IsValidVehicleID - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsValidVehicleID (
/showthread.php?tid=97224)
IsValidVehicleID -
Outbreak - 13.09.2009
I wanna make a function to check if the vehicle id exists on my server.
if i spawn 10 cars. the ids are 1-10. so vehid = 10.
if I delete vehicles 3, 4 and 5. I can still do /delcar 5 and re-delete vehicleid 5, even though it doesnt exist anymore.
No actual vehicle is deleted if i re-delete a vehicle id, but the vehid lowers by 1.
So what im trying to make is and function to check if the vehicleID has been deleted or if it exists.
Is there a good way to do that, or would i be better shifting the vehicleids by 1 each time one is deleted... so if i have 10 vehicles vehid = 10.
if i delete vehicleid 5. vehicleID 6 would then become vehicleid 5., 7 to 6... 8 to 7... 9 to 8.... 10 to 9... so then vehid = 9
Re: IsValidVehicleID -
CracK - 13.09.2009
pawn Код:
stock IsValidVehicleID(vehicleid)
{
if(GetVehicleModel(vehicleid)) return 1;
return 0;
}
Re: IsValidVehicleID -
Outbreak - 13.09.2009
Quote:
|
Originally Posted by CrαcK
pawn Код:
stock IsValidVehicleID(vehicleid) { if(GetVehicleModel(vehicleid)) return 1; return 0; }
|
Did you even read my post?
VehicleID, ID of the Vehicle created... 1 vehicle created, meaning its vehicle ID 1... vehid = 1... ID not model.
Re: IsValidVehicleID -
CracK - 13.09.2009
Quote:
|
Originally Posted by Outbreak
Did you even read my post?
VehicleID, ID of the Vehicle created... 1 vehicle created, meaning its vehicle ID 1... vehid = 1... ID not model.
|
Did you even try this?
GetVehicleModel(vehicleid) will return 0 if the vehicleid does not exist.
Re: IsValidVehicleID -
Nero_3D - 13.09.2009
all functions return 0 if something doesnt exist or dont work
pawn Код:
if(!strcmp("/delcar", cmdtext, true, 7) && (cmdtext[7] == 32 || cmdtext[7] == EOS))
if(!('0' <= cmdtext[8] && cmdtext[8] <= '9'))
return SendClientMessage(playerid, 0xFFFFFFAA, "Right Usage: /delcar [vehicleid]");
else if(!DestroyVehicle(strval(cmdtext[8])))
return SendClientMessage(playerid, 0xFFFFFFAA, "Vehicleid doesnt exist!");
Re: IsValidVehicleID -
Outbreak - 13.09.2009
I've figured out another way i can do it, so im gonna go with that.. Seems fairly reliable and no real chance in it causing any bugs.
Thanks anyway.