SA-MP Forums Archive
CreateVehicle error? - 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: CreateVehicle error? (/showthread.php?tid=612398)



CreateVehicle error? (Edited) - Zeus666 - 17.07.2016

PHP код:
#define TWO_TIRE_VEHICLE GetVehicleModel(GetPlayerVehicleID(playerid)) == 468 
#define SIX_TIRE_VEHICLE GetVehicleModel(GetPlayerVehicleID(playerid)) == 431 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 455 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 433 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 544 
#define NO_TIRE_VEHICLE GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 
#define ENGINE_ONLY_VEHICLE GetVehicleModel(GetPlayerVehicleID(playerid)) == 487 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 453 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 473 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 484 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 417 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 592 
#define TWO_TIRE_VEHICLE_ADD GetVehicleModel(GetVehicleNearID(playerid)) == 468 
#define SIX_TIRE_VEHICLE_ADD GetVehicleModel(GetVehicleNearID(playerid)) == 431 || GetVehicleModel(GetVehicleNearID(playerid)) == 455 || GetVehicleModel(GetVehicleNearID(playerid)) == 433 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 544 
#define NO_TIRE_VEHICLE_ADD GetVehicleModel(GetVehicleNearID(playerid)) == 509 || GetVehicleModel(GetVehicleNearID(playerid)) == 510 
#define ENGINE_ONLY_VEHICLE_ADD GetVehicleModel(GetVehicleNearID(playerid)) == 487 || GetVehicleModel(GetVehicleNearID(playerid)) == 453 || GetVehicleModel(GetVehicleNearID(playerid)) == 473 || GetVehicleModel(GetVehicleNearID(playerid)) == 484 || GetVehicleModel(GetVehicleNearID(playerid)) == 511 || GetVehicleModel(GetVehicleNearID(playerid)) == 417 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 592 

what's wrong with this? it freezez my pawno


Re: CreateVehicle error? - Dayrion - 17.07.2016

That mean nothing. I don't know why do you use define for this.


Re: CreateVehicle error? - Zeus666 - 17.07.2016

Well I need tires or engine for starting a car


PHP код:
enum vehicleinfo
{
    
vehicleTires,
    
vehicleFuel,
    
vehicleEngine,
    
vSlot1[64],
    
vSlot2[64],
    
vSlot3[64],
    
vSlot4[64],
    
vSlot5[64],
    
vSlot6[64],
    
Float:vX,
    
Float:vY,
    
Float:vZ,
    
vehicleSlots,
    
Text3D:vehicleText

PHP код:
    if(FOUR_TIRE(playerid) || FOUR_TIRE2(playerid))
        {
            
format(str,sizeof(str),"~w~Engine:~r~ %i/1~n~~w~Tires:~r~ %i/4~n~~w~Fuel:~r~ %i/100",
            
vInfo[GetPlayerVehicleID(playerid)][vehicleEngine],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleTires],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleFuel]);
            
PlayerTextDrawSetString(playerid,vehicleInfo[playerid],str);
            
PlayerTextDrawShow(playeridvehicleInfo[playerid]);
        }
        if(
TWO_TIRE_VEHICLE)
        {
            
format(str,sizeof(str),"~w~Engine:~r~ %i/1~n~~w~Tires:~r~ %i/2~n~~w~Fuel:~r~ %i/100",
            
vInfo[GetPlayerVehicleID(playerid)][vehicleEngine],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleTires],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleFuel]);
            
PlayerTextDrawSetString(playerid,vehicleInfo[playerid],str);
            
PlayerTextDrawShow(playeridvehicleInfo[playerid]);
        }
        if(
SIX_TIRE_VEHICLE)
        {
            
format(str,sizeof(str),"~w~Engine:~r~ %i/1~n~~w~Tires:~r~ %i/6~n~~w~Fuel:~r~ %i/100",
            
vInfo[GetPlayerVehicleID(playerid)][vehicleEngine],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleTires],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleFuel]);
            
PlayerTextDrawSetString(playerid,vehicleInfo[playerid],str);
            
PlayerTextDrawShow(playeridvehicleInfo[playerid]);
        }
        if(
NO_TIRE_VEHICLE)
        {
            
format(str,sizeof(str),"~w~Engine:~r~ 0/0~n~~w~Tires:~r~ 0/0~n~~w~Fuel:~r~ 0/0");
            
PlayerTextDrawSetString(playerid,vehicleInfo[playerid],str);
            
PlayerTextDrawShow(playeridvehicleInfo[playerid]);
        }
        if(
ENGINE_ONLY_VEHICLE)
        {
            
format(str,sizeof(str),"~w~Engine:~r~ %i/1~n~~w~Tires:~r~ 0/0~n~~w~Fuel:~r~ %i/100",
            
vInfo[GetPlayerVehicleID(playerid)][vehicleEngine],
            
vInfo[GetPlayerVehicleID(playerid)][vehicleFuel]);
            
PlayerTextDrawSetString(playerid,vehicleInfo[playerid],str);
            
PlayerTextDrawShow(playeridvehicleInfo[playerid]);
        }
    } 
see? thats why


and my new added cars are

PHP код:
CreateVehicle(522,818.0776,-1643.5748,13.3828,8.7501,0,0,0); //NRG
    
CreateVehicle(544,1268.1787,-1525.3687,13.5606,260.9624,0,0,0);//FIRETRUCK
    
CreateVehicle(552,1555.7581,-1626.7670,13.3828,81.1073,0,0,0);//Utility Van
    
CreateVehicle(556,1987.5231,-1382.4735,23.6055,240.1862,0,0,0);//Monster Truck
    
CreateVehicle(568,2262.4360,-1056.5121,49.6946,9.6666,0,0,0);//Bandito
    
CreateVehicle(578,2641.6079,-1446.6810,30.2758,271.9059,0,0,0);//DFT-30
    
CreateVehicle(579,2795.2151,-1544.0227,10.9219,201.0919,0,0,0);//Huntley
    
CreateVehicle(588,2856.8699,-1646.5342,10.8750,200.1518,0,0,0);//Hotdog
    
CreateVehicle(487,1716.9417,-2648.7917,13.5469,193.6419,0,0,0); //Maverick
    
CreateVehicle(592,1444.7480,-2593.4758,13.5469,271.6626,0,0,0); //Andromeda
    
CreateVehicle(497,1492.4017,-2416.5955,13.5547,149.9198,0,0,0); //Maverick
    
CreateVehicle(470,2284.8784,-2351.3674,13.5469,50.4473,0,0,0); //Patriot
    
CreateVehicle(430,3043.9883,-1631.1265,-0.6923,67.6806,0,0,0); //Predator
    
CreateVehicle(446,838.0151,-2155.6077,-0.5905,120.6344,0,0,0); //Squallo
    
CreateVehicle(454,544.7344,-2132.8005,-0.4374,319.2429,0,0,0); //Tropic 



Re: CreateVehicle error? - Vince - 17.07.2016

Horrid misuse of macros. Write some functions instead and call GetVehicleModel once.


Re: CreateVehicle error? - Zeus666 - 17.07.2016

Can you give me an exemple?


Re: CreateVehicle error? - Stinged - 17.07.2016

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
Can you give me an exemple?
Код:
#define TWO_TIRE_VEHICLE        1
#define SIX_TIRE_VEHICLE        2
#define NO_TIRE_VEHICLE         3
#define ENGINE_ONLY_VEHICLE     4

GetVehicleType(vehicleid)
{
    switch (vehicleid)
    {
        case 468:                                       return TWO_TIRE_VEHICLE;
        case 431, 455, 433, 544:                        return SIX_TIRE_VEHICLE;
        case 509, 510:                                  return NO_TIRE_VEHICLE;
        case 417, 453, 473, 484, 487, 497, 511, 592:    return ENGINE_ONLY_VEHICLE;
        default: return 0;
    }
}

// Where you want to use it
switch (GetVehicleType(GetPlayerVehicleID(playerid)))
{
    case TWO_TIRE_VEHICLE:
    {

    }
    case SIX_TIRE_VEHICLE:
    {

    }
    case NO_TIRE_VEHICLE:
    {

    }
    case ENGINE_ONLY_VEHICLE:
    {
        
    }
}



Re: CreateVehicle error? - iKarim - 17.07.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Код:
#define TWO_TIRE_VEHICLE        1
#define SIX_TIRE_VEHICLE        2
#define NO_TIRE_VEHICLE         3
#define ENGINE_ONLY_VEHICLE     4

GetVehicleType(vehicleid)
{
    switch (vehicleid)
    {
        case 468:                                       return TWO_TIRE_VEHICLE;
        case 431, 455, 433, 544:                        return SIX_TIRE_VEHICLE;
        case 509, 510:                                  return NO_TIRE_VEHICLE;
        case 417, 453, 473, 484, 487, 497, 511, 592:    return ENGINE_ONLY_VEHICLE;
        default: return 0;
    }
}

// Where you want to use it
switch (GetVehicleType(GetPlayerVehicleID(playerid)))
{
    case TWO_TIRE_VEHICLE:
    {

    }
    case SIX_TIRE_VEHICLE:
    {

    }
    case NO_TIRE_VEHICLE:
    {

    }
    case ENGINE_ONLY_VEHICLE:
    {
        
    }
}
Your code has an issue, you're using vehicleid instead of model id.

PHP код:
GetVehicleType(vehicleid)
{
    new 
model GetVehicleModel(vehicleid);
    switch (
model)
    {
        case 
468:                                       return TWO_TIRE_VEHICLE;
        case 
431455433544:                        return SIX_TIRE_VEHICLE;
        case 
509510:                                  return NO_TIRE_VEHICLE;
        case 
417453473484487497511592:    return ENGINE_ONLY_VEHICLE;
        default: return 
0;
    }




Re: CreateVehicle error? - Zeus666 - 17.07.2016

Guys, I have TWO_TIRE_VEHICLE_ADD add too. Should I add
PHP код:
#define TWO_TIRE_VEHICLE_ADD        1
#define SIX_TIRE_VEHICLE_ADD        2
#define NO_TIRE_VEHICLE_ADD         3
#define ENGINE_ONLY_VEHICLE_ADD     4 
?


Re: CreateVehicle error? - Stinged - 17.07.2016

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
Your code has an issue, you're using vehicleid instead of model id.

PHP код:
GetVehicleType(vehicleid)
{
    new 
model GetVehicleModel(vehicleid);
    switch (
model)
    {
        case 
468:                                       return TWO_TIRE_VEHICLE;
        case 
431455433544:                        return SIX_TIRE_VEHICLE;
        case 
509510:                                  return NO_TIRE_VEHICLE;
        case 
417453473484487497511592:    return ENGINE_ONLY_VEHICLE;
        default: return 
0;
    }

Oh yes, sorry. I didn't notice that.
By the way, no need to create a new variable when using switch.
Код:
switch (GetVehicleModel(vehicleid))
Would work just fine.

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
Guys, I have TWO_TIRE_VEHICLE_ADD add too. Should I add
PHP код:
#define TWO_TIRE_VEHICLE_ADD        1
#define SIX_TIRE_VEHICLE_ADD        2
#define NO_TIRE_VEHICLE_ADD         3
#define ENGINE_ONLY_VEHICLE_ADD     4 
?
I don't get why those are there. Unless I'm reading it incorrectly, they have the exact same definition no?


Re: CreateVehicle error? - Zeus666 - 17.07.2016

Now I see, IF I go by what you've said, I need to change most part of the script,because I have TWO_TIRE_VEHICLE_ADD
SIX_TIRE_VEHICLE_ADD
NO_TIRE_VEHICLE_ADD
ENGINE_ONLY_VEHICLE_ADD


too many times, and most of it is at "Tire" section. (adds tires at every slot, and I have 4 slots per car, so think about it.)


I need to stick on my initial macros. (define)