IsValidVehicleID
#1

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
Reply
#2

pawn Код:
stock IsValidVehicleID(vehicleid)
{
   if(GetVehicleModel(vehicleid)) return 1;
   return 0;
}
Reply
#3

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.
Reply
#4

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.
Reply
#5

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!");
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)