[lua]
function MayorDemote( victim, weapon, killer )
if victim:Team() == TEAM_MAYOR then
victim:ChangeTeam(TEAM_CITIZEN, true)
victim:ChatPrint("You died and you are now a regular citizen.")
killer:AddMoney(1000)
for k, v in pairs (player.GetAll()) do
if v != victim then
v:PrintMessage( HUD_PRINTCENTER, "The mayor has died!" )
end
end
end
end
hook.Add( "PlayerDeath", "mayorDemote", MayorDemote )
[/lua]
cool skip my question haha
Edited:
but i dont want the money added for killing the mayor
Well.. I guess while we're at it, how would you make it so the mayor loses money when he dies? Not saying I want this, just more of the knowledge side. something like
[code]victim:SubtractMoney(500)[/code]
or
[code]victim:LoseMoney(500)[/code]
?
Never mind on my last post I guess
[lua]
function TakeCash( ply, amount )
ply:AddMoney(-amount)
end
[/lua]
I can try to fit that in and experiment to see where it leads me.
Also to make money, I don't know about the guy above me posted the code right / wrong but in wiki it's:
[lua]
function AddSomeCash( ply )
ply:AddMoney(100)
end
[/lua]
Use ply:AddMoney(-200) to take money.
Just answer me this is it possible to not being demoted from mayor if being killed by props, or falling?
[QUOTE=ToddCockerham;24885167]Just answer me this is it possible to not being demoted from mayor if being killed by props, or falling?[/QUOTE]
Yes.
Alright good, got the question down. Now for the request. Can anyone make this please?
[QUOTE=ToddCockerham;24898466]Alright good, got the question down. Now for the request. Can anyone make this please?[/QUOTE]
[lua]function MayorDemote( victim, weapon, killer )
if victim:Team() == (TEAM_MAYOR) && killer:IsPlayer( ) then
victim:SetTeam() == (TEAM_CITIZEN)
victim:ChatPrint("You died and you are now a regular citizen")
for k, v in pairs (player.GetAll()) do
v:PrintMessage( HUD_PRINTCENTER, "The mayor has died!" )
end
end
end
hook.Add( "PlayerDeath", "mayorDemote", MayorDemote )[/lua]
untested but should work
Sigh, don't use
[lua]
victim:SetTeam
[/lua]
instead
[lua]
victim:ChangeTeam
[/lua]
Or else it won't change their salary.
Sorry, you need to Log In to post a reply to this thread.