Faction Vehicles, need help.
#1

I'm trying to make so that when you enter a faction vehicle and you aren't a faction member of the faction the vehicle is associated with, you will get kicked out of it.

pawn Код:
for(new i = 0; i < sizeof(CarInfo); i++)
        {
            if(CarInfo[i][FactionVeh] == 1)
            {
                if(PlayerAccount[playerid][Faction] == CarInfo[i][FactionID]) return 0;
                else
                {
                     RemovePlayerFromVehicle(playerid);
                     SendClientMessage(playerid,COLOR_RED,"[!] You are not in this faction! You cannot drive this vehicle[!]");
                     return 1;
                }
            }
        }
The problem is that it does nothing when you enter a faction vehicle, all vehicles in the game, both owned and everything is in the same table(mysql). If they are a factionvehicle they got 1 in FactionVeh, kinda as shown in code. Hope somebody can help me with this!

Thanks for reading!
Reply
#2

Are you using the "OnPlayerEnterVehicle" callback? If so, don't. It's delayed and buggy from my experiences. Instead, use the OnPlayerStateChange (PLAYER_STATE_DRIVER).
Reply
#3

Exactly what I'm doing.

pawn Код:
if(newstate == 2)
{
 - Code
}
Reply
#4

Or Timer,rs.
pawn Код:
if(GetPlayerState(playerid) == 2)
{
 //Your Code Here
}
Look the Wiki SAMP

States how:

Often used

0 Empty (while initializing) - "PLAYER_STATE_NONE"
1 Player is on foot - "PLAYER_STATE_ONFOOT"
2 Player is driver of a vehicle - "PLAYER_STATE_DRIVER"
3 Player is passenger of a vehicle - "PLAYER_STATE_PASSENGER"
7 Player is wasted or on class selection - "PLAYER_STATE_WASTED"
8 Player is spawned - "PLAYER_STATE_SPAWNED"
9 Player is spectating - "PLAYER_STATE_SPECTATING"

Used internally

4 Player exits a vehicle
5 Player enters a vehicle as driver
6 Player enters a vehicle as passenger
Reply
#5

None of those works, it does nothing when entering a faction vehicle.
Reply
#6

Код:
public OnPlayerEnterVehicle(playerid,vehicleid)
{
	if(CarInfo[vehicleid][FactionVeh] == 1)
	{
		if(PlayerAccount[playerid][Faction] != CarInfo[vehicleid][FactionID])
		{
			RemovePlayerFromVehicle(playerid);                     
			SendClientMessage(playerid,COLOR_RED,"[!] You are not in this faction! You cannot drive this vehicle[!]");                     
		}
	}            
	return 1;
}
Reply
#7

Fixed it, thanks for the help everyone, it turned out to be a fault by me for when I made the Loading system for it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)