Need help with Darkrp Mayor Guard demote on Mayor's death.
8 replies, posted
On my Darkrp server I have it so when the Mayor dies he gets demoted, but I would also like it if the Mayor's Guard got demoted when the Mayor dies too.
Here is the code for the Mayor's demotion on death.
[CODE]hook.Add("PlayerDeath","DemoteMayor",function(v,k)
if (v:Team() == TEAM_MAYOR) then
v:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The mayor has been killed!");
end;
end;
end);[/CODE]
Thanks
change
[lua]
if (v:Team() == TEAM_MAYOR) then
[/lua]
to
[lua]
if (v:Team() == TEAM_MAYOR) || (v:Team() == TEAM_GUARD) then
[/lua]
[QUOTE=Hyper Iguana;39022930]change
[lua]
if (v:Team() == TEAM_MAYOR) then
[/lua]
to
[lua]
if (v:Team() == TEAM_MAYOR) || (v:Team() == TEAM_GUARD) then
[/lua][/QUOTE]
Hmmm I changed it to look like this.
[CODE]hook.Add("PlayerDeath","DemoteMayor",function(v,k)
if (v:Team() == TEAM_MAYOR) || (v:Team() == TEAM_MAYORGUARD) then
v:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
end;
end;
end);[/CODE]
But still when I kill the Mayor the Mayor's Guard doesn't get demoted. :*(
Thanks for the help though.
[QUOTE=Tomas018;39023453]Hmmm I changed it to look like this.
[CODE]hook.Add("PlayerDeath","DemoteMayor",function(v,k)
if (v:Team() == TEAM_MAYOR) || (v:Team() == TEAM_MAYORGUARD) then
v:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
end;
end;
end);[/CODE]
But still when I kill the Mayor the Mayor's Guard doesn't get demoted. :*(
Thanks for the help though.[/QUOTE]
[lua]
hook.Add("PlayerDeath","DemoteMayor",function(ply)
if (ply:Team() == TEAM_MAYOR) || (ply:Team() == TEAM_MAYORGUARD) then
ply:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
end;
end;
end);
[/lua]
[QUOTE=J.R.;39023869][lua]
hook.Add("PlayerDeath","DemoteMayor",function(ply)
if (ply:Team() == TEAM_MAYOR) || (ply:Team() == TEAM_MAYORGUARD) then
ply:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
end;
end;
end);
[/lua][/QUOTE]
That will still only change the job for the Guard if HE is killed and not if the mayor is.
[QUOTE=ms333;39023894]That will still only change the job for the Guard if HE is killed and not if the mayor is.[/QUOTE]
[lua]
hook.Add("PlayerDeath","DemoteMayor",function(ply)
if (ply:Team() == TEAM_MAYOR) then
ply:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
if v:Team() == TEAM_MAYORSPROTECTOR then
v:ChangeTeam(TEAM_CITIZEN,true);
end;
end;
end;
end);
[/lua]
oops sorry
[QUOTE=J.R.;39023975][lua]
hook.Add("PlayerDeath","DemoteMayor",function(ply)
if (ply:Team() == TEAM_MAYOR) then
ply:ChangeTeam(TEAM_CITIZEN,true);
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"The current Mayor of the city has been Assassinated!");
if v:Team() == TEAM_MAYORSPROTECTOR then
v:ChangeTeam(TEAM_CITIZEN,true);
end;
end;
end;
end);
[/lua]
oops sorry[/QUOTE]
Awesome dude, works perfectly.
Thank you very much!
[QUOTE=Tomas018;39025710]Awesome dude, works perfectly.
Thank you very much![/QUOTE]
What file do u add this to and where do u add it
[QUOTE=Teamrealtime;41302758]What file do u add this to and where do u add it[/QUOTE]
You put it in main.lua
gamemodes>darkrp>gamemode>server>main.lua
Sorry, you need to Log In to post a reply to this thread.