Jump to content

onPlayerWasted problem


DarkLink

Recommended Posts

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 :x

Can someone help me? thanks.

Link to comment
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
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

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

Bro it doesnt trigger! This is bad for mta :x

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 :x

How to solve this?

Thanks.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...