• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent entAvoid the use of registerCreatureEvent in login.lua

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
This iscript is not too much unsefull but i done it 4 fun
wink.gif


With this script every time you create a new creraturescript you will not need add registerCreatureEvent(cid,'name') in login.lua.

This script register all 4 you ;D

Just add this tag on xml:
Code:
<event type="login" name="registrando" script="register.lua"/>
delete all registerCreatureEvent form you login.lua
and create reginster.lua and put this:
Lua:
local s = ''
do  -- Load XML once
       f = io.open('data/creaturescripts/creaturescripts.xml','r')
       s = f:read('*a') 
       f:close()
end
function onLogin(cid) -- Script by mock
	
	for line in s:gmatch('<event(.-)/>') do
                local type,name,block = line:match('type="(.-)"'),line:match('name="(.-)"'),line:match('block="(.-)"')
                if not isInArray({'login','logout'},type) and (not block or block == '0') then
			registerCreatureEvent(cid,name)
		end
	end
        return true
end

If you use a tag like this:
<event type="kill" name="loot" event="script" value="loot.lua"/>
it will register.
But if you use like this:
<event type="kill" name="loot" block="1" event="script" value="loot.lua"/>
it wont register
done
kewl.gif
 
Last edited:
lol ftw this IS useful
elf should commit it :p
wat about
Lua:
if not isInArray({'login','logout'},type) then
   registerCreatureEvent(cid,name)
end
 
Last edited:
Wow!! Amazing! this help to remove some lines in login.lua, thank mock! you have lua super powers xD
 
i find it better to place it @ same login.lua
Lua:
        local f =  io.open('data/creaturescripts/creaturescripts.xml','r')
        local s = f:read('*a')
        f:close()
        for type,name,sz in s:gmatch('type="(.-)" name="(.-)".-/>') do
                if not isInArray({'login','logout'},type) then
                        registerCreatureEvent(cid,name)
                end
        end
 
kinda bugged, maybe it will register events that should only be used by monsters or certain players :/
 
then he should add smth that checks like "monster" in event name
then we rename them <event .... name="monsterEventname"

or smth similar
 
@Jano
omg its true. i will change something on script ;D haha!


If you use a tag like this:
<event type="kill" name="loot" event="script" value="loot.lua"/>
it will register.
But if you use like this:
<event type="kill" name="loot" block="1" event="script" value="loot.lua"/>
it wont register

Done
 
Last edited:
it'z lua super powah !!! ;D

@Mock, what about something more formal?
<event type="kill" name="loot" autoregister="false" event="script" value="loot.lua"/>
o well ppl change it :D
 
oh and mock dont take this as a attack or offense ...

this function open XML every time you use it it use more and more ram because it load xml n each use.

on a 500 players server there are atleast 40 newlogin/relogin each minute = 40 open xml, read xml per minute :x

and

PHP:
<!-- hiho-->

<!--
hiho
hiho x2
hiho x3
-->

you should know what i meant with last part =P
 
put a "return true" at the end otherwise players wont be able to log on
 
@Jano, can't the xml just be loaded as a local so it can be read instead of the original xml file?
 
hmm, on startup load that xml as some array and then on every login excute modified version of this script, right ^^
 
@Jano
Humm goo you remenber of load XML in each login.
-- Fixed.
Dont worry about comments.
@Fallon
fail xd
-- Fixed
 
commented lines don't get registered rwight?
Lua:
    <!--Add'Ons
    <event type="advance" name="newSpells" event="script" value="addons/spellup.lua"/>
    <event type="statschange" name="ElemShield" event="script" value="addons/elemshield.lua"/>
    <event type="preparedeath" name="Inmortal" script="addons/inmortal.lua"/>  
    <event type="statschange" name="Protect" event="script" value="addons/noobprotection.lua"/>
    <event type="preparedeath" name="aol" event="script" value="addons/aol.lua"/>
    <event type="attack" name="kawarimi" event="script" value="addons/kawarimi.lua"/> 
    <event type="kill" name="TLSkill" script="addons/TLSKill.lua"/>  
    <event type="preparedeath" name="TLSDeath" script="addons/TLSDeath.lua"/>  
    <event type="login" name="Reset" event="script" value="addons/reset.lua"/>
    <event type="think" name="restore" event="script" value="addons/pacman3.lua"/>
    <event type="attack" name="Pacman" event="script" value="addons/pacman2.lua"/>
    -->
 
@Cybershot
in this case got :S
try change <event
to
<eventaa
or
<event_
or something like this :p
 
Back
Top