Stock function.
#1

Hey,
I was trying to make a command as such so I can determine the seat number of each vehicle and then working out weather there is a free seat. Heres the car seat max

pawn Код:
new VehicleSeats[] =
{
    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,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
    1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
    4,2,2,1,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,500,500,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,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
    1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0
};

And heres my stock.

pawn Код:
stock GetEmptySeat(vehicleid)
{
    new bool:taken[4], Model = GetVehicleModel(vehicleid);
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            for(new j = 0; j < sizeof(VehicleSeats[Model - 400]); j++) //error line
            {
                if(GetPlayerVehicleSeat(i) == j) Taken[j] = true;
            }
            for(new k = 0; k < sizeof(Taken); k++)
            {
                if(Taken[k] == false) return 0;
            }
        }
    }
    return 1;
}
I get these errors when I compile it.

pawn Код:
(143) : error 080: unknown symbol, or not a constant symbol (symbol "Model")
(143) : error 036: empty statement
(143) : error 017: undefined symbol "j"
(143) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Can anyone help me solve these, Thanks.
Reply
#2

if(Taken[k] == false) return 0;
Reply
#3

There is multiple functions but not one that knows the seat numbers. THis way I can loop through 2 seats if they are taken I can spawn the player near the car instead.
Reply
#4

I am modifying one im modifying the one by IceCube.... Link: https://sampforum.blast.hk/showthread.php?tid=285764
Reply
#5

BUMP
Reply
#6

What is the awnser you exactly expect?
Reply
#7

Try new Model = GetVehicleModel(vehicleid)-400;
Reply
#8

Quote:
Originally Posted by milanosie
Посмотреть сообщение
What is the awnser you exactly expect?
Clearly I want an answer to give me a way of taking the 400 from the model and putting it in the code...

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
Try new Model = GetVehicleModel(vehicleid)-400;
Learn Pawno this will either return an error or make no differnce what so ever.
Reply
#9

pawn Код:
stock GetEmptySeat(vehicleid)
{
    new bool:taken[4], Model = GetVehicleModel(vehicleid);
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            for(new j = 0; j < VehicleSeats[Model-400]; j++)
            {
                if(GetPlayerVehicleSeat(i) == j) Taken[j] = true;
            }
            for(new k = 0; k < sizeof(Taken); k++)
            {
                if(Taken[k] == false) return 0;
            }
        }
    }
    return 1;
}
Reply
#10

@UP
returns only 0 or 1? ehm


My version
pawn Код:
new VehicleSeats[] =
{
    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,500,1,2,2,0,2,500,4,2,4,1,2,2,2,4,1,2,
    1,0,0,2,1,1,1,2,2,2,4,4,2,2,2,2,1,1,4,4,2,2,4,2,1,1,2,2,1,2,2,4,2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,
    4,2,2,1,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,500,500,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,1,2,4,4,2,4,1,0,4,2,2,2,2,0,0,500,2,2,
    1,4,4,4,2,2,2,2,2,4,2,0,0,0,4,0,0
};
#define INVALID_SEAT_ID     999
stock GetEmptySeat(vehicleid)
{
    new bool:Taken[4],Seat,Seats; // [4] ?
    Seats = VehicleSeats[GetVehicleModel(vehicleid)-400];
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, vehicleid))
        {
            Seat = GetPlayerVehicleSeat(i);
            Taken[(Seat > 3) ? 3 : Seat] = true;
        }
    }
    for(new d; d < Seats; d++)
        if(!Taken[d])
            return d;
    return INVALID_SEAT_ID;
}
Usage
pawn Код:
new FreeSlot = GetEmptySeat(vehicleid);
if(FreeSlot == INVALID_SEAT_ID) return SendClientMessage(playerid,-1,"Vehicle is full");
PutPlayerInVehicle(playerid,vehicleid,FreeSlot);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)