Hey, how would I give someone money when they kill someone? I want it so if they kill a player, they get 15$.
Networked Int is "Money"
[code]function PlayerDeath( victim, weapon, killer )
if killer:IsPlayer() then
killer:AddMoney(15)
end
end
[/code]
or something like that.
[QUOTE=Busymonkey;21415166][code]function PlayerDeath( victim, weapon, killer )
if killer:IsPlayer() then
killer:AddMoney(15)
end
end
[/code]
or something like that.[/QUOTE]
Wow, I am an idiot. I made a timer to test if my save system worked, and I used v:AddMoney( 15 ), so I don't know why I didn't try killer:AddMoney( 15 ) for this function. Should work, thank you.
It doesn't work :(
Do you have Networked Int "AddMoney" too?
[QUOTE=Dragge;21416029]Do you have Networked Int "AddMoney" too?[/QUOTE]
What do you mean Networked int "AddMoney"? I have the Networked Int, "Money", and the function AddMoney....
Hmm, well the code Busymonkey posted should work then.
Are you calling it from the server or the client?
[QUOTE=Dragge;21416273]Hmm, well the code Busymonkey posted should work then.
Are you calling it from the server or the client?[/QUOTE]
Server.
Hmm. Then im blank..
but you could try
[lua]
hook.Add( "PlayerDeath", "GiveMoney", function( victim, weapon, killer )
if killer:IsPlayer() then
killer:AddMoney(15)
end
end )
[/lua]
( Its the same thing Busymonkey posted, just in another way )
Im learing lua, so I dont really know what im doing all the time. :S
[QUOTE=Dragge;21416411]Hmm. Then im blank..
but you could try
[lua]
hook.Add( "PlayerDeath", "GiveMoney", function( victim, weapon, killer )
if killer:IsPlayer() then
killer:AddMoney(15)
end
end )
[/lua]
( Its the same thing Busymonkey posted, just in another way )
Im learing lua, so I dont really know what im doing all the time. :S[/QUOTE]
That did work, but even if I die it gives me 15$....
Thats because you're the killer. You kill yourself.
[lua]
hook.Add( "PlayerDeath", "GiveMoney", function( victim, weapon, killer )
if killer:IsPlayer() and killer~=victim then
killer:AddMoney(15)
end
end )
[/lua]
Idk if that works, just give it a try.
Thank you Dragge. It worked, and it really helped. Thanks!
No problem :)
Sorry, you need to Log In to post a reply to this thread.