• 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.1+] /attr - set item attributes!

gunz

GunzOT Owner
Premium User
Joined
Dec 30, 2007
Messages
529
Solutions
5
Reaction score
191
Hello,

I found this command very usefull when trying the new scripts for events/quests that needed to dynamically change the aids/uids. I've developed it for my server Gunzodus.net and decided to release it for the community. Hope it helps you. :)

Usage: /attr [type] [value]

Possible types: aid, uid, description, text, attack, defense, extradefense. The value should be number.

aid - Action ID
uid - Unique ID

talkactions/scripts/thingattribute.lua
Code:
function onSay(cid, words, param)

  local player = Player(cid)
  if not player:getGroup():getAccess() then
  return true
  end

  if player:getAccountType() < ACCOUNT_TYPE_GOD then
  return false
  end

  local t = param:split(" ", 1)
  local attr = t[1]
  local value = (t[2])

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

  local tile = position:getTile()
  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:isItem() then
  if attr == "aid" then
  thing:setAttribute(1, tonumber(value))
  elseif attr == "uid" then
  thing:setAttribute(2, tonumber(value))
  elseif attr == "descr" or attr == "description" then
  thing:setAttribute(4, value)
  elseif attr == "text"  then
  thing:setAttribute(8, value)
  elseif attr == "attack" then
  thing:setAttribute(1024, tonumber(value))
  elseif attr == "defense" then
  thing:setAttribute(2048, tonumber(value))
  elseif attr == "extradefense" then
  thing:setAttribute(4096, tonumber(value))
  else
  player:sendCancelMessage("Bad Attribute.")
  return true
  end
  end

  position:sendMagicEffect(CONST_ME_MAGIC_RED)
  return false
end

talkactions.xml
Code:
<talkaction words="/attr" separator=" " script="thingattribute.lua" />
 
Last edited:
I doubt that won't be needed but edited the post. ;]
 
Good. ^^ <3, needed this. But what does Aid and uid?

Does it mean actionid and uniqueid?
 
Thanks, gunzodus. Many people from OTland will be happy. Many people has been searching for this.
 
@gunz thanks this will help me allot im only missing the change health+ maxhealth can u put that in as well? also when i use (/attr text spawns that way ) only word spawns comes in it everything after a space wont show its the same with the description.

also the uid wont work dont know if im the only one but if i do /attr uid 9148 which is a reward chest that gives an item it doesnt do anything :/ the /attr aid and everything else does work tough :p
 
Last edited:
@gunz thanks this will help me allot im only missing the change health+ maxhealth can u put that in as well? also when i use (/attr text spawns that way ) only word spawns comes in it everything after a space wont show its the same with the description.

also the uid wont work dont know if im the only one but if i do /attr uid 9148 which is a reward chest that gives an item it doesnt do anything :/ the /attr aid and everything else does work tough :p
what tfs are u using ?
 
B6BQAGo.jpg


TFS 1.1 from http://nightlies.otland.net/
 
Compile there's a new version since May 1

No changes has been made with these functions in a long time :p
I have sent a script to @yogiikke to test out, works fine for me but only checked a few of the functions.
When he replies ill add some more functions and release it.
 
@Tarek1337 true i didnt updated yet now i have the latest from nightlies and now i have an error in my TFS. but only with the uid the text and description also still remain bugd when i type /attr text hello im someone the sign only says hello
but when i do /attr text hello,im someone it strangely says hello,im same with description. i tryd the command diffrent ways with " without " anyway i could think of


tgGuhlW.jpg




gvBeRWB.jpg
 
/attr text hello im someone the sign only says hello
Change
Code:
local t = param:split(" ", 1)
in to
Code:
local t = param:split(";", 1)
and use like /attr descr;hello im someone

@topic
I had to change
Code:
local tile = position:getTile()
to
Code:
 local tile = Tile(position)
 
@gunz
Code:
elseif attr == "attack" then

  thing:setAttribute(1024, tonumber(value))

where did u find that number? 1024 and what is the number for armor?

oh nevermind i fixd it i added this

Code:
  elseif attr == "armor" then
  thing:setAttribute(ITEM_ATTRIBUTE_ARMOR, tonumber(value))

and it workd for me :D thanks for this script :p
 
Last edited:
Back
Top