SA-MP Forums Archive
Can't get object to destroy - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can't get object to destroy (/showthread.php?tid=291217)



Can't get object to destroy - austin070 - 18.10.2011

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;
}



Re: Can't get object to destroy - Tom1412 - 18.10.2011

try doing

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

and do vid = GetPlayerVehicleID(playerid);


Re: Can't get object to destroy - WackoX - 18.10.2011

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.


Re: Can't get object to destroy - austin070 - 18.10.2011

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.


Re: Can't get object to destroy - WackoX - 18.10.2011

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)]);



Re: Can't get object to destroy - austin070 - 18.10.2011

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.


Re: Can't get object to destroy - Tom1412 - 19.10.2011

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