Get Last Vehicle
#2

pawn Код:
new lastvehicle[MAX_PLAYERS]; //Under your #includes etc. at the top of your script

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    //if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) // Use this is you want for passenger + driver seats.
    if(newstate == PLAYER_STATE_DRIVER) //If the player enters the car as a driver.
    {
        lastvehicle[playerid] = GetPlayerVehicleID(playerid);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    lastvehicle[playerid] = INVALID_VEHICLE_ID;
    return 1;
}

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = INVALID_VEHICLE_ID;
    return 1;
}

CMD:mycommand(playerid, params[]) //Example command: /mycommand
{
    if(lastvehicle[playerid] == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "You have not entered a vehicle yet.");
    if(PlayerIsNotCloseTo(lastvehicle[playerid])
    {
        SendClientMessage(playerid, -1, "You aren't even near the damn thing...");
    }
    else
    {
        SendClientMessage(playerid, -1, "You found your car.");
    }
    return 1;
}
This is merely an example, and the given code is less than likely to actually perform as expected. However the code is accurate and will work on a regular basis.
Reply


Messages In This Thread
Get Last Vehicle - by arjanforgames - 21.07.2013, 13:38
Re: Get Last Vehicle - by Threshold - 21.07.2013, 13:44

Forum Jump:


Users browsing this thread: 3 Guest(s)