جرب,
-- Server Side #
local Timer = {}
local marker = createMarker(...)
addEventHandler('onPlayerDamage',root,function(attacker)
if attacker and attacker ~= source and getElementType(attacker) == 'player' and getPlayerTeam(attacker) and getTeamName(getPlayerTeam(attacker)) == 'Police' then
if getPlayerWantedLevel(source) > 0 and getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= 'Police' then
if isTimer(Timer[source]) then killTimer(Timer[source]) Timer[source] = nil end
if not getElementData(source,'getPlayerFromData') then setElementData(source,'getPlayerFromData',source) end
toggleAllControls(source,false,true,false)
toggleControl(source,'forwards',true)
setControlState(source,'forwards',true)
Timer[source] = setTimer(function()
local rx,ry,rz,ax,ay,az,px,py,pz = getElementRotation(attacker),getElementPosition(attacker),getElementPosition(source)
setElementRotation(source,rx,ry,rz)
if getDistanceBetweenPoints3D(ax,ay,az,px,py,pz) <= 5 then
toggleControl(source,'forwards',false)
else
toggleControl(source,'forwards',true)
setControlState(source,'forwards',true)
end
end,50,0,source)
end
end
end
)
addEventHandler('onMarkerHit',marker,function(plr)
if getElementType(plr) == 'player' and getElementData(plr,'getPlayerFromData') then
toggleAllControls(getElementData(plr,'getPlayerFromData'),true,true,true)
setElementPosition(getElementData(plr,'getPlayerFromData'),x,y,z)
end
end
)