• 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!

Mods 'event'

olavo

New Member
Joined
May 29, 2007
Messages
74
Reaction score
0
Can someone explain me when i use and which is the difference of each type of 'event' in mods like:
event="buffer", event="script" or event="function". Do the last one exists?
 
well i know little about "buffer" but here is my rundown of it.

If you use "script" you include function with it and use return true/false
If you use "buffer" you dont need to include function and use _result = false/true

You probably didn't get it cause I barely did. So heres examples:

Code:
	[COLOR="Blue"]<action[/COLOR] [COLOR="Red"]itemid[/COLOR]=[COLOR="DarkOrchid"]"1981"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"buffer"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		if(item.actionid >= 150 and item.actionid <= 158) then
			doShowTextDialog(cid, item.itemid, getHighscoreString((item.actionid - 150)))
		else
			_result = false
		end
]]>[/COLOR][COLOR="Blue"]</action>[/COLOR]

You noticed how it didn't need to call the function OnUse? and it did not use return false, it used _result

Now a script: (Which I prefer, which is basically copy and paste from Lua to mod.)

Code:
	[COLOR="Blue"]<event [/COLOR][COLOR="Red"]type[/COLOR]=[COLOR="DarkOrchid"]"login"[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"FirstItems"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		domodlib('firstitems_config')

		function onLogin(cid)
			if(getPlayerStorageValue(cid, config.storage) > 0) then
				return true
			end

			for _, id in ipairs(config.items) do
				doPlayerAddItem(cid, id, 1)
			end

			if(getPlayerSex(cid) == PLAYERSEX_FEMALE) then
				doPlayerAddItem(cid, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
]]>[/COLOR][COLOR="Blue"]</event>[/COLOR]

You can see that it used the function line, and returns. Much easier to convert, and buffers sometimes don't work, mainly because I don't know much about them.
 
Back
Top