-- Server Side
x, y, z = 0, 0, 0
thePed = createPed ( 285, x, y, z )
theMarker = createMarker ( 0, 0, 0, "cylinder", 15, 0, 0, 0, 0 )
attachElements ( theMarker, thePed, 0, 0, -1 )
setTimer ( giveWeapon, 500, 1, thePed, 30, 999, true )
addEventHandler ( "onMarkerHit", theMarker,
function ( thePlayer )
if getElementType(thePlayer) == 'player' then
triggerClientEvent ( thePlayer, "setPedAttacking", thePlayer, thePed )
outputChatBox ( "* Start Shooting !!!", thePlayer, 255, 255, 0, true )
end
end
)
addEventHandler ( "onMarkerLeave", theMarker,
function ( thePlayer )
if getElementType(thePlayer) == 'player' then
triggerClientEvent ( thePlayer, "setPedStanding", thePlayer, thePed )
outputChatBox ( "* Stop Shooting !!!", thePlayer, 255, 255, 0, true )
end
end
)
addEvent ( "setPedWeaponAmmo", true )
addEventHandler ( "setPedWeaponAmmo", root,
function ( )
setWeaponAmmo ( thePed, 30, 999 )
end
)
-- Client Side
addEvent ( "setPedAttacking", true )
addEventHandler ( "setPedAttacking", root,
function ( thePed )
setTimer (
function ( )
x, y, z = getElementPosition ( localPlayer )
setPedAimTarget ( thePed, x, y, z )
end
, 100, 0 )
setPedControlState ( thePed, "fire", true )
end
)
addEvent ( "setPedStanding", true )
addEventHandler ( "setPedStanding", root,
function ( thePed )
setPedControlState ( thePed, "fire", false )
for _, x3NAD in ipairs ( getTimers ( 100 ) ) do
killTimer ( x3NAD )
end
triggerServerEvent ( "setPedWeaponAmmo", localPlayer )
end
)