ZeyadGTX Posted September 12, 2014 Share Posted September 12, 2014 Hello I use This spawn protection but its not working idk why i think because of using headshot ? ! i tried everything but not working i use the Headshot in the community not the default headshot ! Client Side : addEventHandler("onClientPlayerDamage",getRootElement(), function() if getElementData(getLocalPlayer(),"spawnprotect") == "true" then cancelEvent() end end ) Server : addEventHandler("onPlayerSpawn",getRootElement(), function() setElementData(source,"spawnprotect","true") setElementAlpha(source,150) setTimer(setElementData,10000,1,source,"spawnprotect","false") setTimer(setElementAlpha,10000,1,source,255) end ) Link to comment
pa3ck Posted September 12, 2014 Share Posted September 12, 2014 Try this: addEventHandler("onPlayerSpawn",getRootElement(), function() local source = source setElementData(source,"spawnprotect","true") setElementAlpha(source,150) setTimer(setElementData,10000,1,source,"spawnprotect","false") setTimer(setElementAlpha,10000,1,source,255) end ) But also, when using headshot it kills you right away. You might need to modify it. Link to comment
ZeyadGTX Posted September 12, 2014 Author Share Posted September 12, 2014 Works for Headshots ? what to modify ? Link to comment
pa3ck Posted September 12, 2014 Share Posted September 12, 2014 Post your headshot function. Link to comment
ZeyadGTX Posted September 12, 2014 Author Share Posted September 12, 2014 Client function sendHeadshot ( attacker, weapon, bodypart, loss ) if attacker == getLocalPlayer() then if bodypart == 9 then triggerServerEvent( "onServerHeadshot", getRootElement(), source, attacker, weapon, loss ) setElementHealth ( source, 0 ) setPedHeadless( source, true ) end end end addEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot ) addEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot ) Server function MakePlayerHeadshot( attacker, weapon, bodypart, loss ) if getElementType ( attacker ) == "ped" then if bodypart == 9 then triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) setPedHeadless ( source, true ) killPed( source, attacker, weapon, bodypart ) setTimer( BackUp, 900, 1, source ) end end end function MakeHeadshot( source, attacker, weapon, loss ) triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) killPed( source, attacker, weapon, 9 ) setPedHeadless ( source, true ) setTimer( BackUp, 900, 1, source ) end function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end function outputHeadshotIcon (killer, weapon, bodypart) if bodypart == 9 then cancelEvent() local r2,g2,b2 = getTeamColor ( getPlayerTeam( killer ) ) local r1,g1,b1 = getTeamColor ( getPlayerTeam( source ) ) exports.killmessages:outputMessage ( {getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) }, getRootElement(),r2,g2,b2) end end addEvent ( "onServerHeadshot", true ) addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot ) addEventHandler( "onPlayerKillMessage", getRootElement(), outputHeadshotIcon ) addEventHandler( "onServerHeadshot", getRootElement(), MakeHeadshot ) Link to comment
pa3ck Posted September 12, 2014 Share Posted September 12, 2014 Just give the if statment(s) an other condition like: and getElementData(source, "spawnprotect") ~= "true" then Link to comment
ZeyadGTX Posted September 12, 2014 Author Share Posted September 12, 2014 what you mean ? do i replace that with line ? Link to comment
pa3ck Posted September 12, 2014 Share Posted September 12, 2014 function MakePlayerHeadshot( attacker, weapon, bodypart, loss ) if getElementType ( attacker ) == "ped" and getElementData ( source, "spawnprotect") ~= "true" then -- this one here if bodypart == 9 then triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) setPedHeadless ( source, true ) killPed( source, attacker, weapon, bodypart ) setTimer( BackUp, 900, 1, source ) end end end Do the same with the rest of the functions. Link to comment
ZeyadGTX Posted September 12, 2014 Author Share Posted September 12, 2014 Same problem 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