offline |
Nováček |
|
Joined: Tue 18. Aug 2015 11:56:01 Posts: 9
Points: 151 002 Cash: $699
|
Přeji krásný den všem co nyní čtou toto téma nerad jej zakládám ačkoliv už si nevím rady s tímto kódem. Zabijí tak jak je nastaven a vypíše že byl hráč kicknutý ale hráč zůstává ve hře můžete mi prosím poradit jestli je chyba v kódu nebo někde jinde ? Děkuji předem za cokoliv co by mi mohlo pomoci. Server Code: local raceState = ""
function onPlayerAFKKill () if raceState == "Running" then setElementData(source,"afkkills",getElementData(source,"afkkills")+1) if getElementData(source,"afkkills") == 4 then kickPlayer(source,"You was AFK for to long.") triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).."#FFFFFF, left [AFK]!",2565,255,255) outputChatBox(getPlayerName(source).."#FFFFFF was kicked by the #FF0000AFK System#FFFFFF.",getRootElement(),255,0,0,true) return end setElementHealth(source, 0) local kills = getElementData(source,"afkkills") triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).."#FFFFFF, #FF9900AFK #FFFFFF[#FF9900"..kills.."#FFFFFF/4]!",2565,255,255,"afk") end end addEvent("onPlayerAFKTimelimit",true) addEventHandler("onPlayerAFKTimelimit",getRootElement(),onPlayerAFKKill)
function onPlayerIsBack () setElementData(source,"afkkills",0) end addEvent("onPlayerIsBack",true) addEventHandler("onPlayerIsBack",getRootElement(),onPlayerIsBack)
function changeRaceState(newStateName) raceState = newStateName end addEvent("onRaceStateChanging", true) addEventHandler( "onRaceStateChanging", getRootElement(), changeRaceState) Client Code: local me = getLocalPlayer() setElementData(me,"afkkills",0) local afktime = 0 local guiAFKAlpha = 0 guiAFKAlphaSet = 0.02 local ltfont = guiCreateFont("ltfont.ttf",20)
function permanentPlayerAFKTime () local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if isPedInVehicle (getLocalPlayer()) then --check freeze state if(isElementFrozen (vehicle)) then afktime = 0 return end --check movement state local x,y,z = getElementVelocity (vehicle) local speed = ((x^2 + y^2 + z^2)^(0.5))* 180 if speed > 1 then checkPlayerAFKStatus() afktime = 0 return end --add afkTimer afktime = afktime+1 --trigger Event if afktime == 30 then triggerServerEvent("onPlayerAFKTimelimit",getLocalPlayer()) guiAFKAlphaSet = -0.05 end if afktime == 15 then guiSetVisible(afkImage,true) addEventHandler("onClientRender",getRootElement(),renderAfkImage) guiAFKAlphaSet = 0.0125 end else afktime = 0 end end setTimer(permanentPlayerAFKTime,1000,0)
function onPlayerPressedKey(button) if button == "u" then return end if button == "mouse1" then return end if button == "mouse2" then return end if button == "mouse3" then return end if button == "mouse_wheel_up" then return end if button == "mouse_wheel_down" then return end --afktime = 0 --checkPlayerAFKStatus() end addEventHandler("onClientKey",getRootElement(), onPlayerPressedKey)
function checkPlayerAFKStatus() if getElementData(me,"afkkills") > 0 then triggerServerEvent("onPlayerIsBack",getLocalPlayer()) end guiAFKAlphaSet = -0.05 end
afkImage = guiCreateStaticImage(0.3,0.35,0.4,0.275,"tools/images/afk_info/afk.png",true) guiSetVisible(afkImage,false) guiSetAlpha(afkImage,0) afkTimeLeft = guiCreateLabel( 0.85,0.8,0.15,0.2,"",true,afkImage) guiSetFont(afkTimeLeft,ltfont)
function renderAfkImage() local alpha = guiGetAlpha(afkImage) guiSetAlpha(afkImage,alpha+guiAFKAlphaSet) guiSetText(afkTimeLeft,(30-afktime)) if alpha + guiAFKAlphaSet >= 1 then guiAFKAlphaSet = 0 elseif alpha + guiAFKAlphaSet <= 0 then removeEventHandler("onClientRender",getRootElement(),renderAfkImage) guiSetVisible(afkImage,false) end end
Meta Code: <meta> <info author="Merry" type="misc" version="1.0.0" name="antiafk"/> <oop>true</oop> <script src="client.lua" type="client"/> <script src="server.lua" type="server"/> <file src="afk.png" /> </meta>
|
|