SA-MP Forums Archive
Help with DestroyObject - 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: Help with DestroyObject (/showthread.php?tid=446863)



Help with DestroyObject - Mennims - 27.06.2013

Ok so what I want to do is that when my vehicle respawns all the objects attached to the vehicle, that is if any are attached will be destroyed.

I have attempted it.


if (strcmp("/upgrade", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 3, -592.4484, -527.8525, 25.9835))
{
RepairVehicle(GetPlayerVehicleID(playerid));
new vehicleid = GetPlayerVehicleID(playerid);
new objectid0 = CreateObject(18553, 0.00000, -1.39560, 3.16254, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid0,vehicleid, 0.00000, -1.39560, 3.16254, 0.00000, 90.00000, 0.00000);

new objectid1 = CreateObject(2937, 0.00000, -3.31740, 1.89430, 0.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid1,vehicleid, 0.00000, -3.31740, 1.89430, 0.00000, 90.00000, 90.00000);

new objectid2 = CreateObject(2937, 0.00000, -3.31740, 1.35320, 0.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid2,vehicleid, 0.00000, -3.31740, 1.35320, 0.00000, 90.00000, 90.00000);

new objectid3 = CreateObject(2937, 1.23730, -2.07990, 1.35320, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid3,vehicleid, 1.23730, -2.07990, 1.35320, 0.00000, 90.00000, 0.00000);

new objectid4 = CreateObject(2937, -1.24490, -2.07990, 1.89430, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid4,vehicleid, -1.24490, -2.07990, 1.89430, 0.00000, 90.00000, 0.00000);

new objectid5 = CreateObject(2937, -1.24490, -0.70940, 1.35320, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid5,vehicleid, -1.24490, -0.70940, 1.35320, 0.00000, 90.00000, 0.00000);

new objectid6 = CreateObject(2937, -1.24490, -0.70940, 1.89430, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid6,vehicleid, -1.24490, -0.70940, 1.89430, 0.00000, 90.00000, 0.00000);

new objectid7 = CreateObject(2937, -1.24493, -2.07992, 1.35320, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid7,vehicleid, -1.24493, -2.07992, 1.35320, 0.00000, 90.00000, 0.00000);

new objectid8 = CreateObject(2937, 1.23730, -0.70940, 1.35320, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid8,vehicleid, 1.23730, -0.70940, 1.35320, 0.00000, 90.00000, 0.00000);

new objectid9 = CreateObject(2937, 1.23730, -2.07990, 1.89430, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid9,vehicleid, 1.23730, -2.07990, 1.89430, 0.00000, 90.00000, 0.00000);

new objectid10 = CreateObject(2937, 1.23730, -0.70940, 1.89434, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid10,vehicleid, 1.23730, -0.70940, 1.89434, 0.00000, 90.00000, 0.00000);

new objectid11 = CreateObject(2937, 0.05370, 1.15080, 0.59260, 0.00000, 30.00000, 90.00000) ;
AttachObjectToVehicle(objectid11,vehicleid, 0.05370, 1.15080, 0.59260, 0.00000, 30.00000, 90.00000);

new objectid12 = CreateObject(2937, -0.93735, 0.50663, 1.89750, 90.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid12,vehicleid, -0.93735, 0.50663, 1.89750, 90.00000, 90.00000, 90.00000);

new objectid13 = CreateObject(2937, 0.02437, 2.48210, -0.03540, 0.00000, 0.00000, 90.00000) ;
AttachObjectToVehicle(objectid13,vehicleid, 0.02437, 2.48210, -0.03540, 0.00000, 0.00000, 90.00000);

new objectid14 = CreateObject(2937, 0.05370, 2.73220, -0.29000, 0.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid14,vehicleid, 0.05370, 2.73220, -0.29000, 0.00000, 90.00000, 90.00000);

new objectid15 = CreateObject(2937, 1.23730, -0.70940, 2.90745, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid15,vehicleid, 1.23730, -0.70940, 2.90745, 0.00000, 90.00000, 0.00000);

new objectid16 = CreateObject(2937, 1.23730, -2.07990, 2.90750, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid16,vehicleid, 1.23730, -2.07990, 2.90750, 0.00000, 90.00000, 0.00000);

new objectid17 = CreateObject(2937, 0.00000, -3.31740, 2.90750, 0.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid17,vehicleid, 0.00000, -3.31740, 2.90750, 0.00000, 90.00000, 90.00000);

new objectid18 = CreateObject(2937, -1.24490, -2.07990, 2.90750, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid18,vehicleid, -1.24490, -2.07990, 2.90750, 0.00000, 90.00000, 0.00000);

new objectid19 = CreateObject(2937, -1.24490, -0.70940, 2.90750, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid19,vehicleid, -1.24490, -0.70940, 2.90750, 0.00000, 90.00000, 0.00000);

new objectid20 = CreateObject(18553, 0.00000, -1.39560, 1.06910, 0.00000, 90.00000, 0.00000) ;
AttachObjectToVehicle(objectid20,vehicleid, 0.00000, -1.39560, 1.06910, 0.00000, 90.00000, 0.00000);

new objectid21 = CreateObject(2937, 0.05370, 0.68730, 0.85970, 0.00000, 30.00000, 90.00000) ;
AttachObjectToVehicle(objectid21,vehicleid, 0.05370, 0.68730, 0.85970, 0.00000, 30.00000, 90.00000);

new objectid22 = CreateObject(2937, 0.99149, 0.50255, 1.89750, 90.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid22,vehicleid, 0.99149, 0.50255, 1.89750, 90.00000, 90.00000, 90.00000);

new objectid23 = CreateObject(2937, 0.99047, -3.33317, 1.89750, 90.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid23,vehicleid, 0.99047, -3.33317, 1.89750, 90.00000, 90.00000, 90.00000);

new objectid24 = CreateObject(2937, -0.99227, -3.29980, 1.89750, 90.00000, 90.00000, 90.00000) ;
AttachObjectToVehicle(objectid24,vehicleid, -0.99227, -3.29980, 1.89750, 90.00000, 90.00000, 90.00000);
}
return 1;
}

Ok but now to remove it

public OnVehicleSpawn(vehicleid)
{
DestroyObject(objectid1);
DestroyObject(objectid2);
DestroyObject(objectid3);
DestroyObject(objectid4);
DestroyObject(objectid5);
DestroyObject(objectid6);
DestroyObject(objectid7);
DestroyObject(objectid;
DestroyObject(objectid9);
DestroyObject(objectid10);
DestroyObject(objectid11);
DestroyObject(objectid12);
DestroyObject(objectid13);
DestroyObject(objectid14);
DestroyObject(objectid15);
DestroyObject(objectid16);
DestroyObject(objectid17);
DestroyObject(objectid1;
DestroyObject(objectid19);
DestroyObject(objectid20);
DestroyObject(objectid21);
DestroyObject(objectid22);
DestroyObject(objectid23);
DestroyObject(objectid24);
}
I have done that but I get a few errors

C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(941) : error 017: undefined symbol "objectid1"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(942) : error 017: undefined symbol "objectid2"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(943) : error 017: undefined symbol "objectid3"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(944) : error 017: undefined symbol "objectid4"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(945) : error 017: undefined symbol "objectid5"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(946) : error 017: undefined symbol "objectid6"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(947) : error 017: undefined symbol "objectid7"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(94 : error 017: undefined symbol "objectid8"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(949) : error 017: undefined symbol "objectid9"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(950) : error 017: undefined symbol "objectid10"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(951) : error 017: undefined symbol "objectid11"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(952) : error 017: undefined symbol "objectid12"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(953) : error 017: undefined symbol "objectid13"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(954) : error 017: undefined symbol "objectid14"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(955) : error 017: undefined symbol "objectid15"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(956) : error 017: undefined symbol "objectid16"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(957) : error 017: undefined symbol "objectid17"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(95 : error 017: undefined symbol "objectid18"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(959) : error 017: undefined symbol "objectid19"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(960) : error 017: undefined symbol "objectid20"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(961) : error 017: undefined symbol "objectid21"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(962) : error 017: undefined symbol "objectid22"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(963) : error 017: undefined symbol "objectid23"
C:\Users\Mennims\Documents\Downloads\samp03x_svr_R 1-2_win32\gamemodes\server.pwn(964) : error 017: undefined symbol "objectid24"

How to fix this? Or is there a better way of just removing all the objects at once? Please help thanks. Because I will be adding many more objects on many more cars and I don't want 1 million lines of destroy objects code


Re: Help with DestroyObject - Kittylol - 27.06.2013

place code with PAWN-IN BEGGINING /PAWN-IN END OF CODE WITH "["
to make your topic more easier to understand
or press "#" in text edit


Re: Help with DestroyObject - Mennims - 27.06.2013

What? Please do the code for me so I can see


Re: Help with DestroyObject - Kittylol - 27.06.2013

in beggining of code place
pawn Код:
#define objectid1
#define objectid2
AND CONTINUE WITH ALL NUMBERS...
and all the way with these


Re: Help with DestroyObject - feartonyb - 27.06.2013

Just place new objectid1, objectid2,..., objectid24; on top of script, then under upgrade command remove new before new objectid1 = ...., new objectid2 = .... so it looks like objectid1 = CreateObject(...);


Re: Help with DestroyObject - CLT - 27.06.2013

Quote:
Originally Posted by Mennims
Посмотреть сообщение
What? Please do the code for me so I can see
Use .[.PAWN.]. at the beggining of the script. (Just without the dots.)
And use .[./PAWN.]. at the end of the script. (Just without the dots aswell.)

And between both pawns place your script which you'll like to show here.


Re: Help with DestroyObject - Mennims - 27.06.2013

Thanks guys, + rep to the helpers