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

Storage value when use a item?

dropz

Member
Joined
May 4, 2022
Messages
46
Reaction score
24
hiho


im facing a problem about the storage value that getting me stucked in one part of my project...


i created new outfits for my TFS 1.2 - Nostalrius that when you use a "outfit scroll" it must change the storage value from -1 or 0 to 1, if the players try use the talkaction command to change outfit without used the specific item, they receive the "deny" condition from the lua script.

the point is, i got stucked in the "deny" condition, the player consume the item, receive the msg of earned outfit but when i try use the command to get the outfit i got the deny condition of the talkaction script and if i try use again the item to change the storage value not is possible too.

probably i made mistakes in my lua scripts or something like this.. idk

any angel?
thanks in advance :D
 
Probably missed something.
(Okay, just kidding. Show me some code)
hahaha i think you are right xD
but okay, lets go to the codes:

here is the script of the item that must change the storage value to 1:
actions/scripts/outfit_warrior.lua
Lua:
local Scrolls =
{
[5098] = {"You've received a Warrior outfit!"}
}

local s = 60000 -- storage
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, s) >= 1 then
       doPlayerSendCancel(cid, "Sorry, you've already used this item")
    else
        setPlayerStorageValue(cid, s, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, Scrolls[item.itemid][1])
        doRemoveItem(item.uid, 1)
    end
return TRUE
end

and here is the script of the talkaction that will gives the permission for the player to use the command and change the outfit:
talkactions/scripts/outfits/outfit_warrior.lua
Lua:
local config = {
   outfits = {
      ["warrior"] = 137
   },
   storage = 60000
}

function onSay(player, words, param)

   if player:getStorageValue(config.storage) ~= 1 then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "You dont have a permission to use this command.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

    local lookType = tostring(param)
    if lookType == 'warrior' then
        if (player:getSex() == PLAYERSEX_FEMALE) then
         lookType = 149
         local playerOutfit = player:getOutfit()
         playerOutfit.lookType = lookType
         player:setOutfit(playerOutfit)
        else
        lookType = 137
         local playerOutfit = player:getOutfit()
         playerOutfit.lookType = lookType
         player:setOutfit(playerOutfit)
      end
    else
        player:sendCancelMessage("This outfit does not exist.")
    end
    return false
end

and for sure, this both scripts must be added inside the talkactions.xml and actions.xml respectively

obs: my first idea was create just a item that gives for the player the outfit inside the panel of Outfits, but unfortunately i dont know how to deal with that... editing the source code i just could made or all the outfits appears for the premium players or none, probably to do that happens i must create new classes, structs and etcsss but C and my mind dont like each other xD...
 
Last edited:
it shouldnt be some like
Lua:
if player:getStorageValue(config.storage) ~= 60000,1 then
?
im new in that too, so... :D
 
Try (data/scripts/actions/my_script.lua)
Lua:
local outfits = {
    [ITEM_ID_1] = { storage = 10000, female = 149, male = 137 },
    [ITEM_ID_2] = { storage = 10001, female = 150, male = 138 },
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local outfit = config[item.itemid]
    if not outfit then
        return true
    end

    if player:getStorageValue(outfit.storage) == 1 then
        -- some message?
        return false
    end
  
    local outfitType = player:getSex() == PLAYERSEX_FEMALE and outfit.female or outfit.male
    player:addOutfit(outfitType)
    player:setStorageValue(outfit.storage, 1)
    -- some message?

    item:remove()
    return true
end

for k, v in pairs(outfits) do
    action:id(k)
end
action:register()
 
Last edited:
Try (data/scripts/actions/my_script.lua)
Lua:
local outfits = {
    [ITEM_ID_1] = { storage: 10000, female: 149, male: 137 },
    [ITEM_ID_2] = { storage: 10001, female: 150, male: 138 },
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local outfit = config[item.itemid]
    if not outfit then
        return true
    end

    if player:getStorageValue(outfit.storage) == 1 then
        -- some message?
        return false
    end
   
    local outfitType = player:getSex() == PLAYERSEX_FEMALE and outfit.female or outfit.male
    player:addOutfit(outfitType)
    player:setStorageValue(outfit.storage, 1)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    -- some message?

    item:remove()
    return true
end

for k, v in pairs(outfits) do
    action:id(k)
end
action:register()
i dont think its TFS 1.2 (nostalrius one) compatibile...
 
Try (data/scripts/actions/my_script.lua)
Lua:
local outfits = {
    [ITEM_ID_1] = { storage = 10000, female = 149, male = 137 },
    [ITEM_ID_2] = { storage = 10001, female = 150, male = 138 },
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local outfit = config[item.itemid]
    if not outfit then
        return true
    end

    if player:getStorageValue(outfit.storage) == 1 then
        -- some message?
        return false
    end
 
    local outfitType = player:getSex() == PLAYERSEX_FEMALE and outfit.female or outfit.male
    player:addOutfit(outfitType)
    player:setStorageValue(outfit.storage, 1)
    -- some message?

    item:remove()
    return true
end

for k, v in pairs(outfits) do
    action:id(k)
end
action:register()
well, i think @PuszekLDZ is right, i tried run this script and it returning just "Warning - Event::checkScript] Can not load script: scripts/outfit_warrior.lua", i did some changes to try load it but without results.. idk if its about the Action() function but i liked the idea letting all the ids insine just one script with that structure, maybe something close this can works, idk... buuut thanks ^^
Post automatically merged:

it shouldnt be some like
Lua:
if player:getStorageValue(config.storage) ~= 60000,1 then
?
im new in that too, so... :D
dont works too, maybe its cuz it declaring two values for one variable?
1669248595548.png
it dont recognize the "then"
 
Last edited:
well, i think @PuszekLDZ is right, i tried run this script and it returning just "Warning - Event::checkScript] Can not load script: scripts/outfit_warrior.lua", i did some changes to try load it but without results.. idk if its about the Action() function but i liked the idea letting all the ids insine just one script with that structure, maybe something close this can works, idk... buuut thanks ^^
Post automatically merged:


dont works too, maybe its cuz it declaring two values for one variable?
View attachment 71907
it dont recognize the "then"
Why did You do two if/then?
I mean to add storagevalue with value, as
"StorageValue, Value"
Try to check how it works with djinns, so You can take my point 😘
 
Why did You do two if/then?
I mean to add storagevalue with value, as
"StorageValue, Value"
Try to check how it works with djinns, so You can take my point 😘
noop i just let them there to show you, the tests that i made i used just one of the "ifs"..
still not working :/
 
Back
Top