DarkLink Posted July 11, 2011 Share Posted July 11, 2011 Okay guys, here I am again .. I have this code: server side function playerKilled(ammo, attacker, weapon, bodypart) outputChatBox("hei") if(attacker ~= false) then outputChatBox("hei2") if(getPlayerTeam(source) == team_immigrantsSP) then outputChatBox("hei3") if(getPlayerTeam(attacker) == team_policeSP) then outputChatBox("hei4") if(getElementData(source, "canBeKilled", false) == false) then outputChatBox("hei5") setElementInterior(attacker, prisonForPolice) setTimer(setElementPosition, 500, 1, attacker, xP, yP, zP + 1) end end end end end addEventHandler ("onPlayerWasted", getRootElement(), playerKilled) function playerDamage_text ( attacker, weapon, bodypart, loss ) if ( bodypart == 9 ) then killPed(source) end end addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text ) The problem is: when I headshot a emigrant (I am police) he dies, but on function playerKilled, I just see the "heei" on chatbox, not "heei2" .. not "heei3".. not "heei4" . why the well ? The condition is, if attacker exists I mean, the emigrant is killed by him, not by fall.. or something else.. But it dont go throuh that condition Can someone help me? thanks. Link to comment
Castillo Posted July 11, 2011 Share Posted July 11, 2011 function playerKilled(ammo, attacker, weapon, bodypart) outputChatBox("hei") if(attacker ~= false) then outputChatBox("hei2") if(getPlayerTeam(source) == getTeamFromName("IMIGRANTS OR WHATEVER TEAM NAME")) then outputChatBox("hei3") if(getPlayerTeam(attacker) == getTeamFromName("POLICE TEAM NAME")) then outputChatBox("hei4") if(getElementData(source, "canBeKilled") == false) then outputChatBox("hei5") setElementInterior(attacker, prisonForPolice) setTimer(setElementPosition, 500, 1, attacker, xP, yP, zP + 1) end end end end end addEventHandler ("onPlayerWasted", getRootElement(), playerKilled) function playerDamage_text ( attacker, weapon, bodypart, loss ) if ( bodypart == 9 ) then killPed(source) end end addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text ) Set your team names in getTeamFromName and see if it works that way. Link to comment
DarkLink Posted July 11, 2011 Author Share Posted July 11, 2011 function playerKilled(ammo, attacker, weapon, bodypart) outputChatBox("hei") if(attacker ~= false) then outputChatBox("hei2") if(getPlayerTeam(source) == getTeamFromName("IMIGRANTS OR WHATEVER TEAM NAME")) then outputChatBox("hei3") if(getPlayerTeam(attacker) == getTeamFromName("POLICE TEAM NAME")) then outputChatBox("hei4") if(getElementData(source, "canBeKilled") == false) then outputChatBox("hei5") setElementInterior(attacker, prisonForPolice) setTimer(setElementPosition, 500, 1, attacker, xP, yP, zP + 1) end end end end end addEventHandler ("onPlayerWasted", getRootElement(), playerKilled) function playerDamage_text ( attacker, weapon, bodypart, loss ) if ( bodypart == 9 ) then killPed(source) end end addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text ) Set your team names in getTeamFromName and see if it works that way. Thanks for ur reply castillo, but I cant see outputChatBox("hei2"), and the changes u do its after that Wont work anyway, right? And I used alot times getPlayerTeam() and it works, any problem with that function? or? Thanks bro. Link to comment
DarkLink Posted July 11, 2011 Author Share Posted July 11, 2011 Maybe when I use killPed(source), the event onPlayerWasted dont trigger ? oO Thanks Link to comment
Castillo Posted July 11, 2011 Share Posted July 11, 2011 Yes, it triggers when a player dies. Btw, you changed team names in getTeamFromName? Edit: You want to check if the player team is imigrants (example team name) or police? if so use this: function playerKilled(ammo, attacker, weapon, bodypart) outputChatBox("hei") if(attacker ~= false) then outputChatBox("hei2") if(getPlayerTeam(source) == getTeamFromName("IMIGRANTS OR WHATEVER TEAM NAME")) then outputChatBox("hei3") elseif(getPlayerTeam(attacker) == getTeamFromName("POLICE TEAM NAME")) then outputChatBox("hei4") end if(getElementData(source, "canBeKilled") == false) then outputChatBox("hei5") setElementInterior(attacker, prisonForPolice) setTimer(setElementPosition, 500, 1, attacker, xP, yP, zP + 1) end end end addEventHandler ("onPlayerWasted", getRootElement(), playerKilled) Link to comment
DarkLink Posted July 11, 2011 Author Share Posted July 11, 2011 Bro it doesnt trigger! This is bad for mta I tryed killing a player without headshot, and all went ok. but when I make headshot, it will kill ped with function killPlayer. And then the player get killed, but the event onPlayerWasted doesnt get triggered How to solve this? Thanks. Link to comment
Castillo Posted July 11, 2011 Share Posted July 11, 2011 Well, maybe use setElementHealth(source,0) instead of killPed() ? Link to comment
DarkLink Posted July 11, 2011 Author Share Posted July 11, 2011 Well, maybe use setElementHealth(source,0) instead of killPed() ? Yes it fixed! Thanks alot bro ;D 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