VenomOG Posted December 26, 2018 Share Posted December 26, 2018 Problem ~ When it runs, it shows for everyone, when removing stars, it removes everyone stars, client trigger for everyone, Intension ~ Evade script, if player is wanted, then it stars timer and removes the wanted when timer ends, Code ~ function evade(player) local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do local level = getPlayerWantedLevel ( thePlayer ) if ( level > 1 ) then triggerClientEvent(thePlayer,"StartEvadeTimer",thePlayer) end end end setTimer(evade,1000,1) addEvent("removeEvadeStars",true) addEventHandler("removeEvadeStars",root,function() setPlayerWantedLevel(client,0) setElementData(client,"Charges",0) end) CLIENT~ local x,y = guiGetScreenSize() local sx, sy = x/1280, y/768 addEvent("StartEvadeTimer",true) addEventHandler("StartEvadeTimer",root,function() addEventHandler( "onClientRender", root, showRobTime ) Time = 10 tick = getTickCount() end) function showRobTime( ) if getElementData( localPlayer, "ArrestedBy" ) or getElementData(localPlayer,"Jailed") == "yes" or isPedDead ( localPlayer ) then removeEventHandler("onClientRender",root,showRobTime) return end if getTickCount( )-tick >= 1000 then Time = Time -1 tick = getTickCount() end dxDrawText(Time.." seconds left ", sx*69, sy*728, sx*187, sy*758, tocolor(254, 0, 0, 255), 1, "default-bold", "left", "bottom", false, false, false, false, false) if Time <= 0 then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("removeEvadeStars",localPlayer) end end Link to comment
Ab-47 Posted December 27, 2018 Share Posted December 27, 2018 (edited) Try this, not entirely sure what your issue is but from what I gathered, maybe the level variable was getting set constantly with the loop by all players so pack them in a table and maybe it would give an individual value. level = {} function evade(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do level[thePlayer] = getPlayerWantedLevel ( thePlayer ) if ( level[thePlayer] > 1 ) then triggerClientEvent(thePlayer,"StartEvadeTimer",thePlayer) end end end setTimer(evade,1000,1) Edited December 27, 2018 by Ab-47 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now