Check playername
#2

You have to check if the player entered in the train and if the train has a driver.

Here's an example:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    switch(newstate)
    {
        case PLAYER_STATE_PASSENGER:
        {// Check if player has entered as passenger
            if(GetPlayerVehicleID(playerid) == TRAIN_ID)
            {// Check if the vehicle is the train, CHANGE TO TRAIN VEHICLE ID
                new driverid = GetVehicleDriverID(GetPlayerVehicleID(playerid));
                // Get the driverid
                if(driverid != INVALID_PLAYER_ID)
                {// Check if the train has a driver
                    // Do stuff
                }
            }
        }
    }
    return 1;
}

stock GetVehicleDriverID(vehicleid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                return i;
            }
        }
    }
    return INVALID_PLAYER_ID;
}
Reply


Messages In This Thread
Check playername - by cyberlord - 05.01.2015, 18:53
Re: Check playername - by Larceny - 05.01.2015, 20:34

Forum Jump:


Users browsing this thread: 1 Guest(s)