SA-MP Forums Archive
Example = CreateVehicle(..) then get that actual vehicle id? - 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: Example = CreateVehicle(..) then get that actual vehicle id? (/showthread.php?tid=286697)



Example = CreateVehicle(..) then get that actual vehicle id? - Jack_Leslie - 30.09.2011

Hi guys, I'm having troubles with the dealership system I've got right. So when the gameloads, it creates a users owned vehicle like this:

pawn Код:
CarInfo[idx][ownedvehicle] = CreateVehicle(CarInfo[idx][vModel],CarInfo[idx][vLocationx],CarInfo[idx][vLocationy],CarInfo[idx][vLocationz],CarInfo[idx][vAngle],CarInfo[idx][vColorOne],CarInfo[idx][vColorTwo],10000);
Then I have a code that returns CarInfo[idx][ownedvehicle] as a Vehicle ID. Sometimes though, it bugs, and gives a different vehicle id, or an invalid vehicle ID. So is there any way I can grab the actual Vehicle ID of CarInfo[...][ownedvehicle] ?


Re: Example = CreateVehicle(..) then get that actual vehicle id? - Backwardsman97 - 30.09.2011

What do you mean grab the actual vehicle id? CarInfo[...][ownedvehicle] is set to whatever you set it to. Maybe there's a problem when you're dealing with the idx variable or an error elsewhere.


Re: Example = CreateVehicle(..) then get that actual vehicle id? - Jack_Leslie - 30.09.2011

Well this is what I have to grab the Vehicle ID:

pawn Код:
stock GetCarIDFromPlayer(playerid)
{
    for(new i=0; i<sizeof(CarInfo); i++)
    {
        if(!strcmp(CarInfo[i][vOwner], PlayerName(playerid))) return CarInfo[i][ownedvehicle];  //Returns the Vehicle ID
    }
    return -1;
}
(Made by Jeffrey)

Many people have told me that looks perfectly fine, however, sometimes, even if the players name is the same as "CarInfo[i][vOwner]" then it still returns -1 (INVALID_VEHICLE_ID).


Re: Example = CreateVehicle(..) then get that actual vehicle id? - [MWR]Blood - 30.09.2011

https://sampwiki.blast.hk/wiki/GetVehicleModel


Re: Example = CreateVehicle(..) then get that actual vehicle id? - iPLEOMAX - 30.09.2011

Do you check the CaSeS?


Re: Example = CreateVehicle(..) then get that actual vehicle id? - Jack_Leslie - 30.09.2011

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Do you check the CaSeS?
Nah I don't... should I?


Re: Example = CreateVehicle(..) then get that actual vehicle id? - iPLEOMAX - 30.09.2011

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Nah I don't... should I?
nvm.

Do some debug codes when saving the vehicle id and also when using it..

Check at what moments this happen.


Re: Example = CreateVehicle(..) then get that actual vehicle id? - Jack_Leslie - 30.09.2011

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
nvm.

Do some debug codes when saving the vehicle id and also when using it..

Check at what moments this happen.
I can't do that. Because it only happens sometimes, that's why I requested help, see if someone knows why. If I did put in some debug, it could take days to weeks to months to see it, because I don't know when it'll happen next.