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

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
Hello. I have this script for a tradevip. I want it to work only when the player has a vip amount that will remain more than 2 days. Ex:
The minimum transfer amount is 2 days.
Player has 3 days, he tries to transfer 2 [will be 1] but I do not want to give to transfer so, I want a way that the script only works when there is more than 2 days left in the account. [Eg when the player has 4 days And tries to transfer 2].
And when you try to transfer and you are not satisfied, you can send the message "You can not transfer that amount of VIP."
Can anyone make this modification? Thanks in advance.

One more thing, do not send the trade item, so that it only serves for the trade to work, not that when the trade is accepted the player who is receiving the vip does not receive the item.

Lua:
function onSay(cid, words, param, param2, channel)
 
if(param == '') then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
    return true
end
local itemxx = 5957
local t = string.explode(param, ",")
local creature = getCreatureByName(t[1])
local day = tonumber(t[2])
local storage1 = 223314
local storage2 = 224413
if os.time() > getPlayerStorageValue(cid, storage1) then
     setPlayerStorageValue(cid, storage2, 0)
   if (creature ~= nil) and isPlayer(creature) and not isPlayerGhost(creature) then
      if (day ~= nil) and (type(day) == 'number') and (day>0) then
         if (getPlayerPremiumDays(cid)-1) >= day then
            doStartTrade(cid, creature, doPlayerAddItem(cid, itemxx, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador "..getPlayerName(creature)..", com a intenção de trocar "..day.." dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador "..getPlayerName(cid).." deu trade em você, e está disposto a trocar "..day.." dia(s) de VIP.")
            setPlayerStorageValue(cid, storage1, os.time()+1*60)
            setPlayerStorageValue(cid, storage2, day)
         else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não pode transferir essa quantidade de VIP.")
         end
      else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
      end
   else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
   end
else
    doPlayerSendCancel(cid, "Invalid param specified.")
end
return true
end
 
Last edited by a moderator:
Solution
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        print(days, getPlayerPremiumDays(cid))
        if days and...
Try this;
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        if days and type(days) == 'number' and days > getPlayerPremiumDays(cid) - 2 then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end
 
Try this;
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        if days and type(days) == 'number' and days > getPlayerPremiumDays(cid) - 2 then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end

Did not work. It is giving trade until the player is without VIP.
 
This?
Code:
function onTradeAccept(cid, target, item)

local storage2 = 224413

if getPlayerStorageValue(cid, storage2) > 0 then
   local sto = getPlayerStorageValue(cid, storage2)
      doPlayerRemovePremiumDays(cid, sto)
      doPlayerAddPremiumDays(target, sto)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você trocou "..sto.." dia(s) de premium, Parabéns.")
      doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "Você realizou uma troca e adquiriu "..sto.." dia(s) de premium, Parabéns.")
      setPlayerStorageValue(cid, storage2, 0)
end

return true
end

No that's function onTradeAccept(cid, target, item)
I asked for getPlayerPremiumDays, check your lib files / global.lua file to see if you can find it.
If not check your source code.
 
No that's function onTradeAccept(cid, target, item)
I asked for getPlayerPremiumDays, check your lib files / global.lua file to see if you can find it.
If not check your source code.
In the source code I found this:

Code:
    //getPlayerPremiumDays(cid)
    lua_register(m_luaState, "getPlayerPremiumDays", LuaInterface::luaGetPlayerPremiumDays);
Code:
int32_t LuaInterface::luaGetPlayerPremiumDays(lua_State* L)
{
    return internalGetPlayerInfo(L, PlayerInfoPremiumDays);
}
 
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        print(days, getPlayerPremiumDays(cid))
        if days and type(days) == 'number' and days > getPlayerPremiumDays(cid) - 2 then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end

Try that and take an SS of your console.
 
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        print(days, getPlayerPremiumDays(cid))
        if days and type(days) == 'number' and days > getPlayerPremiumDays(cid) - 2 then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end

Try that and take an SS of your console.

What appeared 3 then 0, 4 then 0 was the player who did not have vip. In other words, it is working without the player having vip

http://i.imgur.com/NCOxqGq.jpg
 
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        print(days, getPlayerPremiumDays(cid))
        if days and type(days) == 'number' and getPlayerPremiumDays(cid) - 2 >= days then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end
 
Solution
Lua:
local config = {
    itemid = 5957,
    storage1 = 223314,,
    storage2 = 224413
}

function onSay(cid, words, param, param2, channel)
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    local creature = getCreatureByName(t[1])
    if not creature and isPlayer(creature) and not isPlayerGhost(creature) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
        return true
    end

    if os.time() > getPlayerStorageValue(cid, config.storage1) then
        local days = tonumber(t[2])
        print(days, getPlayerPremiumDays(cid))
        if days and type(days) == 'number' and getPlayerPremiumDays(cid) - 2 >= days then
            doStartTrade(cid, creature, doPlayerAddItem(cid, config.itemid, 1))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador " .. getPlayerName(creature) .. ", com a intenção de trocar " .. days .. " dia(s) de VIP.")
            doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "O Jogador " .. getPlayerName(cid) .. " deu trade em você, e está disposto a trocar " .. days .. " dia(s) de VIP.")
            setPlayerStorageValue(cid, config.storage1, os.time() + 1 * 60)
            setPlayerStorageValue(cid, config.storage2, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not transfer that amount of VIP.")
        end
    else
        doPlayerSendCancel(cid, "Invalid param specified.")
        return true
    end

    return true
end
It worked. Could you put for the transfer minimum to be 2? It is giving trade with 1 day of vip.
 
Lua:
local days = tonumber(t[2])
Lua:
local days = tonumber(t[2])
    if days < 2 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Minimum premium transfer amount is 2 days.")
        return true
    end
or
Lua:
if days and type(days) == 'number' and getPlayerPremiumDays(cid) - 2 >= days then
Lua:
if days and type(days) == 'number' and days > 1 and getPlayerPremiumDays(cid) - 2 >= days then
 
Lua:
local days = tonumber(t[2])
Lua:
local days = tonumber(t[2])
    if days < 2 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Minimum premium transfer amount is 2 days.")
        return true
    end
or
Lua:
if days and type(days) == 'number' and getPlayerPremiumDays(cid) - 2 >= days then
Lua:
if days and type(days) == 'number' and days > 1 and getPlayerPremiumDays(cid) - 2 >= days then

When using the command does not appear in the default. Could you set it up to appear? For example: When to use! Tradevip xikini, 3 Appear Marcos says: ! Tradevip xikini, 3
 

Similar threads

Back
Top