SA-MP Forums Archive
So I have trouble with my veh system... - 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: So I have trouble with my veh system... (/showthread.php?tid=414995)



So I have trouble with my veh system... - Scrillex - 11.02.2013

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!


AW: So I have trouble with my veh system... - roym899 - 11.02.2013

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


Re: So I have trouble with my veh system... - Scrillex - 11.02.2013

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



Re: So I have trouble with my veh system... - RajatPawar - 11.02.2013

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



AW: So I have trouble with my veh system... - roym899 - 11.02.2013

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.


Re: AW: So I have trouble with my veh system... - Scrillex - 11.02.2013

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!


AW: So I have trouble with my veh system... - roym899 - 11.02.2013

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.


Re: So I have trouble with my veh system... - Scrillex - 11.02.2013

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


AW: Re: So I have trouble with my veh system... - roym899 - 11.02.2013

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.


Re: So I have trouble with my veh system... - Scrillex - 11.02.2013

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!