[code]
local w = {}
w[1] = "s_m4a1"
w[2] = "s_ak47"
w[3] = "s_revolver"
hook.Add("PlayerSay", "heygurllemmegetchonumber", function(text, sender)
if string.sub(text, 1, 3) == "!rw" then
sender:Give(math.random(1, #w))
end
end)
[/code]
w is a table.
Bad arguement #1 to 'sub' (string expected, got userdata)
GM:PlayerSay( Player sender, string text, boolean teamChat )
figure it out from there on
[QUOTE=zerothefallen;45605104]GM:PlayerSay( Player sender, string text, boolean teamChat )
figure it out from there on[/QUOTE]
no errors this time,
[code]
hook.Add("PlayerSay", "heygurllemmegetchonumber", function(sender, text)
if ( string.sub(text, 1, 3) == "!rw" ) then
sender:Give(math.random(1, #w))
end
end)
[/code]
So its working now or what?
[QUOTE=Lolm4te;45605299]So its working now or what?[/QUOTE]
yes, but a new problem rises
[code]
concommand.Add("wa", function(ply,cmd,args,str)
if !ply:IsUserGroup("owner") then return end else
table.insert( w, args )
end
end)
[/code]
no errors, nothing added to the table
What's the problem :suicide:
yeah, nothings working.
Read what zero said, I missed that part.
[QUOTE=74pantera;45605322]yes, but a new problem rises
[code]
concommand.Add("wa", function(ply,cmd,args,str)
if !ply:IsUserGroup("owner") then return end else
table.insert( w, args )
end
end)
[/code]
no errors, nothing added to the table[/QUOTE]
your formatting is fucked. you end the if statement on the first line, then stuff another end randomly (?)
re-write this
Edited:
[lua]
concommand.Add("wa", function(ply,cmd,args,str)
if !ply:IsUserGroup("owner") then return end else
table.insert( w, args )
end
end)
[/lua]
You have an else after you already ended that function which is wrong. Remove that.
Then you have an end which would end the else, but as the else is not suppose to be there, remove that one too.
Giving everyone code won't help them to learn if they don't make mistakes and fix it themselves..
I simply removed two words to spare us some time. But oh well, updated the post but I already got Ninja'd so whatever.
Sorry, you need to Log In to post a reply to this thread.