#1

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

You need to research a bit on enums
Reply
#3

You could explain more what's the problem?
Reply
#4

Why you name this var DRIVERS?

Explain more..what you wanna do, then we can give you some efficent ways
Reply
#5

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

Well I'm just trying to make team cars. the enum is to hold what type of cars they are.
Reply
#7

Ah okay, then you should easily do sth like this:

PHP код:
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(playeridTEAM_GROVE))
{
    
//Here he is in a Grove Car :)
}
//To Set Player in a team car:
PutPlayerInVehicle(playeridCars[TEAM_GROVE][0], 0);
PutPlayerInVehicle(playeridCars[TEAM_GROVE][0]+10); //For the next car
PutPlayerInVehicle(playeridCars[TEAM_GROVE][0]+20); //Just check that the number is smaller then Cars[x][1] 
I hope i could help you a bit
Reply
#8

Could you link the tutorial you used?
Reply
#9

https://sampforum.blast.hk/showthread.php?tid=160810
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)