Can't get object to destroy
#1

Title says it all. Here's the code:

pawn Код:
NeonStatus[MAX_VEHICLES];
pawn Код:
carneon[vid] = CreateObject(18648,0,0,0,0,0,0);
carneon2[vid] = CreateObject(18648,0,0,0,0,0,0);
AttachObjectToVehicle(carneon[vid], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(carneon2[vid], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
NeonStatus[vid] = 1;
// Creates & attaches neon
pawn Код:
CMD:neon(playerid, params[])
{
    if(NeonStatus[GetPlayerVehicleID(playerid)] == 1)
    {
        NeonStatus[GetPlayerVehicleID(playerid)] = 0;
        DestroyObject(carneon[GetPlayerVehicleID(playerid)]);
        DestroyObject(carneon2[GetPlayerVehicleID(playerid)]);
                // should destroy the object but doesn't.
    }else
    {
        ShowPlayerDialog(playerid, NeonDialog, DIALOG_STYLE_LIST, "Select a color:", "Blue\r\nRed\r\nYellow\r\nGreen\r\nPink", "Select", "Cancel");
    }
    return 1;
}
Reply
#2

try doing

DestroyObject(carneon[vid]);
DestroyObject(carneon2[vid]);

and do vid = GetPlayerVehicleID(playerid);
Reply
#3

Quote:
Originally Posted by Tom1412
Посмотреть сообщение
try doing

DestroyObject(carneon[vid]);
DestroyObject(carneon2[vid]);

and do vid = GetPlayerVehicleID(playerid);
That doesn't change any of the code in theory.

@TS: Try to debug everything.
Reply
#4

Quote:
Originally Posted by Tom1412
Посмотреть сообщение
try doing

DestroyObject(carneon[vid]);
DestroyObject(carneon2[vid]);

and do vid = GetPlayerVehicleID(playerid);
I can't believe that worked -.-. Thanks.
Reply
#5

Quote:
Originally Posted by austin070
Посмотреть сообщение
I can't believe that worked -.-. Thanks.
That can't be the solution, because:

Код:
new vid = GetPlayerVehicleID(playerid);

DestroyObject(carneon[vid]);
DestroyObject(carneon2[vid]);
is the same as:
Код:
DestroyObject(carneon[GetPlayerVehicleID(playerid)]);
DestroyObject(carneon2[GetPlayerVehicleID(playerid)]);
Reply
#6

Quote:
Originally Posted by WackoX
Посмотреть сообщение
That can't be the solution, because:

Код:
new vid = GetPlayerVehicleID(playerid);

DestroyObject(carneon[vid]);
DestroyObject(carneon2[vid]);
is the same as:
Код:
DestroyObject(carneon[GetPlayerVehicleID(playerid)]);
DestroyObject(carneon2[GetPlayerVehicleID(playerid)]);
That's the same thing I thought. Hence the "I can't believe that worked -.-." However, you are wrong at it not being a solution because it worked. I didn't change anything else in attempt to fix it.
Reply
#7

even though it might be the same, but for destroyobject it has to be the same name as the boject is created for.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)