IsFactionCar isn't running - 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: IsFactionCar isn't running (
/showthread.php?tid=617802)
IsFactionCar isn't running -
ImTouchk - 26.09.2016
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!
Re: IsFactionCar isn't running -
Vince - 26.09.2016
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.
Re: IsFactionCar isn't running -
ImTouchk - 26.09.2016
Quote:
Originally Posted by Vince
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?
Re: IsFactionCar isn't running -
Shinja - 26.09.2016
you don't need to forward for stocks
Re: IsFactionCar isn't running -
ImTouchk - 27.09.2016
Quote:
Originally Posted by Shinja
you don't need to forward for stocks
|
and this due to an error?
Re: IsFactionCar isn't running -
Konstantinos - 27.09.2016
Quote:
Originally Posted by ImTouchk
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.