DarkRp Mayor Dies.

Hey I have a quick request to throw out there. I am curious on how I can make it so that when the mayor dies he is assassinated and is moved back to the citizen job. Thanks in advanced for people that help.


function MayorDemote( victim, weapon, killer )
	if victim:Team() == (TEAM_MAYOR) 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 )

Something like that.

[lua]
victim:SetTeam(TEAM_CITIZEN)
[/lua]


function MayorDemote( victim, weapon, killer )
	if victim:Team() == TEAM_MAYOR 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 )

Fixed.

this helped me alot to is it allright if i use it to ?

It’s not like it’s licensed, Go ahead.

thanks

What file would this be put in?

init.lua

Thanks

Useful’d

your tabbing is bad.

More like horrible.

That script demotes, but doesn’t change the Salary or Job title. Would anyone kindly fix it?

[LUA]function MayorDemote( victim, weapon, killer )
if victim:Team() == TEAM_MAYOR then
ChangeJob(victim,“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]

It should work…

Edit: What happened to lua tag lol

That doesn’t work, it doesn’t reset your salary or job title.

[LUA]
function MayorDemote( victim, weapon, killer )
if victim:Team() == TEAM_MAYOR then
victim:UpdateJob(team.GetName(1))
victim:ChatPrint(“You died and you are now a regular citizen”)
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]

It will work I promise :slight_smile:

Nope, that actually made it worse, now the mayor doesn’t change job but changes job title. Salary is still the same.

You’re lying. You havent put the changing of the job anywhere.


function MayorDemote( victim, weapon, killer )
	if victim:Team() == TEAM_MAYOR then
                victim:SetTeam(TEAM_CITIZEN)
		victim:UpdateJob(team.GetName(1))
		victim:ChatPrint("You died and you are now a regular citizen")
		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 )

Their is a bug in your script, When you die as mayor, your salary stays as the mayors salary even though your a citizen.