Object won't delete
#1

When I use a command /spikestripdestroy and there's 3-4 spike strips near each other, only the first two are deleted, and the others can't be deleted


pawn Код:
stock DeleteClosestStrip(playerid)
{
    new Float:x,Float:y,Float:z;
    for(new i = 0; i < MAX_STRIPS; i++)
    {
        GetObjectPos(spikestrip[i][0], x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 2.0, x, y, z))
        {
            if(spikestrip[i][0] != 0)
            {
                DestroyObject(spikestrip[i][0]);
                DestroyPickup(spikestrip[i][1]);
                spikestrip[i][0] = 0; spikestrip[i][1] = 0;
                GameTextForPlayer(playerid, "Spikestrip ~r~destroyed", 3000, 5);
                return 1;
            }
        }
    }
    return 0;
}
Reply
#2

you are deleting just 2 objects:

pawn Код:
DestroyObject(spikestrip[i][0]);
DestroyPickup(spikestrip[i][1]);

//also please use this to empty a variable:
spikestrip[i][1]=-1;
u must also add the other objects u want to be destroyed in order to get this to work.
Reply
#3

Thanks, fixed it. But now there's another problem. variable in enum got mixed up with my note variable.

When I print(pInfo[playerid][pAdminLevel]);, it shows me a content of Note1 variable.

This is how I load them:

pawn Код:
public LoadPlayer(playerid)
{
    new usfile[128];
    format(usfile, sizeof(usfile), "Accounts/%s.ini", pName[playerid]);
   
    new File:UserFile = fopen(usfile, io_read); // Open the file
    new key[256], val[256];
    new Data[256];
    if(UserFile){
        while (fread(UserFile, Data, sizeof(Data)))
        { // LOAD FROM ORIGIONAL USERFILES
            key = ini_GetKey(Data);
            if(strcmp(key ,"Faction" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][fsFaction] = strval(val);}
            if(strcmp(key ,"AdminLevel" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][pAdminLevel] = strval(val);}
        }
        fclose(UserFile);
    }
   
    format(usfile, sizeof(usfile), "AccountsUpdate/%s.ini", pName[playerid]);
    UserFile = fopen(usfile, io_read); // Open the file
   
    if(UserFile){
        while (fread(UserFile, Data, sizeof(Data)))
        { // LOAD FROM NEW USERFILES FOR UPDATES
            key = ini_GetKey(Data);
            if(strcmp(key ,"Note1" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote1],val,0,strlen(val)-1,32);}
            if(strcmp(key ,"Note2" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote2],val,0,strlen(val)-1,32);}
            if(strcmp(key ,"Note3" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote3],val,0,strlen(val)-1,32);}
            if(strcmp(key ,"Note4" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote4],val,0,strlen(val)-1,32);}
            if(strcmp(key ,"Note5" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote5],val,0,strlen(val)-1,32);}
        }
        fclose(UserFile);
    }
}
Note1 variable somehow got into the pAdminLevel variable.

This is my enum:
pawn Код:
enum pInformation
{
    pAdminLevel,
    fsFaction,
    pNote1[100],
    pNote2[100],
    pNote3[100],
    pNote4[100],
    pNote5[100]
}
new pInfo[MAX_PLAYERS][pInformation];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)