Stopping player fom exiting car
#10

pawn Code:
// Top of your script
new
    g_PlayerVehicle[MAX_PLAYERS],
    g_SeatID[MAX_PLAYERS]
;


// OnPlayerStateChange
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    // Store vehicle's ID
    if ((newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER))
    {
        g_PlayerVehicle[playerid] = GetPlayerVehicleID(playerid);
        g_SeatID[playerid] = GetPlayerVehicleSeat(playerid);
    }

    // Making not possible to get out of the car
    if ((newstate == PLAYER_STATE_ONFOOT) && ((oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)))
        PutPlayerInVehicle(playerid, g_PlayerVehicle[playerid], g_SeatID[playerid]);

    // Return
    return 1;
}
This should work



EDIT: Sorry, I thought you want to put player back in vehicle after he get outs.
This code should work:

pawn Code:
// Top of your script
new
    g_PlayerVehicle[MAX_PLAYERS],
    g_SeatID[MAX_PLAYERS]
;

forward PutPlayerBackInVehicle(playerid);
public  PutPlayerBackInVehicle(playerid)
{
    PutPlayerInVehicle(playerid, g_PlayerVehicle[playerid], g_SeatID[playerid]);

    return 1;
}


// OnPlayerStateChange
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    // Store vehicle's ID
    if ((newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER))
    {
        g_PlayerVehicle[playerid] = GetPlayerVehicleID(playerid);
        g_SeatID[playerid] = GetPlayerVehicleSeat(playerid);
    }

    // Return
    return 1;
}


// OnPlayerKeyStateChange
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    // Making not possible to get out of the car
    if (IsPlayerInAnyVehicle(playerid))
    {
        if (newkeys & KEY_SECONDARY_ATTACK)
        {
            SetTimerEx("PutPlayerBackInVehicle", 100, false, "i", playerid);
        }
    }

    // Return
    return 1;
}
Reply


Messages In This Thread
Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:02
Re: Stopping player fom exiting car - by Krx17 - 04.02.2011, 06:04
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:10
Re: Stopping player fom exiting car - by Krx17 - 04.02.2011, 06:10
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:16
Re: Stopping player fom exiting car - by Kwarde - 04.02.2011, 06:18
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:38
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:57
Re: Stopping player fom exiting car - by Kyle_Olsen - 04.02.2011, 07:02
Re: Stopping player fom exiting car - by MrDeath537 - 04.02.2011, 07:36

Forum Jump:


Users browsing this thread: 1 Guest(s)