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

Lua [TFS 1.2] Addon - Use item to recieve addons

SorketROrk

Well-Known Member
Joined
Oct 14, 2020
Messages
152
Solutions
1
Reaction score
69
Location
Sweden
Hello,

I have been looking for a script of type Action that will give addons, but could not find something that fits my requirements,
something like this

Example:

Use Item 2145 > Player gets citizen addon 1+2 and message "Addons added" > Remove item.
If Player already has these addons then message "You already have ...." > Keep item.

Using TFS 1.2


Hopefully someone with knowledge can lend a hand? :)

/SRO
 
Solution
Hey, thank you for your time!

The script seems to be written to do exactly what I need.
It does however not give the message "You already used it" and it keeps removing item on use, even after player already has the addons, any idea how its happening?

any errors?

try this maybe

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)

    if player:hasOutfit(136,3) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy have both addons.')
        return true
    end
    
    if player:getStorageValue(4905) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy used it.')
        return true
    end

    if player:getStorageValue(4905) == -1 then...
Hello,

I have been looking for a script of type Action that will give addons, but could not find something that fits my requirements,
something like this

Example:

Use Item 2145 > Player gets citizen addon 1+2 and message "Addons added" > Remove item.
If Player already has these addons then message "You already have ...." > Keep item.

Using TFS 1.2


Hopefully someone with knowledge can lend a hand? :)

/SRO
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)

    if player:getStorageValue(4905) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy used it.')
        return true
    end

    if player:getStorageValue(4905) == -1 then
        player:setStorageValue(4905, 1)
        player:addOutfitAddon(136, 3)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received all addons of citzien.')
        item:remove(1)
        end
    return true
    end

regirst your itemid in actions xml :D
 
Last edited:
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)

    if player:getStorageValue(4905) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy used it.')
        return true
    end

    if player:getStorageValue(4905) == -1 then
        player:setStorageValue(4905, 1)
        player:addOutfitAddon(136, 3)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received all addons of citzien.')
        item:remove(1)
        end
    return true
    end

regirst your itemid in actions xml :D
Hey, thank you for your time!

The script seems to be written to do exactly what I need.
It does however not give the message "You already used it" and it keeps removing item on use, even after player already has the addons, any idea how its happening?
 
Hey, thank you for your time!

The script seems to be written to do exactly what I need.
It does however not give the message "You already used it" and it keeps removing item on use, even after player already has the addons, any idea how its happening?

any errors?

try this maybe

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)

    if player:hasOutfit(136,3) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy have both addons.')
        return true
    end
    
    if player:getStorageValue(4905) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You alredy used it.')
        return true
    end

    if player:getStorageValue(4905) == -1 then
        player:setStorageValue(4905, 1)
        player:addOutfitAddon(136, 3)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received all addons of citzien.')
        item:remove(1)
        end
    return true
    end
 
Last edited:
Solution
Back
Top