1. Post #1
    Gold Member
    Simple_sa's Avatar
    July 2009
    97 Posts
    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

  2. Post #2
    Gold Member
    Crazy Quebec's Avatar
    May 2008
    2,449 Posts
    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://notepad-plus.sourceforge.net/
    http://www.garrysmod.org/downloads/?a=view&id=62428

  3. Post #3
    Gold Member
    Simple_sa's Avatar
    July 2009
    97 Posts
    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.

  4. Post #4
    Gold Member
    Crazy Quebec's Avatar
    May 2008
    2,449 Posts
    You would hook to the mayor's death with the PlayerDeath gamemode hook.

    function MayorDeath( victim, weapon, killer )
    	if victim:Team() == TEAM_MAYOR then
    		--Stuff
    	end
    end
     
    hook.Add( "PlayerDeath", "MayorDeathCheck", MayorDeath) 

    http://wiki.garrysmod.com/?title=Gamemode_Hooks
    http://wiki.garrysmod.com/?title=Gamemode.PlayerDeath
    http://wiki.garrysmod.com/?title=Player.Team

  5. Post #5
    Gold Member
    Simple_sa's Avatar
    July 2009
    97 Posts
    Ok. I will try that. Thank you.

  6. Post #6

    February 2010
    12 Posts
    You would hook to the mayor's death with the PlayerDeath gamemode hook.

    function MayorDeath( victim, weapon, killer )
    	if victim:Team() == TEAM_MAYOR then
    		--Stuff
    	end
    end
     
    hook.Add( "PlayerDeath", "MayorDeathCheck", MayorDeath) 

    http://wiki.garrysmod.com/?title=Gamemode_Hooks
    http://wiki.garrysmod.com/?title=Gamemode.PlayerDeath
    http://wiki.garrysmod.com/?title=Player.Team
    Where do you put the code?
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 2 (list)

  7. Post #7
    Busymonkey's Avatar
    July 2009
    1,974 Posts
    @ Dan Brown

    27th October 2009

  8. Post #8
    Facepunch Resident Alcoholic!
    sphinxa279's Avatar
    July 2007
    7,495 Posts
    /facepalm

    Stupid bumper, why would they go all the way back to these threads just to nudge them up :saddowns:
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Disagree Disagree x 1 (list)

  9. Post #9
    slay3r36's Avatar
    January 2010
    223 Posts
    its better to bump instead of create a new thread for the same question

    anyway, put this:
    function MayorDeath( victim, weapon, killer )
        if victim:Team() == TEAM_MAYOR then
              victim:SetTeam( TEAM_CITIZEN )
        end
    end
     
    hook.Add( "PlayerDeath", "MayorDeathCheck", MayorDeath) 

    in garrysmod/garrysmod/lua/autorun/server/randomname.lua
    Reply With Quote Edit / Delete Reply France Show Events Useful Useful x 1 (list)

  10. Post #10

    February 2010
    12 Posts
    Thank you.
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 1Agree Agree x 1 (list)

  11. Post #11
    wrong thread

    fuck my life

    sorry.
    Reply With Quote Edit / Delete Reply Windows 7 United Kingdom Show Events Funny Funny x 4 (list)

  12. Post #12
    ST20winD's Avatar
    August 2012
    10 Posts
    [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
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 4Late Late x 2Winner Winner x 1 (list)

  13. Post #13

    August 2011
    34 Posts
    Wont work..
    Never mind lol.
    Had a comma.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 3Late Late x 1 (list)