Gothic Online Forums
Tradescript - Printable Version

+- Gothic Online Forums (https://archive.gothic-online.com)
+-- Forum: Scripting (English) (https://archive.gothic-online.com/forum-11.html)
+--- Forum: Scripting Help (https://archive.gothic-online.com/forum-12.html)
+--- Thread: Tradescript (/thread-2790.html)



Tradescript - Surotex - 01.09.2020

Hey, guys,

I have been working on an RP project for a long time, but now I have reached a point of desperation and need help.

The point where I need help is this. I need a working trade script which is essential for me, but I just can't get it to work. :/

This is where you come in, at least I would be very grateful if someone could help me with it, maybe even share a working trade script with me. A mention in the credits would be a matter of course.

It would be desirable to trade directly the FocusID without entering an extra ID.

Thanks in advance! Smile


RE: Tradescript - Lokivir - 01.09.2020

Hey,

hope this helps ;)

Code:
local focusid = null;
if (getPlayerFocus(playerid) == -1)
{
    sendMessageToPlayer(playerid, 255, 0, 0, "You need to have someone in your focus!");
    return;
}
else
{
    focusid = getPlayerFocus(playerid);
    local playername = getPlayerName(playerid);
    local focusname = getPlayerName(focusid);
    local args = sscanf("sd", params);
    local item_id = getItemId(args[0]);
    local pos = getPlayerPosition(playerid);
    local pos2 = getPlayerPosition(focusid);
    if (getDistance3d(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) <= 400)
    {
        if (args)    //trading
        {
                if (amount >= args[1])
                {
                    removeItem(playerid, item_id, args[1]);
                    giveItem(focusid, item_id, args[1]);
                    sendMessageToPlayer(focusid, 0, 255, 0, "You have been given " +args[1]+ "x " +args[0]+ " from " +playername);
                    sendMessageToPlayer(playerid, 0, 255, 0, "You have given " +args[1]+ "x " +args[0]+ " to " +getPlayerName(focusid));
                    print(playername + " has given " + focusname + " " + args[1] + " " + args[0]);
                }
                else
                    sendMessageToPlayer(playerid, 255, 0, 0, "You don't have enough of that.");
        }
        else
            sendMessageToPlayer(playerid, 255, 0, 0, "/trade <Item_Instance> <Amount>");
    }
    else
        sendMessageToPlayer(playerid, 255, 0, 0, "The player is too far away!");
}

This is an old script of mine. It worked fine the last time i used it.
If you got some problems or have some questions, just ask away :D