IsVehicleOccupied -
Syxh0wN - 25.11.2018
Olб abigos, to com um probleminha aqui, podem me ajudar?
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
new slot = SlotCar(vehicleid);
if(slot > 0)
{
for(new i; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i)) continue;
if(VehicleInfo[vehicleid][vVehicle] == vehicleid) return 1;
}
}
else
{
for(new i; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i)) continue;
if(GetPlayerVehicleID(i) == vehicleid) return 1;
}
}
return 0;
}
if(!IsVehicleOccupied(VehicleInfo[437][vVehicle]))
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PutPlayerInVehicle(playerid, VehicleInfo[437][vVehicle], 0);
SetPlayerRaceCheckpoint(playerid, 0, -2035.1129,-72.9383,34.8887, -2004.5264,-38.5044,34.8705, 3.5);
}
else
{
if(!IsVehicleOccupied(VehicleInfo[438][vVehicle]))
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PutPlayerInVehicle(playerid, VehicleInfo[437][vVehicle], 0);
SetPlayerRaceCheckpoint(playerid, 0, -2035.1129,-72.9383,34.8887, -2004.5264,-38.5044,34.8705, 3.5);
}
else
{
if(!IsVehicleOccupied(VehicleInfo[439][vVehicle]))
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PutPlayerInVehicle(playerid, VehicleInfo[437][vVehicle], 0);
SetPlayerRaceCheckpoint(playerid, 0, -2035.1129,-72.9383,34.8887, -2004.5264,-38.5044,34.8705, 3.5);
}
else return SendClientMessage(playerid, -1, "* Desculpe, todos os nossos veнculos jб estгo sendo utilizados");
}
}
Oque aconte й que quando o player 2 vai escolher a mesma categoria de habilitaзгo, da que os dois estгo no mesmo veнculo, mas um nгo vк o outro, percebi porque quando o player 1 estб parado, e o player 2 estб andando,
o velocimetro do player 1 aumenta de acordo com o do player 2. Coloquei um cmd tbm pra pegar o ID do veнculo que eles estгo e sгo os mesmo.
Re: IsVehicleOccupied -
JeffSantos2 - 26.11.2018
Olб, eu sugiro que vocк faзa assim o cуdigo:
Код:
stock IsVehicleOccupied(vehicleid)
{
for(new i; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid)) return true;
}
return false;
}
for(new id = 437; id <= 439; i++)
{
if(!IsVehicleOccupied(VehicleInfo[id][vVehicle]))
{
SetVehicleToRespawn(VehicleInfo[id][vVehicle]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PutPlayerInVehicle(playerid, VehicleInfo[id][vVehicle], 0);
SetPlayerRaceCheckpoint(playerid, 0, -2035.1129,-72.9383,34.8887, -2004.5264,-38.5044,34.8705, 3.5);
}
}
Mas caso queira apenas corrigir o seu ali, o erro provбvel esta em aqui у:
Код:
if(!IsVehicleOccupied(VehicleInfo[438][vVehicle]))
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
PutPlayerInVehicle(playerid, VehicleInfo[437][vVehicle], 0); //note que aqui esta VehicleInfo[437], mas a verificaзгo й se o 438 estб ocupado
SetPlayerRaceCheckpoint(playerid, 0, -2035.1129,-72.9383,34.8887, -2004.5264,-38.5044,34.8705, 3.5);
}
Mesma coisa no 439
Teste o jeito que vocк achar melhor