Help with Pickups (GiftBox System)
#1

Ok so the problem is is that when a player in my GM lands on ANY pickup they get one of the random gift pickups. How do I make it where they ONLY get the random gift at the gift object pickup (that can be placed via /addgift)? It's very annoying when a player walks onto an information point and gets a gift.

Please & Thanks: jakejohnsonusa

Here is the GiftBox FS:
pawn Code:
/*

                                        -------------------------------------------------------
                                        -------------------------------------------------------
                                                    Gift System Update! Version 1.0

                                                            Credits to

                                                     MouseBreaker, SA-MP Team
                                                      RoamPT For Zone System
                                        -------------------------------------------------------
                                        -------------------------------------------------------

*/


// Include
#include <a_samp>

// Server Colours
#define COLOR_WHITE 0xD4D4D4C8
#define COLOR_GREEN 0x00E800FF
#define COLOR_RED 0xEC0000FF

// Definitions
#define MAX_GIFTS (500)

// Forward
forward GetPlayerGiftFounds(playerid);
forward GetPlayerGiftReceiveds(playerid);

// Server Variable
new giftCounter;
new Gift[MAX_GIFTS];
new Picked[MAX_PLAYERS];
new RandomModel[5][1] = {
    {19054},
    {19055},
    {19056},
    {19057},
    {19058}
};

enum PlayerInfo
{
    aGift,
    gFound
};

new pInfo[MAX_PLAYERS][PlayerInfo];

#define MAX_ZONE_NAME 28

forward Zones_Update();

enum SAZONE_MAIN {
        SAZONE_NAME[28],
        Float:SAZONE_AREA[6]
};

static const gSAZones[][SAZONE_MAIN] = {
    //  NAME                            AREA (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) Removed for post, not needed.

public OnFilterScriptInit()
{
    print("\n--------------------------------------------------");
    print(" Holiday Update! Creator, MouseBreaker (v1.0)");
    print("--------------------------------------------------\n");

    giftCounter = 0;
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------------------");
    print(" Holiday Update! Creator, MouseBreaker (v1.0)");
    print("--------------------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    Picked[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/agift", cmdtext, true, 10) == 0 || strcmp("/admingift", cmdtext, true, 10) == 0)
    {
        new string[128];
        if(IsPlayerAdmin(playerid))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    switch(random(5))
                    {
                        case 0: {
                            new rand = (100 + random(2400));
                            GivePlayerMoney(i, rand);
                            format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                            GameTextForPlayer(i, string, 4000, 3);
                        }
                        case 1: {
                            SetPlayerHealth(i, 100);
                            format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~A Candy Cane");
                            GameTextForPlayer(i, string, 4000, 3);
                        }
                        case 2: {
                            SetPlayerArmour(i, 100);
                            format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~Full Body Armour");
                            GameTextForPlayer(i, string, 4000, 3);
                        }
                        case 3: {
                            new rand = (100 + random(2400));
                            GivePlayerMoney(i, rand);
                            format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                            GameTextForPlayer(i, string, 4000, 3);
                        }
                        case 4: {
                            new rand = (100 + random(2400));
                            GivePlayerMoney(i, rand);
                            format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                            GameTextForPlayer(i, string, 4000, 3);
                        }
                    }
                    pInfo[i][aGift]++;
                }
            }
            format(string, sizeof(string), "Happy Holidays! You Have Received A Gift From The J:RP Admins.");
            SendClientMessageToAll(COLOR_WHITE, string);
        }
        else
        {
            return 0;
        }
        return 1;
    }
    if (strcmp("/addgift", cmdtext, true, 10) == 0 || strcmp("/creategift", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            new rand = random(sizeof(RandomModel));
            Gift[giftCounter] = CreatePickup(RandomModel[rand][0], 1, x + 3, y + 1, z, GetPlayerVirtualWorld(playerid));
            giftCounter++;
            new string[128 + MAX_ZONE_NAME], zone[MAX_ZONE_NAME];
            GetPlayer2DZone(playerid, zone, sizeof(zone));
            format(string, sizeof(string), "Santa Claus  Has Put A Gift At %s! Go And Open It Fast!", zone);
            SendClientMessageToAll(COLOR_RED, string);
        }
        else
        {
            return 0;
        }
        return 1;
    }
    return 0;
}

public OnPlayerDisconnect(playerid)
{
    Picked[playerid] = 0;
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    new string[128];
    for(new x = 0; x < MAX_GIFTS; x++)
    {
        if(pickupid == Gift[x] && Picked[playerid] == 0)
        {
            switch(random(x))
            {
                case 0:
                {
                    new rand = (100 + random(2400));
                    GivePlayerMoney(playerid, rand);
                    format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                    GameTextForPlayer(playerid, string, 4000, 3);
                    format(string, sizeof(string), "Happy Holidays! You Have Received $%d!", rand);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                }
                case 1:
                {
                    SetPlayerHealth(playerid, 100);
                    format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~A Candy Cane");
                    GameTextForPlayer(playerid, string, 4000, 3);
                    SendClientMessage(playerid, COLOR_GREEN, "You Have Received A Candy Cane! Your Health Has Been Refilled!");
                }
                case 2:
                {
                    SetPlayerArmour(playerid, 100);
                    format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~Full Body Armour");
                    GameTextForPlayer(playerid, string, 4000, 3);
                    SendClientMessage(playerid, COLOR_GREEN, "You Have Received Body Armour! Your Armour Has Been Refilled!");
                }
                case 3:
                {
                    new rand = (100 + random(2400));
                    GivePlayerMoney(playerid, rand);
                    format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                    GameTextForPlayer(playerid, string, 4000, 3);
                    format(string, sizeof(string), "Happy Holidays! You Have Received $%d!", rand);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                }
                case 4:
                {
                    new rand = (100 + random(2400));
                    GivePlayerMoney(playerid, rand);
                    format(string, sizeof(string), "~r~Happy Holidays!~n~~w~Received ~g~$%d", rand);
                    GameTextForPlayer(playerid, string, 4000, 3);
                    format(string, sizeof(string), "Happy Holidays! You Have Received $%d!", rand);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                }
            }
            new zone[MAX_ZONE_NAME], pname[MAX_PLAYER_NAME];
            GetPlayer2DZone(playerid, zone, sizeof(zone));
            GetPlayerName(playerid, pname, sizeof(pname));
            format(string, sizeof(string), "%s Has Opend Their Gift At %s!", pname, zone);
            SendClientMessageToAll(COLOR_RED, string);
            DestroyPickup(Gift[x]);
            pInfo[playerid][gFound]++;
            Picked[playerid] = 1;
        }
    }
    Picked[playerid] = 0;
    return 1;
}

public GetPlayerGiftFounds(playerid)
{
    return pInfo[playerid][gFound];
}

public GetPlayerGiftReceiveds(playerid)
{
    return pInfo[playerid][aGift];
}

stock IsPlayerInZone(playerid, zone[])
{
    new TmpZone[MAX_ZONE_NAME];
    GetPlayer3DZone(playerid, TmpZone, sizeof(TmpZone));
    for(new i = 0; i != sizeof(gSAZones); i++)
    {
        if(strfind(TmpZone, zone, true) != -1)
            return 1;
    }
    return 0;
}

stock GetPlayer2DZone(playerid, zone[], len)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i != sizeof(gSAZones); i++ )
    {
        if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
        {
            return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
        }
    }
    return 0;
}

stock GetPlayer3DZone(playerid, zone[], len)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i != sizeof(gSAZones); i++ )
    {
        if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4] && z >= gSAZones[i][SAZONE_AREA][2] && z <= gSAZones[i][SAZONE_AREA][5])
        {
            return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
        }
    }
    return 0;
}
Reply
#2

Picked[playerid] == 0 <<<<<< thats means if thats not at 0 they can pickup any other pickups :O,
Reply
#3

I think that is what stops allowing players to be able to pickup gifts after they pickup one. Right?
Reply
#4

Bump. Anyone. Please help me fix this so it only applies to GIFT BOX pickups. Pleaaasssse.
Reply
#5

Bump... Please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)