For some reason, every time I try and promote a cop to a chief it doesn't work, it just tells me there is already a chief.
[code]local Server = {}
local table = table
local string = string
local TIDS = {TEAM_POLICE}
function Server.PromoteCMD(ply,args)
for k,v in pairs(player.GetAll()) do
if v:Team() == TEAM_CHIEF then
haschief = true
end
end
if ply:Team() != TEAM_MAYOR then ply:ChatPrint("Mayor only!") return "" end
if haschief == true then ply:ChatPrint("There already is a chief!") return "" end
if !args then ply:ChatPrint("Format: /promote [player's name] (You can only promote Cops!") return "" end
for k,v in pairs(player.GetAll()) do
if string.find(string.lower(v:GetName()),string.lower(args)) and table.HasValue(TIDS,v:Team()) then
v:ChangeTeam(TEAM_CHIEF, true)
v:Spawn()
Notify(v, 1, 4, "You have beem promoted to Police Chief!")
return ""
end
end
ply:ChatPrint("Player not found or player was not a cop.")
return ""
end
AddChatCommand("/promote", Server.PromoteCMD)[/code]
Sorry for the bump but I really need this fixed. It use to work before but then all of a sudden it bugged out.
You are looping player.GetAll() loop inside player.GetAll() loop, why?
Really that makes no sense, command for promoting everyone?
Also, that loops make it so if there is a chief in the server, haschief == true
Ollie Is A Dumb Ass Ignore Him All Of The Code Is Right But You Forgot To Hook It
Sorry, you need to Log In to post a reply to this thread.