Detect if user achieved pickup:
#3

Try this out!
pawn Код:
#define MAX_HORSE_SHOES 10

new pHorseShoeID            [MAX_PLAYERS][MAX_HORSE_SHOES],
    bool:pHorseShoeTaken    [MAX_PLAYERS][MAX_HORSE_SHOES];

new const Float:HorseShoeCoords[MAX_HORSE_SHOES][3] =
{
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z},
    {x, y, z}
}; // Replace x, y, z with coordinates

stock GetPlayerHorseshoes(playerid)
{
    new shoes;
    for(new i; i < MAX_HORSE_SHOES; i ++)
    {
        if(pHorseShoeTaken[playerid][i])
            shoes ++;
    }
    return shoes;
}

public OnPlayerConnect(playerid)
{
    for(new i; i < MAX_HORSE_SHOES; i ++)
    {
        new Float:x, Float:y, Float:z;
        x = HorseShoeCoords[i][0];
        y = HorseShoeCoords[i][1];
        z = HorseShoeCoords[i][2];
        pHorseShoeID[playerid][i] = CreateDynamicPickup(954, 1, x, y, z, -1, -1, playerid);
        pHorseShoeTaken[playerid][i] = false;
    }
}

public OnPlayerDisconnect(playerid, reason)
{
    for(new i; i < MAX_HORSE_SHOES; i ++)
    {
        if(!pHorseShoeTaken[playerid][i])
        {
            DestroyDynamicPickup(pHorseShoeID[playerid][i]);
            pHorseShoeTaken[playerid][i] = false;
        }
    }
}

public OnPlayerPickupDynamicPickup(playerid, pickupid)
{
    for(new i; i < MAX_HORSE_SHOES; i ++)
    {
        if(pickupid == pHorseShoeID[playerid][i])
        {
            DestroyDynamicPickup(pHorseShoeID[playerid][i]);
            pHorseShoeTaken[playerid][i] = true;

            new string[47];
            format(string, sizeof(string), "~g~You have picked up %i out of %i horseshoes!", GetPlayerHorseshoes(playerid), MAX_HORSE_SHOES);
            GameTextForPlayer(playerid, string, 2000, 6);
            PlayerPlaySound(playerid, 1150, 0.0, 0.0, 0.0);
        }
    }
}
Reply


Messages In This Thread
Detect if user achieved pickup: - by Twizted - 26.06.2014, 13:30
Re: Detect if user achieved pickup: - by Dignity - 26.06.2014, 13:36
Re: Detect if user achieved pickup: - by RedFusion - 26.06.2014, 13:41
Re: Detect if user achieved pickup: - by Vince - 26.06.2014, 14:05
Re: Detect if user achieved pickup: - by Twizted - 26.06.2014, 15:13

Forum Jump:


Users browsing this thread: 1 Guest(s)