Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Trying to store pickup ids to delete them later in a dynamic pickup creator

$
0
0
Hello I'm trying to store my pickup ids to be able to delete them using the id with a /deletepickup (id) command or a /deleteallpickups

My problem is that the commands always delete the last pickup created. I've tried many other alternative but the result was the same, could someone help me on that, please? I'd appreciate it

Here is the code I used

Code:

enum pickuppos
{
        id,
        model,
    Float:X,
        Float:Y,
        Float:Z,
        type,
        amount
};

Code:

enum pData
{
        pickupid,
        totalpickups
};

Code:

new oInfo[MAX_PLAYERS][MAX_CREATED_OBJECTS][pickuppos];
new pInfo[MAX_PLAYERS][pData];


When creating the pickup, I use this code

Code:

for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
                            {
                                    GetPlayerPos(playerid,oInfo[playerid][i][X],oInfo[playerid][i][Y],oInfo[playerid][i][Z]);
                                        oInfo[playerid][i][id] = CreateDynamicPickup(1240, 1, oInfo[playerid][i][X], oInfo[playerid][i][Y], oInfo[playerid][i][Z],-1, -1, -1, -1);
                    pInfo[playerid][totalpickups] ++;
                                }

Here are the 2 commands to delete them

Code:

CMD:delpickups(playerid,params[])
{
    new pickup;
        DeleteAllPickups(playerid);
        pInfo[playerid][totalpickups]--;
        oInfo[playerid][pickup][id] = -1;
        oInfo[playerid][pickup][X]                        = 0.0;
        oInfo[playerid][pickup][Y]                        = 0.0;
        oInfo[playerid][pickup][Z]                        = 0.0;
        return 1;
}
CMD:delpickup(playerid,params[])
{
        new pickup;
        DestroyDynamicPickup(oInfo[playerid][pickup][id]);
        pInfo[playerid][totalpickups]--;
        return 1;
}


And my stock
Code:

stock DeleteAllPickups(playerid)
{
    for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
    {
        DestroyDynamicPickup(oInfo[playerid][i][id]);
            oInfo[playerid][i][id]                = -1;
                  oInfo[playerid][i][type]                  = 0;
                  oInfo[playerid][i][X]                          = 0.0;
                  oInfo[playerid][i][Y]                          = 0.0;
                  oInfo[playerid][i][Z]                          = 0.0;
                  pInfo[playerid][totalpickups]                = 0;
                oInfo[playerid][i][model]                = -1;
    }
        return 1;
}


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>