Wrong id, when deleting. -
I don't know how to explain that but...
1) I create ingame some roadblocks... I give them ids, by havib RoadBlockId ++; system.
2) After creating some roadblock, I delete one RoadBlock with ID ... example 4. System count RoadBlockID --;
3) Then I create a new roadBlock, but it came with same ID as the last one. Example 8. Two roadblocks, with ID 8.
4) After that I Try to use /DeleteAllRoadBlocks. It Don't delete the roadblocks with id 8.
5) When I do it manually, by insert ID, then the new RoadBlock will come with ID -1... and so on.
Here's some code....
PHP код:
Dialog:Rajapiire_Tekita(playerid, response, listitem, inputtext[])
{
if(response == 1)
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
if(RajapiireteArv == MAX_RAJAPIIRDED)return SendClientMessage(playerid, COLOR_RED, "Maksimaalne rajapiirete arv on saavutatud! Rohkem rajapiirded teha ei saa.");
RajapiireteArv ++;
switch(listitem )
{
case 0: Rajapiire[RajapiireteArv] = CreateObject(978, x, y, z - 0.5, 0, 0, a);
case 1: Rajapiire[RajapiireteArv] = CreateObject(973, x, y, z - 0.5, 0, 0, a);
case 2: Rajapiire[RajapiireteArv] = CreateObject(1459, x, y, z - 0.5, 0, 0, a);
case 3: Rajapiire[RajapiireteArv] = CreateObject(3091, x, y, z - 0.5, 0, 0, a);
case 4: Rajapiire[RajapiireteArv] = CreateObject(981, x, y, z - 0.5, 0, 0, a);
case 5: Rajapiire[RajapiireteArv] = CreateObject(1238, x, y, z - 1, 0, 0, a);
case 6: Rajapiire[RajapiireteArv] = CreateObject(1425, x, y, z - 0.5, 0, 0, a);
}
new string[64];
format(string, sizeof(string), "~n~~n~~n~~n~Tekitasite rajapiirde Id-ga ~g~%i.", RajapiireteArv);
GameTextForPlayer(playerid, string, 1500, 5);
}
else ShowEasyDialog(playerid, 16);
return 1;
}
//----------------------------Dialog_Rajapiirde_Kustutamine-----------------------//
Dialog:Rajapiire_Kustuta(playerid, response, listitem, inputtext[])
{
if(response == 1)
{
if (strval(inputtext) < 0 || strval(inputtext) > 200) return SendClientMessage(playerid, COLOR_RED, "Rajapiirete ID-d on 0-st kuni 200-ni!"), ShowEasyDialog(playerid, 18);
if (strval(inputtext) > 0 || strval(inputtext) < 200)
{
new string[64];
if(Rajapiire[strval(inputtext)] ==0) return SendClientMessage(playerid, COLOR_RED, "Sisestatud ID-ga rajapiire puudub"), ShowEasyDialog(playerid, 18);
DeletePlayer3DTextLabel(playerid, RajapiirdeTextLabel[strval(inputtext)]);
DestroyObject(Rajapiire[strval(inputtext)]);
Rajapiire[strval(inputtext)] =0;
RajapiireteArv --;
format(string, sizeof(string), "~n~~n~~n~~n~Kustutasite rajapiirde Id-ga ~g~%i.", strval(inputtext));
GameTextForPlayer(playerid, string, 1500, 5);
}
else return SendClientMessage(playerid, COLOR_RED, "Rajapiirete ID-d saavad olla ainult numbrid."), ShowEasyDialog(playerid, 18);
}
else ShowEasyDialog(playerid, 16);
return 1;
}
//----------------------------Dialog_Rajapiirde_Kustutamine_Kхik-----------------------//
Dialog:Rajapiire_Kustuta_Koik(playerid, response, listitem, inputtext[])
{
if(response == 1)
{
new string[128];
for(new i = 0; i < RajapiireteArv; i++)
{
DeletePlayer3DTextLabel(playerid, RajapiirdeTextLabel[i]);
DestroyObject(Rajapiire[i]);
Rajapiire[i] =0;
}
format(string, sizeof(string), "~n~~n~~n~~n~Kustutasite kхik rajapiirded. ~n~ Neid oli kokku ~r~%d!", RajapiireteArv);
GameTextForPlayer(playerid, string, 1500, 5);
RajapiireteArv =0;
}
else ShowEasyDialog(playerid, 16);
return 1;
}
Re: Wrong id, when deleting. -
Fixed by my self...
I used func. for...