Help With PlayerSay Hook

So here’s what’s up. im trying to make this script that when you say “/pay arg[1] arg[2]” it pays your arg[1] arg[2] dollars.

They had this on wiki.
[lua]
function ISaid( ply, text, toall )
if (string.sub(text, 1, 4) == “/pay”) then–if the first 4 letters are /all continue
return “[Global]”…string.sub( text, 5 );–add [Global] infront of the players text then display
end
return text;–if its just a normal chat message, display normally
end
hook.Add( “PlayerSay”, “ISaid”, ISaid );
[/lua]

and i could change it to
[lua]
function ISaid( ply, text, toall )
Whotopay = arg[1]
Amounttopay = arg[2]
if (string.sub(text, 1, 4) == “/pay”) then–if the first 4 letters are /all continue
//Run function here for examle…
ply:PayPlayer(Whotopay, Amounttopay)
end
end
hook.Add( “PlayerSay”, “ISaid”, ISaid );
[/lua]

But how do i get the values of arg[1] and arg[2]??

i would have to use somthing like
[lua]
local texttable = string.Explode(" ",txt)
[/lua]
to get the next value after “/pay” right?

I search google and i could not find anything so i am now here on facepunch trying to get the answer.

Help is greatly appreciated.

string.Explode gives args[2] and args[3]

Right on the dot.

Yes and if i am correct i could use somthing like this to get the values of them.

[lua]
Topay = texttable[1]
Amounttopay = texttable[2]
[/lua]

I think this is what you want:

[lua]function GiveMoney(ply,text)
if string.sub(text,1,4) == “/pay” then
local words = string.Explode(" ",text)
– This cuts up the sentence into words in a table
ply:PayPlayer(words[2],words[3])
– words[2] is the second word, like “Entoros”, and words[3] would be “50”
return “”
end
end
hook.Add(“PlayerSay”,“PayMoney”,GiveMoney)[/lua]

Thanks i knew i was on the right track. Thanks to everyone that helped me.