• Darkrp General Script Needed : )
    24 replies, posted
-snip-Made My own
[lua] function FindTheMayor( ply ) if ply:Team() == TEAM_MAYOR >= 0 then game.ConsoleCommand("rp_maxmayorguards 1") -- maybe it would be "rp_maxmayorguards", "1" ? else game.ConsoleCommand("rp_maxmayorguards 0") end end hook.Add("PlayerJoinTeam", "FindMyMayor", FindTheMayor) [/lua] Untested, unsure if this is what you wanted.
what the hell? it doesnt even seem complete... [editline]26th January 2011[/editline] and now i must wait hours.... for a simple response
[QUOTE=Raymonx1;27661643]what the hell? it doesnt even seem complete... [editline]26th January 2011[/editline] and now i must wait hours.... for a simple response[/QUOTE] Just for that, I won't give you a valid response. Don't disrespect us and expect to get something good out of it.
I sowwy....
So, How often do you want this to run? Do you want it just when the mayor gets assassinated it will run?
-snip-
bump
When a player wants to be a guard, loop through all players and check for a mayor. When the mayor is demoted, demote the guard.
Raymon, right now I really don't like you. You didn't bump right, your grammar is horrible, and you sound like an ungrateful 10 year old. However, [lua] function MayorCheck( pl, victim ) for k,v in pairs(player.GetAll()) do if v:Team(TEAM_MAYOR) >= 0 then RunConsoleCommand("rp_maxmayorguards", "1") end timer.Create("mayordeathcheck", 2, 0, function() if victim:IsTeam() == TEAM_MAYOR then victim:ChangeTeam(TEAM_CITIZEN, true) timer.Stop("mayordeathcheck") if v:Team(TEAM_MAYORGUARD) >= 0 then RunConsoleCommand("rp_maxmayorguards", "0") pl:ChangeTeam(TEAM_CITIZEN, true) end end end) end end hook.Add("PlayerDeath", "mayorcheck", MayorCheck) [/lua] This isn't my best work, I don't know if the hook is right. I'm sure some coder can correct this though, if it's usable? haha.
-snip-
[QUOTE=Derek_SM;27667932]Raymon, right now I really don't like you. You didn't bump right, your grammar is horrible, and you sound like an ungrateful 10 year old. However, -- useless code here -- [/QUOTE] Wow you are an asshole stirring up trouble. Why do you even use a timer for this code? [lua] -- PUT THIS AT THE BOTTOM OF sv_gamemode_functions.lua function mcheck( vic, wep, kil ) if vic:Team() == TEAM_MAYOR then vic:SetTeam(TEAM_CITIZEN) NotifyAll(1,4,"The mayor has been killed by a "..wep) for a,b in pairs(player.GetAll()) do if b:Team() == TEAM_MAYORSGUARD then b:SetTeam(TEAM_CITIZEN) end end kil:AddMoney(500) Notify(kil,1,4,"You have gotten $500 from the underground for killing the mayor!") end end hook.Add("PlayerDeath", "mcheck", mcheck) -- PUT THIS IN THE meta:ChangeTeam FUNCTION. if team.NumPlayers(TEAM_MAYOR) == 0 then Notify(ply, 1, 4, "There is no mayor for you to guard right now.") return end [/lua] Untested.
Your code is wrong, and maybe he doesn't want the killer to have 500 dollars after he kills the damn mayor. Also, right here: [lua] NotifyAll(1,4,"The mayor has been killed by a "..wep) [/lua] Shouldn't you use: [lua] NotifyAll(1,4,"The mayor has been killed by a " .. killer:GetWeapon() .. " !") [/lua] >.>?
The second argument of the PlayerDeath hook is the weapon the player was killed by.
[QUOTE=zzaacckk;27684435]The second argument of the PlayerDeath hook is the weapon the player was killed by.[/QUOTE] It've never worked properly.
Where did you put it and what errors were returned?
--snip--- doesn't work derek
--snip--
Instead of replying "doesn't work" say specifically what happens to make it unsuccessful, this helps people answer your questions. Also more "wants to" than "can".
--snip--
Anyone?
--snip--
[url]http://wiki.garrysmod.com/?title=Lua_Tutorial_Series[/url]
Ya. Im just gonna try to do it my self... thanks all
I like how all the justin beibers in here are failing so much. Seen as though none of you can do this I could sell you a fully working script that I made a few days ago for my server that demotes the mayor and his bodyguards when the mayor dies and the bodyguard job is only available when there is a mayor for £5? [editline]31st January 2011[/editline] [QUOTE=Derek_SM;27683773]Your code is wrong, and maybe he doesn't want the killer to have 500 dollars after he kills the damn mayor. Also, right here: [lua] NotifyAll(1,4,"The mayor has been killed by a "..wep) [/lua] Shouldn't you use: [lua] NotifyAll(1,4,"The mayor has been killed by a " .. killer:GetWeapon() .. " !") [/lua] >.>?[/QUOTE] Seriously guys, I am not trying to be rude but there isn't really a nice way to say this. Everyone who has posted so far has only posted bad code and this thread has condescended into a coding nightmare. For example it isn't : [lua] NotifyAll(1,4,"The mayor has been killed by a " .. killer:GetWeapon() .. " !") [/lua] It is any of these: [lua] NotifyAll(1,4,"The mayor has been killed by a " .. killer:GetActiveWeapon():GetName() .. " !") NotifyAll(1,4,"The mayor has been killed by a " .. wep:GetName() .. " !") NotifyAll(1,4,"The mayor has been killed by a " .. wep:GetClass() .. " !") [/lua] Please only post code that works, if it's a slight mistake that is fine, but all of the code in this thread is wrong. Again, I am sorry if I sound rude, I don't want to sound like the stereotypical narcissist facepuncher, but this thread has gone on for too long with broken code.
Sorry, you need to Log In to post a reply to this thread.