-
/votemayor frage
also ich hab beim ucrpm mod das /votecop kopiert und es zu /votemayor gemacht aber es geht nicht was muss man machen das es geht
hiers der code
Code:
-- Votemayor
function RoleplayData.VoteMayor(userid, strText)
local Name = _PlayerInfo(userid, "name")
NoNameTxt1 = string.gsub( Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1" ) -- Lets get rid of the special chars.
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "") -- Remove the name
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("/votemayor") then
if RoleplayData.VoteActive then
_PrintMessage(userid, 4, "Somebody is already voting!\nYou have to wait untill it's done.")
return true
end
if RoleplayData[userid].Team == TEAM_YELLOW then
_PrintMessage(userid, 4, "You are already a mayor!")
return true
end
if RoleplayData[userid].IsSleeping then
_PrintMessage(userid, 4, "You can't vote while asleep!")
return true
end
RoleplayData.ResetStats()
RoleplayData.VotesYes = 1
RoleplayData.TotalVotes = 1
RoleplayData.VoteActive = true
_PrintMessageAll(4, Name .. " wants to become mayor!")
_PrintMessageAll(1, Name .. " wants to become mayor!")
RoleplayData.Voter = userid
for i = 1, _MaxPlayers() do
if _PlayerInfo(i, "connected") then
if (userid ~= i) then
_PlayerOption(i, "VoteMayor", RoleplayData.VoteEndTime)
RoleplayData.VoteMayorGUI(i, false)
end
end
end
RoleplayData.VoteTimer = AddTimer(RoleplayData.VoteEndTime, 1, RoleplayData.EndVoteMayor, false)
return true
end
end
function RoleplayData.EndVoteMayor(kick)
local Num = 0
for i = 1, _MaxPlayers() do
if _PlayerInfo(i, "connected") then
_GModText_Hide(i, (RoleplayData.IndexGUI - 10), 1, 0)
_GModRect_Hide(i, (RoleplayData.IndexGUI - 10), 1, 0)
Num = Num + 1
end
end
RoleplayData.TotalVotes = Num
if kick then
RoleplayData.CheckKickVotes()
else
RoleplayData.CheckVotes()
end
end
function VoteMayor(userid, num, seconds)
if num == 1 then
RoleplayData.VotesYes = RoleplayData.VotesYes + 1
_PrintMessage(userid, 4, "You voted: Yes")
_PrintMessageAll(3, _PlayerInfo(userid, "name") .. " voted: Yes")
_PrintMessageAll(1, _PlayerInfo(userid, "name") .. " voted: Yes")
RoleplayData.VotesYes = RoleplayData.VotesYes +1
RoleplayData.TotalVotes = RoleplayData.TotalVotes + 1
RoleplayData.CheckVotes()
else
_PrintMessage(userid, 4, "You voted: No")
_PrintMessageAll(3, _PlayerInfo(userid, "name") .. " voted: No")
_PrintMessageAll(1, _PlayerInfo(userid, "name") .. " voted: No")
RoleplayData.TotalVotes = RoleplayData.TotalVotes + 1
RoleplayData.CheckVotes()
end
_GModText_Hide(userid, (RoleplayData.IndexGUI - 10), 1, 0)
_GModRect_Hide(userid, (RoleplayData.IndexGUI - 10), 1, 0)
end
function RoleplayData.CheckVotes()
local Num = 0
for i = 1, _MaxPlayers() do
if _PlayerInfo(i, "connected") then
Num = Num + 1
end
end
if RoleplayData.TotalVotes == (Num) then
if ((RoleplayData.VotesYes / Num) * 100) > RoleplayData.VoteMayorPercentage then
_PrintMessageAll(4, "Vote Succeeded")
_PrintMessageAll(1, "Vote Succeeded")
RoleplayData[RoleplayData.Voter].Team = TEAM_YELLOW
_PlayerRespawn(RoleplayData.Voter)
RoleplayData[RoleplayData.Voter].Model = "Mayor (gman)"
RoleplayData[RoleplayData.Voter].ModelName = "models/player/gman_high.mdl"
if RoleplayData[RoleplayData.Voter].Job == "Unemployed" then
RoleplayData[RoleplayData.Voter].Job = "Mayor"
end
--RoleplayData.SetModels(userid)´
RoleplayData[RoleplayData.Voter].Position = _EntGetPos(RoleplayData.Voter) -- Get position
RoleplayData[RoleplayData.Voter].Angle = _PlayerGetShootAng(RoleplayData.Voter) -- Get the angle
RoleplayData.ShowGUI(RoleplayData.Voter)
local Health = _PlayerInfo(RoleplayData.Voter, "health")
_PlayerRespawn(RoleplayData.Voter) -- Respawn the player
_PlayerSetHealth(RoleplayData.Voter, Health)
AddTimer(0.05, 1, _EntSetPos, RoleplayData.Voter, RoleplayData[RoleplayData.Voter].Position) -- Move them back
AddTimer(0.05, 1, _EntSetAng, RoleplayData.Voter, RoleplayData[RoleplayData.Voter].Angle) -- Set angle back
else
_PrintMessageAll(4, "Vote Failed!")
_PrintMessageAll(1, "Vote Failed!")
end
if RoleplayData.VoteTimer ~= nil then HaltTimer(RoleplayData.VoteTimer) end
RoleplayData.ResetStats()
end
end
function RoleplayData.VoteMayorGUI(userid, kick)
_GModText_Start("Default")
_GModText_SetPos(0.05, -1)
_GModText_SetTime(RoleplayData.VoteEndTime, 1, 1)
if kick then
_GModText_SetText("Do you want to kick " .. _PlayerInfo(RoleplayData.Voter, "name") .. " from the Mayor?\n\n\n1. Yes\n\n2. No (Any number)")
else
_GModText_SetText(_PlayerInfo(RoleplayData.Voter, "name") .. " wants to become a Mayor!\n\n\n1. Yes\n\n2. No (Any number)")
end
_GModText_SetColor(255, 255, 255, 255)
_GModText_Send(userid, (RoleplayData.IndexGUI - 10))
local Length = (string.len(_PlayerInfo(RoleplayData.Voter, "name")) / 200)
_GModRect_Start("gmod/white")
_GModRect_SetColor(0, 0, 0, 100)
_GModRect_SetPos(0.04, 0.43, (0.2 + Length), 0.15)
_GModRect_SetTime(RoleplayData.VoteEndTime, 1, 1)
_GModRect_Send(userid, (RoleplayData.IndexGUI - 10))
end
-- Kickmayor
function RoleplayData.VoteKickMayor(userid, strText)
local Name = _PlayerInfo(userid, "name")
NoNameTxt1 = string.gsub( Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1" ) -- Lets get rid of the special chars.
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "") -- Remove the name
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("/kickmayor") then
if RoleplayData.VoteActive then
_PrintMessage(userid, 4, "Somebody is already voting!\nYou have to wait untill it's done.")
return true
end
RoleplayData.ResetStats()
RoleplayData.VotesYes = 1
RoleplayData.TotalVotes = 2
RoleplayData.VoteActive = true
for i = 1, _MaxPlayers() do
if not _PlayerInfo(i, "connected") then return end
local Names = _PlayerInfo(i, "name")
if string.find(string.lower(Names), string.lower(Text[3])) then
if RoleplayData[i].Team == TEAM_BLUE then
if (userid == i) then
_PrintMessage(userid, 3, "You can't vote to kick youself")
_PrintMessage(userid, 3, "Use /citizen to become a citizen.")
RoleplayData.ResetStats()
return true
end
_PrintMessageAll(4, Name .. " wants to kick mayor " .. Names .. "!")
_PrintMessageAll(1, Name .. " wants to kick mayor " .. Names .. "!")
RoleplayData.Voter = i
RoleplayData.VoteTimer = AddTimer(RoleplayData.VoteEndTime, 1, RoleplayData.EndVoteMayor, true)
for p = 1, _MaxPlayers() do
if _PlayerInfo(p, "connected") then
if (userid ~= p) and (RoleplayData.Voter ~= p) then
_PlayerOption(p, "VoteKickMayor", RoleplayData.VoteEndTime)
RoleplayData.VoteMayorGUI(p, true)
end
end
end
end
end
end
return true
end
end
function VoteKickMayor(userid, num, seconds)
_GModText_Hide(userid, (RoleplayData.IndexGUI - 10), 1, 0)
_GModRect_Hide(userid, (RoleplayData.IndexGUI - 10), 1, 0)
if num == 1 then
RoleplayData.VotesYes = RoleplayData.VotesYes + 1
_PrintMessage(userid, 4, "You voted: Yes")
_PrintMessageAll(3, _PlayerInfo(userid, "name") .. " voted: Yes")
_PrintMessageAll(1, _PlayerInfo(userid, "name") .. " voted: Yes")
RoleplayData.VotesYes = RoleplayData.VotesYes +1
RoleplayData.TotalVotes = RoleplayData.TotalVotes + 1
RoleplayData.CheckKickVotes()
else
_PrintMessage(userid, 4, "You voted: No")
_PrintMessageAll(3, _PlayerInfo(userid, "name") .. " voted: No")
_PrintMessageAll(1, _PlayerInfo(userid, "name") .. " voted: No")
RoleplayData.TotalVotes = RoleplayData.TotalVotes + 1
RoleplayData.CheckKickVotes()
end
end
function RoleplayData.CheckKickVotes()
local Num = 0
for i = 1, _MaxPlayers() do
if _PlayerInfo(i, "connected") then
Num = Num + 1
end
end
if RoleplayData.TotalVotes == (Num) then
if ((RoleplayData.VotesYes / Num) * 100) > RoleplayData.KickMayorPercentage then
_PrintMessageAll(4, "Vote Succeeded")
_PrintMessageAll(1, "Vote Succeeded")
RoleplayData[RoleplayData.Voter].Team = TEAM_GREEN
_PlayerRespawn(RoleplayData.Voter)
RoleplayData[RoleplayData.Voter].ModelName = nil
RoleplayData[RoleplayData.Voter].Job = "Unemployed"
RoleplayData.SetModels(RoleplayData.Voter)
RoleplayData.ShowGUI(RoleplayData.Voter)
else
_PrintMessageAll(4, "Vote Failed!")
_PrintMessageAll(1, "Vote Failed!")
end
if RoleplayData.VoteTimer ~= nil then HaltTimer(RoleplayData.VoteTimer) end
RoleplayData.ResetStats()
end
end
function RoleplayData.MakeUserCitizen(userid, strText)
local Name = _PlayerInfo(userid, "name")
NoNameTxt1 = string.gsub(Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1")
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "")
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("/makecitizen") then
if not RoleplayData.isAdmin(userid) then _PrintMessage(userid, 3, "You must be admin to use this command!") return true end
for i = 1, _MaxPlayers() do
if not _PlayerInfo(i, "connected") then return end
local Names = _PlayerInfo(i, "name")
if string.find(string.lower(Names), string.lower(Text[3])) then
if RoleplayData[i].Team == TEAM_YELLOW then
RoleplayData[i].Team = TEAM_GREEN
_PlayerRespawn(i)
RoleplayData[i].ModelName = nil
RoleplayData[i].Job = "Unemployed"
RoleplayData.SetModels(i)
RoleplayData.ShowGUI(i)
end
end
end
return true
end
end
function RoleplayData.OutOfCharacter(userid, strText)
local Name = _PlayerInfo(userid, "name") -- Find the name of the player
NoNameTxt1 = string.gsub( Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1" ) -- Lets get rid of the special chars.
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "") -- Remove the name
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("ooc") then -- Check if the player typed "ooc"
local String = ""
for i = 3, table.getn(Text) do
String = String .. Text[i] .. " "
end
_PrintMessageAll(3, Name .. ": (( " .. String .. " ))")
_PrintMessageAll(1, Name .. ": (( " .. String .. " ))")
return true
end
end
function RoleplayData.EndVote(userid, strText)
local Name = _PlayerInfo(userid, "name")
NoNameTxt1 = string.gsub( Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1" )
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "")
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("/endvote") then
if not RoleplayData.isAdmin(userid) then _PrintMessage(userid, 3, "Access Denied.") _PrintMessage(userid, 1, "Access Denied.") return true end
if RoleplayData.VoteActive then
HaltTimer(RoleplayData.VoteTimer)
RoleplayData.ResetStats()
for i = 1, _MaxPlayers() do
if _PlayerInfo(i, "connected") then
_GModText_Hide(i, (RoleplayData.IndexGUI - 10), 1, 0)
_GModRect_Hide(i, (RoleplayData.IndexGUI - 10), 1, 0)
end
end
_PrintMessageAll(4, "An admin has cancelled the vote!")
else
_PrintMessageAll(3, "There is no vote active.")
end
return true
end
end
function RoleplayData.MakeMayor(userid, strText)
local Name = _PlayerInfo(userid, "name")
NoNameTxt1 = string.gsub(Name, "([%[%]%(%)%%%+%-%*%?%^%$%.])", "%%%1")
NoNameTxt = string.gsub(strText, NoNameTxt1..":", "")
Text = _Explode(NoNameTxt, " ", 0)
if string.lower(Text[2]) == string.lower("/makemayor") then
if not RoleplayData.isAdmin(userid) then _PrintMessage(userid, 3, "Access Denied.") _PrintMessage(userid, 1, "Access Denied.") return true end
for i = 1, _MaxPlayers() do
if not _PlayerInfo(i, "connected") then return end
local Names = _PlayerInfo(i, "name")
if string.find(string.lower(Names), string.lower(Text[3])) then
if RoleplayData[i].Team == TEAM_GREEN then
RoleplayData[i].Team = TEAM_YELLOW
_PlayerRespawn(i)
RoleplayData[i].Model = "Mayor (gman)"
RoleplayData[i].ModelName = "models/player/gman_high.mdl"
if RoleplayData[i].Job == "Unemployed" then
RoleplayData[i].Job = "Mayor"
end
RoleplayData[i].Position = _EntGetPos(i) -- Get position
RoleplayData[i].Angle = _PlayerGetShootAng(i) -- Get the angle
RoleplayData.ShowGUI(i)
local Health = _PlayerInfo(i, "health")
_PlayerRespawn(i) -- Respawn the player
_PlayerSetHealth(i, Health)
AddTimer(0.05, 1, _EntSetPos, i, RoleplayData[i].Position) -- Move them back
AddTimer(0.05, 1, _EntSetAng, i, RoleplayData[i].Angle) -- Set angle back
_PrintMessageAll(4, Names .. " has been made a Mayor by admin!")
return true
else
_PrintMessage(userid, 3, Names .. " is already a Mayor!")
return true
end
end
end
return true
end
end
function RoleplayData.ResetStats()
RoleplayData.VotesYes = 0
RoleplayData.TotalVotes = 0
RoleplayData.Voter = 0
RoleplayData.VoteActive = false
end
-
AW: /votemayor frage
Irgendwelche Fehler oder was genau geht nich Oo? nen edit hinzustelen is eine sache dann aber auch genau sagen was denn genua nich stimmt dran aber einfach sagen da geht nich macht das es geht is nich so der sinn ich kann weiterhelfen wenn ich weiß wonach ich suchen soll weil ich hab da son paar verdachte nur dazu muss ich wissen ob beim ausfürhen nen fehler kommt oder was weiß ich
-
AW: /votemayor frage
du hast recht also: wenn ich in game ucrpm starte (oder wie es heißt) und /votemayor sage passiert nichts.Muss ich da noch woanders was editen?
-
AW: /votemayor frage
kann mir vielleicht jetzt wer helfen
sorry für das ubbumpen
-
AW: /votemayor frage
Hast du /votemayor auch in die Event hooks reingestellt?
z.b.
Code:
...
function eventPlayerSayPurt(userid, strText, bTeam)
local Block = RoleplayData.VoteMayor(userid, strText)
if Block then
return false
end
...
EDIT: Ups, si ja schon ne weile her ^^