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

TalkAction [TFS 1.X] Set item action id

Elwyn

Well-Known Member
Joined
Aug 24, 2014
Messages
212
Reaction score
76
Use it just like /r, put the item in the tile you're facing and say /aid number

Create a file named set_actionid.lua on talkactions/scripts and put the following code:
Code:
function onSay(cid, words, param)
   local player = Player(cid)

   if not player then
     return false
   end

   if not player:getGroup():getAccess() then
     return true
   end

   if not tonumber(param) then
     player:sendCancelMessage("Need a number param.")
     return false
   end

   local position = player:getPosition()
   position:getNextPosition(player:getDirection())

   local tile = Tile(position)
   if not tile then
     player:sendCancelMessage("Object not found.")
     return false
   end

   local thing = tile:getTopVisibleThing(player)
   if not thing then
     player:sendCancelMessage("Thing not found.")
     return false
   end

   if thing:isCreature() then
     player:sendCancelMessage("You can't give an action id to a creature.")
   elseif thing:isItem() then
     local actionid = tonumber(param)
     if actionid <= 0 then
       thing:removeAttribute(ITEM_ATTRIBUTE_ACTIONID)
     else
       thing:setActionId(actionid)
     end
   end

   position:sendMagicEffect(CONST_ME_MAGIC_RED)
   return false
end

On talkactions.xml put:

Code:
  <talkaction words="/aid" separator=" " script="set_actionid.lua" />
 
This is great man thanks! UID would also be helpful ;)
 
Back
Top