05.01.2015, 20:34
You have to check if the player entered in the train and if the train has a driver.
Here's an example:
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;
}