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

simple trick - making a table /reload proof

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,690
Location
Poland
Some complex systems get ruined when you do /reload (if you have addEvent, it may refer to an empty table)

You can avoid redefining a table while reloading by using
Code:
if not some_tbl then some_tbl = {} end -- a table exist so it's kept
or
Code:
some_tbl = some_tbl or {} -- shorter version of thing above
in code, instead of
Code:
some_tbl = {} -- information dies when you do /reload

I feel stupid for not knowing this before and I never saw anyone using it.
You can make your tables reload-proof this way.
It doesn't seem to work with "local", though.
 
Have you managed to fix this when reloading creaturescripts?

Example:
PHP:
function onLogin(cid)
      registerCreatureEvent(cid, "lootMessage")
end

After reloading the events are lost and players need to relogin (or iterate for each player online and reregister the events, but that might lag if it has lot of players)
 
maybe
Code:
function onThink(cid, Interval)
      registerCreatureEvent(cid, "lootMessage")
end
 
Back
Top