• 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

Active Member
Joined
Oct 14, 2020
Messages
109
Solutions
1
Reaction score
34
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...

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,703
Solutions
33
Reaction score
938
Location
Germany
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:
OP
SorketROrk

SorketROrk

Active Member
Joined
Oct 14, 2020
Messages
109
Solutions
1
Reaction score
34
Location
Sweden
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?
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,703
Solutions
33
Reaction score
938
Location
Germany
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
Top