Wrong id, when deleting.
#1

Hello!

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.

What I am doing wrong?
How to check the available ids?

Here's some code....
PHP код:
Dialog:Rajapiire_Tekita(playeridresponselistiteminputtext[])
{
    if(
response == 1)
    {
        new 
Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridx,y,z);
        
GetPlayerFacingAngle(playerida);
        if(
RajapiireteArv == MAX_RAJAPIIRDED)return SendClientMessage(playeridCOLOR_RED"Maksimaalne rajapiirete arv on saavutatud! Rohkem rajapiirded teha ei saa.");
        
RajapiireteArv ++;
        switch(
listitem )
        {
            case 
0Rajapiire[RajapiireteArv] = CreateObject(978xy0.500a);
            case 
1Rajapiire[RajapiireteArv] = CreateObject(973xy0.500a);
            case 
2Rajapiire[RajapiireteArv] = CreateObject(1459xy0.500a);
            case 
3Rajapiire[RajapiireteArv] = CreateObject(3091xy0.500a);
            case 
4Rajapiire[RajapiireteArv] = CreateObject(981xy0.500a);
            case 
5:    Rajapiire[RajapiireteArv] = CreateObject(1238xy100a);
            case 
6Rajapiire[RajapiireteArv] = CreateObject(1425xy0.500a);
        }
        new 
string[64];
        
format(stringsizeof(string), "~n~~n~~n~~n~Tekitasite rajapiirde Id-ga ~g~%i."RajapiireteArv);
        
GameTextForPlayer(playeridstring15005);
    }
    else 
ShowEasyDialog(playerid16);
    return 
1;
}
//----------------------------Dialog_Rajapiirde_Kustutamine-----------------------//
Dialog:Rajapiire_Kustuta(playeridresponselistiteminputtext[])
{
    if(
response == 1)
    {
        if (
strval(inputtext) < || strval(inputtext) > 200) return SendClientMessage(playeridCOLOR_RED"Rajapiirete ID-d on 0-st kuni 200-ni!"), ShowEasyDialog(playerid18);
        if (
strval(inputtext) > || strval(inputtext) < 200)
        {
            new 
string[64];
            if(
Rajapiire[strval(inputtext)] ==0) return SendClientMessage(playeridCOLOR_RED"Sisestatud ID-ga rajapiire puudub"), ShowEasyDialog(playerid18);
            
DeletePlayer3DTextLabel(playeridRajapiirdeTextLabel[strval(inputtext)]);
            
DestroyObject(Rajapiire[strval(inputtext)]);
            
Rajapiire[strval(inputtext)] =0;
            
RajapiireteArv --;
            
format(stringsizeof(string), "~n~~n~~n~~n~Kustutasite rajapiirde Id-ga ~g~%i."strval(inputtext));
            
GameTextForPlayer(playeridstring15005);
        }
        else return 
SendClientMessage(playeridCOLOR_RED"Rajapiirete ID-d saavad olla ainult numbrid."), ShowEasyDialog(playerid18);
    }
    else 
ShowEasyDialog(playerid16);
    return 
1;
}
//----------------------------Dialog_Rajapiirde_Kustutamine_Kхik-----------------------//
Dialog:Rajapiire_Kustuta_Koik(playeridresponselistiteminputtext[])
{
    if(
response == 1)
    {
        new 
string[128];
        for(new 
0RajapiireteArvi++)
        {
            
DeletePlayer3DTextLabel(playeridRajapiirdeTextLabel[i]);
            
DestroyObject(Rajapiire[i]);
            
Rajapiire[i] =0;
        }
        
format(stringsizeof(string), "~n~~n~~n~~n~Kustutasite kхik rajapiirded. ~n~ Neid oli kokku ~r~%d!"RajapiireteArv);
        
GameTextForPlayer(playeridstring15005);
        
RajapiireteArv =0;
    }
    else 
ShowEasyDialog(playerid16);
    return 
1;

Reply
#2

Fixed by my self...
I used func. for...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)