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

TalkAction TFS 1.0 and up Get Metamethods - Easy to update

Jotran

Banned User
Joined
Feb 8, 2015
Messages
349
Reaction score
109
This was written so you could easily see what metamethods that are available for each TFS metatable
It doesn't give the arguments but it is a nice reference tool :)
Example:
list npc
I had a screenshot but it wasn't showing :(
Code:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end
    local meta = {
          ["combat"] = Combat,
          ["condition"] = Condition,
          ["container"] = Container,
          ["creature"] = Creature,
          ["group"] = Group,
          ["guild"] = Guild,
          ["house"] = House,
          ["item"] = Item,
          ["item type"] = ItemType,
          ["modal window"] = ModalWindow,
          ["monster"] = Monster,
          ["monster type"] = MonsterType,
          ["network message"] = NetworkMessage,
          ["npc"] = Npc,
          ["party"] = Party,
          ["player"] = Player,
          ["position"] = Position,
          ["teleport"] = Teleport,
          ["tile"] = Tile,
          ["town"] = Town,
          ["variant"] = Variant,
          ["vocation"] = Vocation
        }
    if type(meta[param:lower()]) ~= "table" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param.." is not a TFS metatable.")
        return false
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "------------"..param.." start -----------")
    for name, type_ in pairs(meta[param:lower()]) do
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, type(type_).." "..name)
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "------------"..param.." end -------------")
    return false
end

Code:
<talkaction words="list" separator=" " script="getMetamethods.lua"/>
 
Last edited:
Wow! Now that is fucking nice, and can be used even as they keep updating and changing the source. Nicely done!
 
for TFS 1.1:
Code:
local meta = {
	["combat"] = Combat,
	["condition"] = Condition,
	["container"] = Container,
	["creature"] = Creature,
	["group"] = Group,
	["guild"] = Guild,
	["house"] = House,
	["item"] = Item,
	["item type"] = ItemType,
	["modal window"] = ModalWindow,
	["monster"] = Monster,
	["monster type"] = MonsterType,
	["network message"] = NetworkMessage,
	["npc"] = Npc,
	["party"] = Party,
	["player"] = Player,
	["position"] = Position,
	["teleport"] = Teleport,
	["tile"] = Tile,
	["town"] = Town,
	["variant"] = Variant,
	["vocation"] = Vocation
}
	
function onSay(player, words, param, channel)
	if(param == '') then
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return false
	end
	
	if type(meta[param:lower()]) ~= "table" then
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, param.." is not a TFS metatable.")
		return false
	end
	
	player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "------------" .. param .. " start -----------")
	for name, type_ in pairs(meta[param:lower()]) do
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, type(type_) .. " " .. name)
	end
	
	player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "------------" .. param .. " end -------------")
	return false
end
 
This was written so you could easily see what metamethods that are available for each TFS metatable
It doesn't give the arguments but it is a nice reference tool :)
Example:
list npc
I had a screenshot but it wasn't showing :(
Code:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end
    local meta = {
          ["combat"] = Combat,
          ["condition"] = Condition,
          ["container"] = Container,
          ["creature"] = Creature,
          ["group"] = Group,
          ["guild"] = Guild,
          ["house"] = House,
          ["item"] = Item,
          ["item type"] = ItemType,
          ["modal window"] = ModalWindow,
          ["monster"] = Monster,
          ["monster type"] = MonsterType,
          ["network message"] = NetworkMessage,
          ["npc"] = Npc,
          ["party"] = Party,
          ["player"] = Player,
          ["position"] = Position,
          ["teleport"] = Teleport,
          ["tile"] = Tile,
          ["town"] = Town,
          ["variant"] = Variant,
          ["vocation"] = Vocation
        }
    if type(meta[param:lower()]) ~= "table" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param.." is not a TFS metatable.")
        return false
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "------------"..param.." start -----------")
    for name, type_ in pairs(meta[param:lower()]) do
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, type(type_).." "..name)
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "------------"..param.." end -------------")
    return false
end

Code:
<talkaction words="list" separator=" " script="getMetamethods.lua"/>

for TFS 1.1:
Code:
local meta = {
    ["combat"] = Combat,
    ["condition"] = Condition,
    ["container"] = Container,
    ["creature"] = Creature,
    ["group"] = Group,
    ["guild"] = Guild,
    ["house"] = House,
    ["item"] = Item,
    ["item type"] = ItemType,
    ["modal window"] = ModalWindow,
    ["monster"] = Monster,
    ["monster type"] = MonsterType,
    ["network message"] = NetworkMessage,
    ["npc"] = Npc,
    ["party"] = Party,
    ["player"] = Player,
    ["position"] = Position,
    ["teleport"] = Teleport,
    ["tile"] = Tile,
    ["town"] = Town,
    ["variant"] = Variant,
    ["vocation"] = Vocation
}
   
function onSay(player, words, param, channel)
    if(param == '') then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return false
    end
   
    if type(meta[param:lower()]) ~= "table" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, param.." is not a TFS metatable.")
        return false
    end
   
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "------------" .. param .. " start -----------")
    for name, type_ in pairs(meta[param:lower()]) do
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, type(type_) .. " " .. name)
    end
   
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "------------" .. param .. " end -------------")
    return false
end
Woah you guys rock :D helps alot
 
Back
Top