Jump to content

can you please review this code


Machine

Recommended Posts

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

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