Stock function. -
SpankMe2 - 18.01.2012
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.
Re: Stock function. -
Psymetrix - 18.01.2012
if(Taken[k] == false) return 0;
Re: Stock function. -
SpankMe2 - 18.01.2012
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.
Re: Stock function. -
SpankMe2 - 18.01.2012
I am modifying one im modifying the one by IceCube.... Link:
https://sampforum.blast.hk/showthread.php?tid=285764
Re: Stock function. -
SpankMe2 - 19.01.2012
BUMP
Re: Stock function. -
milanosie - 19.01.2012
What is the awnser you exactly expect?
Re: Stock function. -
[ABK]Antonio - 19.01.2012
Try new Model = GetVehicleModel(vehicleid)-400;
Re: Stock function. -
SpankMe2 - 19.01.2012
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.
Respuesta: Stock function. -
OPremium - 19.01.2012
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;
}
Re: Stock function. -
Jefff - 19.01.2012
@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);