Q: GetVehicleModel
#1

Hey Lads,


How Does GetVehicleModel Actually Work.
I Know This Sounds Dumb, But I'd Really Like to Know How to Works, So i Can Maybe Code a Something With This Function.

Basically, I Want Something Along These Lines... Maybe you Guys Could Point me to Another Function?

Код:
new VehicleID;
new VModel;
VehicleID = GetPlayerVehicleID(playerid); 
VModel    =  GetVehicleModel(vehicleid);
/* My Array |  Car ID Here? | Is Petrol/Diesel*/
if(gEngines[VModel]-???] == 0)
/* 0 = Diesel, 1 = Petrol */
Yeah, That about It xD

Ezay
\o/
Reply
#2

GetVehicleModel returns a vehicle model, like 411 for example (Infernus).
pawn Код:
if( GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 411 )
return SendClientMessage( playerid, "You're driving a 'Infernus'" );
Reply
#3

/* My Array | Car ID Here? | Is Petrol/Diesel*/
if(gEngines[VModel]-411] == 0) //Returns 411 == Infernus
/* 0 = Diesel, 1 = Petrol */


That About Correct?
Reply
#4

No, what you exactly want to do?
Reply
#5

Read the Comments,

I Made an Array Somthing like This

new gEngines[] =
{
0, //Landstalker | Petrol = 0 | ID: 400
1, //Diesel Car | Diesel = 1 | ID: 401
};
Reply
#6

pawn Код:
new isPetrolCar[MAX_VEHICLES];

if( GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 400 ) // LandStalker
isPetrolCar[GetPlayerVehicleID( playerid )] = 0;
//and etc..
Reply
#7

Cheers Marricio,

You've Helped me Out;

Ezay
\o/
Reply
#8

do

if(gEngines[VModel - 400] == 0)
Reply
#9

@Kar

if(gEngines[VModel - 400] == 0)?
The -400, is that the ModelID?

Or

Does it Just go like This?


if(gEngines[VModel - 400] == 0) // 400
if(gEngines[VModel - 400] == 0) // 401
if(gEngines[VModel - 400] == 1) // 402 (Diesel)
Reply
#10

So basically, what you're trying to do is something like this...

pawn Код:
new Diesel[HOWMANYDIESELWEHAVE] = {
    {411}, //though this isn't true...but whatever ID for a diesel truck is
    {} //etc
};


stock IsInDiesel(playerid)
{
    new Vehicle = GetVehicleModel(GetPlayerVehicleID(playerid)), bool:found;
    //We create our two variables for storing our data. One will store the vehicle model, the other whether we found something.
    for(new i = 0; i < sizeof(Diesel); i++)
    {
        if(Vehicle == Diesel[i]) //If their vehicle model is equal to something in our array
        {
            found=true; //We found something, so we set our found boolean to true.
            break; //Then we break out of our loop here..No point in continuing if we've found what we're looking for.
        }
    }
    if(found) return true; //We'll return TRUE if we've found something
    else return false; //if we haven't, we'll return FALSE
}


CMD:dieselfuel(playerid, params[])
{
    if(!IsInDiesel(playerid)) return SendClientMessage(playerid, 0xCC0000AA, "You aren't in a diesel truck!"); //This is just an example, you'd probably use it differently.
    return 1;
}
You can use this both to detect if it isn't a diesel truck or if it is. !IsInDiesel(playerid) to detect if it isn't, IsInDiesel(playerid) to detect if it is.

This is how it works - https://sampwiki.blast.hk/wiki/GetVehicleModel
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)