slaw
Software Developer
Im not author of this. I found it on google when I tried make talkaction with xx parameters.
functions.lua or global.lua
Usage.
If you want make talkactions like this:
/broadcast Text,delay,color
explodedString = explode(",", string)
Example talkaction:
functions.lua or global.lua
PHP:
function explode(div,str)
if (div=='') then
return false
end
local pos,arr = 0,{}
-- for each divider found
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
return arr
end
Usage.
If you want make talkactions like this:
/broadcast Text,delay,color
explodedString = explode(",", string)
Example talkaction:
PHP:
function onSay(cid, words, param)
if param ~= "" then
params = explode(",", param)
testString = ""
for _, par in pairs(params) do
testString = testString..' '..par
end
doPlayerSendCancel(cid, "You have used params: ".. testString ..".")
Last edited: