Putting car in cargobob not working
#1

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(iCX,CY,CZ);
                    new 
string2[128];
                    
format(string2,sizeof(string2), "%d"i);
                    
SendClientMessage(playeridCOLOR_GREENstring2);
                        if(
PlayerToPoint(15.0,playeridCXCYCZ))
                        {
                            if(
PlayerInfo[playerid][pChave1] == || PlayerInfo[playerid][pChave2] == || PlayerInfo[playerid][pChave3] == || PlayerInfo[playerid][pChave4] == || PlayerInfo[playerid][pChave5] == || 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(playeridCOLOR_GREEN"[Info] Colocaste um veiculo no helicoptero! Para o removeres entra no helicoptero e faz /tirarcarroheli.");
                                        }
                                        else
                                        {
                                        
SendClientMessage(playeridCOLOR_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(playeridCOLOR_RED"Erro: Nao estas em nenhum veiculo!");
                                return 
1;
                                }
                            }
                            else
                            {
                            
SendClientMessage(playeridCOLOR_RED"Erro: Este helicoptero nao te pertence!");
                            return 
1;
                            }
                        }
                        else
                        {
                        
SendClientMessage(playeridCOLOR_RED"Erro: Nao te encontras perto de nenhum helicoptero!");
                        return 
1;
                        }
                    }
                }
                return 
1;
            }
        } 
Reply
#2

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)