Machine Posted August 28, 2020 Share Posted August 28, 2020 what i am trying to achieve is when killer kill another player he will get all the killed player money , is this functional or i messed up the parameters function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) local money = getPlayerMoney(source) if ( killer ) and ( killer ~= source ) then givePlayerMoney ( killer, source ) end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) Link to comment
Moderators IIYAMA Posted August 28, 2020 Moderators Share Posted August 28, 2020 27 minutes ago, Machine said: is this functional or i messed up the parameters You can't give a player to another player. givePlayerMoney ( killer, source ) Some extra validation might be required, not only a player can kill another player. if ( killer ) and ( killer ~= source ) and getElementType(killer) == "player" and money > 0 then givePlayerMoney ( killer, money ) end Link to comment
Tekken Posted August 28, 2020 Share Posted August 28, 2020 Replace givePlayerMoney(killer, source) with givePlayerMoney(killer, (getPlayerMoney(source) or 0)); As you need to get the killed player money before you can give it to the killer. Good luck. Link to comment
TAPL Posted August 29, 2020 Share Posted August 29, 2020 Also use setPlayerMoney to remove the killed player money after giving the amount to the killer, assuming that's what you're trying to do. 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