PDA

View Full Version : Cars.


CannonBolt
26/09/2016, 10:38 PM
Hey guys i need help :( i tried creating some team cars base off a tutorial on the forums but to found that the tutorial is wrong i'm trying to create them cars.


new Cars[TeamCars];

enum TeamCars{
DRIVERS
};

Cars[DRIVERS] = AddStaticVehicle(...);

...

Tag Mismatch / invalid array size (negative, zero or out of bounds)

Should i do MAX_VEHICLES instead?

iLearner
27/09/2016, 05:52 AM
You need to research a bit on enums

CannonBolt
27/09/2016, 09:16 PM
You could explain more what's the problem?

Kaliber
27/09/2016, 09:28 PM
Why you name this var DRIVERS? :confused:

Explain more..what you wanna do, then we can give you some efficent ways :)

Sew_Sumi
27/09/2016, 09:46 PM
What line does the actual error turn up at?

As above said though, there could be a better way of doing this, as your enum, doesn't hold much info at all.

CannonBolt
27/09/2016, 11:09 PM
Well I'm just trying to make team cars. the enum is to hold what type of cars they are.

Kaliber
28/09/2016, 01:17 AM
Ah okay, then you should easily do sth like this:

enum
{
TEAM_GROVE, //This is 0
TEAM_BALLAS, //This is 1
TEAM_VAGOS, //This is 2
MAX_TEAMS //Just let this always @ the end of the enum :)
};
new Cars[MAX_TEAMS][2];

Cars[TEAM_GROVE][0] = AddStaticVehicle(...); //0 means the first car
AddStaticVehicle(...);
AddStaticVehicle(...);
AddStaticVehicle(...);
Cars[TEAM_GROVE][1] = AddStaticVehicle(...); //1 means the end car

//Its a segment of cars :)
//To check if a player is in the car:
#define IsPlayerInTeamCar(%0,%1) (Cars[%1][0] <= GetPlayerVehicleID(%0) <= Cars[%1][1])
//Usage:
if(IsPlayerInTeamCar(playerid, TEAM_GROVE))
{
//Here he is in a Grove Car :)
}

//To Set Player in a team car:
PutPlayerInVehicle(playerid, Cars[TEAM_GROVE][0], 0);
PutPlayerInVehicle(playerid, Cars[TEAM_GROVE][0]+1, 0); //For the next car
PutPlayerInVehicle(playerid, Cars[TEAM_GROVE][0]+2, 0); //Just check that the number is smaller then Cars[x][1]

I hope i could help you a bit :)

Sew_Sumi
28/09/2016, 02:34 AM
Could you link the tutorial you used?

CannonBolt
28/09/2016, 02:48 AM
http://forum.sa-mp.com/showthread.php?t=160810

Sew_Sumi
28/09/2016, 01:58 PM
When I did it, I simply used an array for the vehicles, used the team ID in that array for each vehicle, and checked it against the players team.


Enums are however a good thing to master.