Putting car in cargobob not working - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Putting car in cargobob not working (
/showthread.php?tid=614315)
Putting car in cargobob not working -
GunZsmd - 07.08.2016
Hi guys,
So i made a system to put some cars in any cargobob but it doesnt find any near cargobobs and im right next to one. Can anyone check whats going wrong?
PHP Code:
if(strcmp(cmd, "/porcarroheli", true) == 0)
{
if(IsPlayerConnected(playerid))
{
for(new i=0;i<MAX_VEHICLES;i++)
{
if(DynamicCars[i][CarModel] == 548)
{
new Float:CX,Float:CY,Float:CZ;
GetVehiclePos(i, CX,CY,CZ);
new string2[128];
format(string2,sizeof(string2), "%d", i);
SendClientMessage(playerid, COLOR_GREEN, string2);
if(PlayerToPoint(15.0,playerid, CX, CY, CZ))
{
if(PlayerInfo[playerid][pChave1] == i || PlayerInfo[playerid][pChave2] == i || PlayerInfo[playerid][pChave3] == i || PlayerInfo[playerid][pChave4] == i || PlayerInfo[playerid][pChave5] == i || PlayerInfo[playerid][pChave6] == i)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsValidModel(GetVehicleModel(GetPlayerVehicleID(playerid))))
{
if(DynamicCars[i][cTransporte] == 0)
{
DynamicCars[i][cTransporte] = GetPlayerVehicleID(playerid);
new car = GetPlayerVehicleID(playerid);
DynamicCars[car][CarX] = 0;
DynamicCars[car][CarY] = 0;
DynamicCars[car][CarZ] = 0;
DynamicCars[car][CarAngle] = 0;
DynamicCars[car][Interior] = 0;
DynamicCars[car][World] = 0;
DestroyVehicle(car);
CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
SaveDynamicCars();
SendClientMessage(playerid, COLOR_GREEN, "[Info] Colocaste um veiculo no helicoptero! Para o removeres entra no helicoptero e faz /tirarcarroheli.");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Este helicoptero ja contem um veiculo! Remove-o primeiro para colocares outro!");
return 1;
}
}
else
{
SendClientMessage(playerid,COLOR_RED, "Erro: Nao podes colocar este veiculo no helicoptero!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Nao estas em nenhum veiculo!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Este helicoptero nao te pertence!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Nao te encontras perto de nenhum helicoptero!");
return 1;
}
}
}
return 1;
}
}
Re: Putting car in cargobob not working -
Jefff - 07.08.2016
You can't have return in loop because it stops at ID 0
pawn Code:
if(strcmp(cmd, "/porcarroheli", true) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, COLOR_RED, "Erro: Nao estas em nenhum veiculo!");
else if(!IsValidModel(GetVehicleModel(GetPlayerVehicleID(playerid)))) SendClientMessage(playerid,COLOR_RED, "Erro: Nao podes colocar este veiculo no helicoptero!");
else
{
new helicoptero_id;
new Float:CX,Float:CY,Float:CZ;
for(new i=1; i < MAX_VEHICLES; i++)
{
if(DynamicCars[i][CarModel] == 548)
{
GetVehiclePos(i,CX,CY,CZ);
new string2[5];
valstr(string2,i);
SendClientMessage(playerid, COLOR_GREEN, string2);
if(PlayerToPoint(15.0,playerid,CX, CY, CZ))
{
helicoptero_id = i;
break;
}
}
}
if(!helicoptero_id) SendClientMessage(playerid, COLOR_RED, "Erro: Nao te encontras perto de nenhum helicoptero!");
else
{
new v = helicoptero_id;
if(PlayerInfo[playerid][pChave1] == v || PlayerInfo[playerid][pChave2] == v || PlayerInfo[playerid][pChave3] == v || PlayerInfo[playerid][pChave4] == v || PlayerInfo[playerid][pChave5] == v || PlayerInfo[playerid][pChave6] == v)
{
if(DynamicCars[v][cTransporte] == 0)
{
new car = DynamicCars[v][cTransporte] = GetPlayerVehicleID(playerid);
DynamicCars[car][CarX] = DynamicCars[car][CarY] = DynamicCars[car][CarZ] = 0;
DynamicCars[car][CarAngle] = DynamicCars[car][Interior] = DynamicCars[car][World] = 0;
DestroyVehicle(car);
CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
SaveDynamicCars();
SendClientMessage(playerid, COLOR_GREEN, "[Info] Colocaste um veiculo no helicoptero! Para o removeres entra no helicoptero e faz /tirarcarroheli.");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Este helicoptero ja contem um veiculo! Remove-o primeiro para colocares outro!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Erro: Este helicoptero nao te pertence!");
}
}
}
return 1;
}