DarkRP - Mayor demotion on death (Please help)

Hi.

Im ok with lua, but Ive been having problems doing this. Here is what I basically what to do:

If the mayor dies he loses his mayor status. They would be automatically demoted and would become a citizen. Also I would like a message on the screen poping up saying “The mayor has been assinated”.

I can proberly do the message, but having a hard time code the demotion thing. I also dont no where to put it. It should be easy enough, just dont no what to do.

Help would be greatly apperciated.

Thanx, Simple

If you want a specific and direct answer about the workings of a specific gamemode, ask in that gamemode’s thread. All I can tell you is how to find it out yourself, and it’s really not hard.

Just open Notepad++ (if you’re not using that already, see links below) and use the search in files function to find the string “demote” in the DarkRP folder. You’ll find what you’re looking for in no time at all!

http://www.garrysmod.org/downloads/?a=view&id=62428

Thanx, ya ive done that. But I don’t no which files to put it in. (main.lua, etc) But thanx, il ask in gamemodes section I guess.

You would hook to the mayor’s death with the PlayerDeath gamemode hook.

[lua]
function MayorDeath( victim, weapon, killer )
if victim:Team() == TEAM_MAYOR then
–Stuff
end
end

hook.Add( “PlayerDeath”, “MayorDeathCheck”, MayorDeath) [/lua]

Ok. I will try that. Thank you.

Where do you put the code?

@ Dan Brown

27th October 2009

/facepalm

Stupid bumper, why would they go all the way back to these threads just to nudge them up :saddowns:

its better to bump instead of create a new thread for the same question

anyway, put this: [lua]function MayorDeath( victim, weapon, killer )
if victim:Team() == TEAM_MAYOR then
victim:SetTeam( TEAM_CITIZEN )
end
end

hook.Add( “PlayerDeath”, “MayorDeathCheck”, MayorDeath) [/lua]

in garrysmod/garrysmod/lua/autorun/server/randomname.lua

Thank you.

wrong thread

fuck my life

sorry.

[SUP]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);[/SUP]

Goes in init.lua

Wont work…
Never mind lol.
Had a comma.