Jump to content

[QUESTION] getRandomPlayer and death reason


Agon

Recommended Posts

function justTesting() 
myPlayer = getRandomPlayer() 
givePlayerMoney(myPlayer, 1000) 
giveWeapon(myPlayer, 31, 200) 
outputChatBox("You are the choosen one!", myPlayer, 255, 0, 0) 
end 
addCommandHandler("justtest", justTesting) 

For example there are 4 players in my server.

A = 1st player

B = 2nd player

C = 3rd player

D = 4th player.

myPlayer = getRandomPlayer() will get a random player i.e B.

but will "givePlayerMoney(myPlayer, 1000)" line give the player named "B" money and weapon or get another random player?

-----------------------------------------------------------------

Second question. How can i get a player's death reason?

i tried this but didn't work

function playerWasted ( ammo, attacker, weapon, bodypart ) 
if (attacker == 53) then --- if the player drowned 
outputChatBox("You are drowned", source) 
end 
end --- lol forgot this 
addEventHandler("onPlayerWasted", getRootElement(), playerWasted) 

Edited by Guest
Link to comment
  • Other Languages Moderators

1- It will be the same player, your code is fine.

2- The weapon parameter can be the weapon id or death reason id

You can find death reasons here http://wiki.multitheftauto.com/wiki/Death_Reasons

so your code should be:

function playerWasted ( ammo, attacker, weapon, bodypart ) 
     if (weapon == 53) then --- if the player drowned 
          outputChatBox("You are drowned", source) 
     end 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerWasted) 

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...