Passenger problem
#1

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
Reply
#2

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.
Reply
#3

@CmZxC - You just complicated that man.
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    for(new 
0MAX_PLAYERSi++) if(GetPlayerVehicleSeat(i) == && GetPlayerVehicleID(i) == vehicleid) return false;
    return 
true;

Reply
#4

yeah that might be, but you have a little mistake there, != 0 is the correct one instead of != 1.
Reply
#5

Indeed, the counting starting from "0" and not from "1", thanks for this.
Reply
#6

thank's for answers i will test it now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)