IsFactionCar isn't running
#1

Hello all, i'm making faction cars but when i did the script, i saw some warnings ( 18 warnings exactly, yes, so many... ), but, the problem is, when I'm joining the game with pFaction variable 0, if i'm entering the faction car without specific faction, I don't get down from vehicle. A warning, that's why, or...? Down I will take some usefully stuff. Thanks.

Code:
forward IsJobCar(vehicleid);
stock IsJobCar(vehicleid)
{
	new EQNCar[MAX_VEHICLES];
    for(new i = 0; i < sizeof(EQNCar); i++)
        if(vehicleid == EQNCar[i])
            return true;
    return false;
}
*IsJobCar function
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(IsJobCar(vehicleid) && PlayerInfo[playerid][pFaction] != 4)
	{
		RemovePlayerFromVehicle(playerid);
	    SendClientMessage(playerid, -1, "{FFFFFF}Factiune invalida.");
	}
	return 1;
}
*OnPlayerEnterVehicle function
Mhm, if now I think, I must put GetVehicleID after OnPlayerEnterVehicle line?... I really don't know.
Bye!
Reply
#2

OnPlayerEnterVehicle is called when a player presses the key to enter a vehicle. At that point the player isn't actually in the vehicle yet and the entering action may even be aborted. As such, you cannot remove a player from a vehicle they're not even in. Use ClearAnimations to stop the player from entering the vehicle, or use OnPlayerStateChange to eject the player after he has entered the vehicle.
Reply
#3

Quote:
Originally Posted by Vince
View Post
OnPlayerEnterVehicle is called when a player presses the key to enter a vehicle. At that point the player isn't actually in the vehicle yet and the entering action may even be aborted. As such, you cannot remove a player from a vehicle they're not even in. Use ClearAnimations to stop the player from entering the vehicle, or use OnPlayerStateChange to eject the player after he has entered the vehicle.
I tried and entervehicle and statechange, notthing happens... Maybe is a stock IsJobCar problem?
Reply
#4

you don't need to forward for stocks
Reply
#5

Quote:
Originally Posted by Shinja
View Post
you don't need to forward for stocks
and this due to an error?
Reply
#6

Quote:
Originally Posted by ImTouchk
View Post
Code:
new EQNCar[MAX_VEHICLES];
for(new i = 0; i < sizeof(EQNCar); i++)
    if(vehicleid == EQNCar[i])
        return true;
    return false;
The array which stores the vehicle IDs of some faction must be global so you can access it everywhere. What your code does is create an array with size of 2000 and the values are by default 0. Vehicle IDs start from 1 so the function will always return false.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)