• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Explode [Like in PHP]

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,663
Solutions
125
Reaction score
1,109
Location
Germany
GitHub
slawkens
Im not author of this. I found it on google when I tried make talkaction with xx parameters.

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:
Slawk, if I am right, all it does it shows the God/GM, what happened when he used the talkaction, right?
 
It will show which parameters have he used. Usable in talkactions which have more parameters. And remembers, this is just example, nothing more :p
 
Back
Top