Im trying to Take the OOC Spam Out of DarkRP by adding a OOC timer . But my Code dosent seem to work and Ive Tried quite alot.
I get the error: [gamemodes\darkrp\gamemode\main.lua:1638] '<' Expected near 'CanOOC'
Here is my Code:
[CODE]local function OOC(ply, args)
for _, ply in pairs( player.GetAll() ) do
local CanOOC = 1
if CanOOC == 0 then
Notify(ply, 1, 4, string.format("You Must Wait 20 Seconds Between Messages In OOC!"))
return ""
end
local function SetOOC
CanOOC == 1 -- Line 1638
end
local DoSay = function(text)
if text == "" then return "" end
local col = team.GetColor(ply:Team())
local col2 = Color(255,255,255,255)
CanOOC = 0
timer.Create("ooctimer", 20, 1, SetOOC")
if not ply:Alive() then
col2 = Color(255,200,200,255)
col = col2
end
for k,v in pairs(player.GetAll()) do
TalkToPerson(v, col, "(OOC) "..ply:Name(), col2, text, ply)
end
end
return args, DoSay
end
AddChatCommand("//", OOC, true)
AddChatCommand("/a", OOC, true)
AddChatCommand("/ooc", OOC, true)[/CODE]
== is the compare operator
= is the assignment operator
Why is there a quote after the SetOOC in the timer?
[lua]local function OOC(ply, args)
if GetConVarNumber("ooc") == 0 then
Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "OOC", ""))
return ""
end
if ply.OOCDelay && ply.OOCDelay >= CurTime() then
Notify(ply,1,4, "You must wait another " .. math.floor(ply.OOCDelay - CurTime()) .. " seconds in order to do that.")
return ""
end
local DoSay = function(text)
if text == "" then return "" end
local col = team.GetColor(ply:Team())
local col2 = Color(255,255,255,255)
if not ply:Alive() then
col2 = Color(255,200,200,255)
col = col2
end
for k,v in pairs(player.GetAll()) do
TalkToPerson(v, col, "(OOC) "..ply:Name(), col2, text, ply)
end
ply.OOCDelay = CurTime() + 20
end
return args, DoSay
end
AddChatCommand("//", OOC, true)
AddChatCommand("/a", OOC, true)
AddChatCommand("/ooc", OOC, true)[/lua]
This should work for you, probably a better way to do it, but the way you have it, it won't work.
Thanks , Facepunch is a Great Commuity :)
[QUOTE=Matt W;33342677]Thanks , Facepunch is a Great Commuity :)[/QUOTE]
You will change your mind soon enough :v:
Sorry, you need to Log In to post a reply to this thread.