Diath
DIATH
Hello, many of you are creating scripts and sometimes you post 2 versions of script for 2 versions of The Forgotten Server or sometimes people are requesting scripts for previous The Forgotten Server versions.
I'll show you how to make backward compatibility in one script.
If you call function without brackets and arguments, it'll return variable type (in this case function) and function ID or nil if function doesn't exist.
Here are few examples:
I'll show you how to make backward compatibility in one script.
If you call function without brackets and arguments, it'll return variable type (in this case function) and function ID or nil if function doesn't exist.
Here are few examples:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local func = db.query
if func then
db.query('UPDATE `players` SET `comment` = \': )\';')
else
db.executeQuery('UPDATE `players` SET `comment = \': )\';')
end
return true
end
Code:
function onKill(cid, target, damage, flags)
if isPlayer(target) then
local item = doPlayerAddItem(cid, 5805, 1)
local func = doItemSetAttribute
if func then
doItemSetAttribute(item.uid, 'description', 'It\'s reward for killing '.. getCreatureName(target) ..'.')
else
doSetItemSpecialDescription(item.uid, 'It\'s reward for killing '.. getCreatureName(target) ..'.')
end
end
return true
end
Last edited: