So I have trouble with my veh system...
#1

here is some code :

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[GroveStreet])
        {
            if (Group_GetPlayer(gGSF, playerid)) // Can use the car.
            {
                SendClientMessage(playerid, COLOR_RED, " %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
        if(CarCheck == Cars[SevileCrips])
        {
            if (Group_GetPlayer(gSBF, playerid)) // Can use the car.
            {
                SendClientMessage(playerid, COLOR_RED, " %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Sevile Beach Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
        if(CarCheck == Cars[VeronaBeachCrips])
        {
            if (Group_GetPlayer(gVBF, playerid)) // Can use the car.
            {
                SendClientMessage(playerid, COLOR_RED, " %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in Verona Beach Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
        if(CarCheck == Cars[TempleDriveCrips])
        {
            if (Group_GetPlayer(gTDF, playerid)) // Can use the car.
            {
                SendClientMessage(playerid, COLOR_RED, " %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in Temple Drive Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
    }
    return 1;
}
Maybe someone can help.. It dosn't show message when player is driver!
Reply
#2

How do you assign Cars[whatever] ?
And how do you define GroveStreet or SevileCrips?
Reply
#3

pawn Код:
enum TeamCars
{
    GroveStreet,
    SevileCrips,
    VeronaBeachCrips,
    TempleDriveCrips,
    TempleBloodz,
    GlenPark,
    Jefferson,
    EastBloodz,
    Idlewood
}
new Cars[TeamCars];
Reply
#4

Shouldn't it be something like,
pawn Код:
new Cars[MAX_VEHICLES][TeamCars];
Reply
#5

I might be wrong but if you then assign the car id to one of these like
Cars[GroveStreet] = CreateVehicle(...)
All gangs will have only one car? Most likely that's not what you intended to do. So I guess you reassign the value multiple times for multiple cars? Or do they really have only one car? If so it should work. If not it should only work for the last car created.
For multiplecars per gang you need new Cars[10][TeamCars]; (10 cars per team in this example)
And then loop through all these IDs when someone enters a car.
Reply
#6

Quote:
Originally Posted by roym899
Посмотреть сообщение
I might be wrong but if you then assign the car id to one of these like
Cars[GroveStreet] = CreateVehicle(...)
All gangs will have only one car? Most likely that's not what you intended to do. So I guess you reassign the value multiple times for multiple cars? Or do they really have only one car? If so it should work. If not it should only work for the last car created.
For multiplecars per gang you need new Cars[10][TeamCars]; (10 cars per team in this example)
And then loop through all these IDs when someone enters a car.
Good point I will see if it will work ..

new Cars[MAX_VEHICLES][TeamCars]; (Didn't worked!)

Bouth didn't work!
Reply
#7

MAX_VEHICLES would mean you have 2000 possible cars per team. Probably to much D:

Better define a MAX_GANGVEHICLES with the wanted value and use that.
And add a loop under new CarCheck = GetPlayerVehicleID(playerid);
for(new i=0; i<MAX_GANGVEHICLES;++i)
{
*your code but always use Cars[i][GroveStreet] instead of Cars[GroveStreet]*
}

Post the code then. Also the code where you assign the carids (the part where you create the vehicles)
It should normally work if you did it the right way.
Reply
#8

It's not problem there I think.. You see the message even don't comes up!
Reply
#9

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
It's not problem there I think.. You see the message even don't comes up!
Ofc not because the if statement isn't true. Try to enter the last car you've created in your script and see if that one works.
Reply
#10

Btw looked everywhere and my statment is working fine... Something else is wrong! + Cars are fine...

Because when I enter with another gang id it just kicks me out and says you aren't a part of gang Crips!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)