Get in Player Vehicle [PROBLEM]
#4

Actually, it took me a long time to get all these details, and there's probably the same thing hidden on SA-MP forums somewhere, but I wasn't ready to look. This is my code from quite a while ago, but it will still work perfectly. I can't believe I got it to work the way it does, especially at the level I was at during the time I made this...

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
#include <foreach>

new MaxVehicleSeats[212] =
{
    4, 2, 2, 2, 4, 4, 1, 2, 2, 4, 2, 2, 2, 4, 2, 2, 4, 2, 4, 2, 4, 4, 2, 2, 2,
    1, 4, 4, 4, 2, 1, 9, 1, 2, 2, 0, 2, 9, 4, 2, 4, 1, 2, 2, 2, 4, 1,
    2, 1, 2, 0, 2, 1, 1, 1, 2, 2, 2, 4, 4, 2, 2, 1, 2, 1, 2, 4, 4, 2, 2, 4, 2, 1,
    1, 2, 2, 1, 2, 2, 4, 2, 1, 4, 3, 1, 1, 1, 4, 4, 2, 4, 2, 4, 1, 2, 2, 2, 4, 4,
    2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 1, 1, 2, 1, 1, 2, 2, 4, 2, 2, 1, 1, 2, 2, 2, 2,
    2, 2, 2, 2, 4, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 4, 2, 2, 2, 2, 2, 4, 4, 2, 2, 4,
    4, 2, 1, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 1, 2, 4, 4, 1, 0, 0, 1, 1, 2,
    1, 2, 2, 4, 2, 4, 4, 2, 4, 1, 0, 4, 2, 2, 2, 2, 0, 0, 2, 2, 1, 1,
    4, 4, 4, 2, 2, 2, 2, 2, 4, 2, 0, 0, 0, 4, 0, 0
};

CMD:gipv(playerid, params[])
{
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000FF, "{9ACD32}[INFO]: {FFFFFF}/gipv [name/id]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "Player not found.");
    if(!IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000FF, "Player is not in any vehicle.");
    if(!GetAvailableSeats(GetPlayerVehicleID(id))) return SendClientMessage(playerid, 0xFF0000FF, "This player's vehicle cannot seat any more players.");
    PutPlayerInVehicle(playerid, GetPlayerVehicleID(id), GetNextSeat(GetPlayerVehicleID(id)));
    SendClientMessage(playerid, 0xFFFF00FF, "You have teleported into the player's vehicle.");
    return 1;
}

stock GetAvailableSeats(vehicleid)
{
    new maxseats = MaxVehicleSeats[(GetVehicleModel(vehicleid) - 400)];
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            if(maxseats <= 0) break;
            maxseats--;
        }
    }
    return maxseats;
}

stock GetNextSeat(vehicleid)
{
    new available;
    new seat[10];
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            seat[GetPlayerVehicleSeat(i)] = 1;
        }
    }
    for(new v = 0; v < MaxVehicleSeats[GetVehicleModel(vehicleid) - 400]; v++)
    {
        if(seat[v] == 1) continue;
        available = v;
    }
    return available;
}
NOTE: This requires the following includes:
- ZCMD (By ZeeX)
- Foreach (By ******)
- a_samp (By The SA-MP Team)
- sscanf2 (By ******)
Reply


Messages In This Thread
Get in Player Vehicle [PROBLEM] - by AwokenNeoX - 01.03.2014, 12:01
Re: Get in Player Vehicle [PROBLEM] - by PrivatioBoni - 01.03.2014, 13:12
Re: Get in Player Vehicle [PROBLEM] - by BroZeus - 01.03.2014, 13:14
Re: Get in Player Vehicle [PROBLEM] - by Threshold - 01.03.2014, 15:29

Forum Jump:


Users browsing this thread: 2 Guest(s)