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

OnUse get mount.

Andréew

Humble mapper.
Joined
Apr 14, 2015
Messages
833
Solutions
2
Reaction score
1,929
Location
Sweden
Hey boys and girls.
I need your help with making a script that should be fairly easy for one who knows what the heck ya doing :eek:
alright lets get to it.

i need a script kind of like this
(not my code, credits to @andypsylon)
Code:
[LIST=1]
[*]

[*]local c = {17, 22, 23, 24, 25}
[*]function onUse(cid, item, fromPosition, itemEx, toPosition)
[*]    if doRemoveItem(item.uid, 1) then
[*]        return doPlayerAddMount(cid, c[math.random(#c)])
[*]    end
[*]end
[*]
[/LIST]

however i want the script to give you mount id "28" with a small chance to get mount id "33" instead.

using TFS 1.2
Thank you :)
 
Solution
Lua:
local chance = 30

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if math.random(100) <= chance and not player:hasMount(33) then
        player:addMount(33)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    elseif not player:hasMount(28) then
        player:addMount(28)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    item:remove(1)
    return true
end
You or Wibbenz scolded me in the past for doing this. lol
I mean yeah, you scripted it like the person wanted it, but you should be coaching them about why this isn't the best way to do the thing as well.

If you use the script as-is, even if the player has obtained both mounts, the item will still...
Lua:
local chance = 30

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if math.random(100) <= chance and not player:hasMount(33) then
        player:addMount(33)
    elseif not player:hasMount(28) then
        player:addMount(28)
    end
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    return true
end
 
@Vulcan_
Thank you for taking your time!
would love some changes tho after some testing!

i want item to disappear after use
and it would be really cool if you could make so that when you get mount 33 it would send a (CONST_ME_MAGIC_RED) instead ;)
 
@Vulcan_
Thank you for taking your time!
would love some changes tho after some testing!

i want item to disappear after use
and it would be really cool if you could make so that when you get mount 33 it would send a (CONST_ME_MAGIC_RED) instead ;)
Lua:
local chance = 30

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if math.random(100) <= chance and not player:hasMount(33) then
        player:addMount(33)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    elseif not player:hasMount(28) then
        player:addMount(28)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    item:remove(1)
    return true
end
 
Lua:
local chance = 30

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if math.random(100) <= chance and not player:hasMount(33) then
        player:addMount(33)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    elseif not player:hasMount(28) then
        player:addMount(28)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    item:remove(1)
    return true
end
You or Wibbenz scolded me in the past for doing this. lol
I mean yeah, you scripted it like the person wanted it, but you should be coaching them about why this isn't the best way to do the thing as well.

If you use the script as-is, even if the player has obtained both mounts, the item will still be consumed.
The player shouldn't lose the item if they have already obtained all possible rewards. :/
Lua:
local chance = 30

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasMount(33) and player:hasMount(28) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You've already obtained all rewards.")
        return player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    local effect = CONST_ME_POFF
    if math.random(100) <= chance and not player:hasMount(33) then
        player:addMount(33)
        effect = CONST_ME_MAGIC_RED
    elseif not player:hasMount(28) then
        player:addMount(28)
        effect = CONST_ME_MAGIC_BLUE
    end
    player:getPosition():sendMagicEffect(effect)
    item:remove(1)
    return true
end
 
Last edited:
Solution
Back
Top