Example = CreateVehicle(..) then get that actual vehicle id?
#1

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

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

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

https://sampwiki.blast.hk/wiki/GetVehicleModel
Reply
#5

Do you check the CaSeS?
Reply
#6

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)