Passenger problem - 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: Passenger problem (
/showthread.php?tid=358011)
Passenger problem -
dasto_fantasto - 09.07.2012
Hello,
I'm new in Sa-Mp scripting, now i'm making code and have a little problem.
I want to make that if the car is empty (there is nobody in the car) you can't sit as a driver.
If there is passenger than you cant sit into drivers place.
Can anybody help? Thank's in advance
Re: Passenger problem -
CmZxC - 09.07.2012
pawn Код:
#include <a_samp>
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerVehicleID(i) != vehicleid) continue;
if(GetPlayerState(i) == PLAYER_STATE_PASSENGER && !ispassenger) return 1; // success, should also break the loop
if(i>=499 && !ispassenger) return ClearAnimations(playerid); // nobody in, can't enter.
}
return 1;
}
Not tested, not sure.
Re: Passenger problem -
Accord - 09.07.2012
@CmZxC - You just complicated that man.
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < MAX_PLAYERS; i++) if(GetPlayerVehicleSeat(i) == 0 && GetPlayerVehicleID(i) == vehicleid) return false;
return true;
}
Re: Passenger problem -
CmZxC - 09.07.2012
yeah that might be, but you have a little mistake there, != 0 is the correct one instead of != 1.
Re: Passenger problem -
Accord - 09.07.2012
Indeed, the counting starting from "0" and not from "1", thanks for this.
Re: Passenger problem -
dasto_fantasto - 09.07.2012
thank's for answers i will test it now