[Ajuda] /destruirid e /repararid ( em carros criados) Buga
#1

Pawn de /veh

pawn Code:
if(strcmp(cmd, "/veh", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 1337)
            {
                if(CreatedCar >= 100)
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "Jб criaram muitos carros, destrua alguns primeiro /destruirid");
                    return true;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /veh [IDCARRO] [COR1] [COR2]");
                    return true;
                }
                new car;
                car = strval(tmp);
                if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "   Modelo Do Carro Tem Que Ser Entre 411 e 600 !"); return true; }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /veh [IDCARRO] [COR1] [COR2]");
                    return true;
                }
                new COLOR1;
                COLOR1 = strval(tmp);
                if(COLOR1 < 0 || COLOR1 > 236) { SendClientMessage(playerid, COLOR_GREY, "   Nъmero Da Cor tem que ser entre 0 e 126 !"); return true; }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /veh [IDCARRO] [COR1] [COR2]");
                    return true;
                }
                new COLOR2;
                COLOR2 = strval(tmp);
                if(COLOR2 < 0 || COLOR2 > 236) { SendClientMessage(playerid, COLOR_GREY, "   Nъmero Da Cor tem que ser entre 0 e 126 !"); return true; }
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(playerid, X,Y,Z);
                new carid = CreateVehicle(car, X,Y+2,Z, 0.0, COLOR1, COLOR2, 60000);
                new mot, lu, alar, por, cap, porma, ob;
                //new carro = GetPlayerVehicleID(playerid);
                CreatedCars[CreatedCar] = carid;
                CreatedCar ++;
                GetVehicleParamsEx(carid, mot, lu, alar, por, cap, porma, ob);
                SetVehicleParamsEx(carid, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
                format(string, sizeof(string), "   Veiculo %d Criado.", carid);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
        }
        return true;
    }
Pawn do /destruirid

pawn Code:
if(!strcmp("/destruirid", cmdtext, true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 3)
            {
                MSGPLAYER(playerid, COLOR_GRAD1, "   Vocк nгo estб autorizado a usar este comando !");
                return 1;
            }
            if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341)
            {
                MSGPLAYER(playerid, COLOR_GRAD1, "Vocк nгo estб trabalhando! (/trabalhar)");
                return 1;
            }
            new counter = 0;
            new result;
            new plyName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
            for(new i; i != MAX_VEHICLES; i++)
            {
                new dist = ChecarveiculoThiago(5, playerid, i);
                if(dist)
                {
                    result = i;
                    counter++;
                }
            }
            switch(counter)
            {
                case 0:
                {
                    MSGPLAYER(playerid, COLOR_GREY, "   Nгo hб nenhum carro nesse raio!");
                }
                case 1:
                {
                    if(result < CAR_AMOUNT)
                    {
                        MSGPLAYER(playerid, COLOR_GREY, "Vocк sу pode destruir veнculos criados");
                        return 1;
                    }
                    new name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    DestroyVehicle(result);
                    format(string, sizeof(string), "Vocк destruiu o veнculo ID:[%d]", result);
                    MSGPLAYER(playerid, COLOR_GREY, string);
                    if(admtrampando[playerid] == 1 && admhide[playerid] == 1)
                    {
                        format(string, sizeof(string), "AdmAviso: Carro ID:[%d] foi destruido Por: Boot_Server", result);
                        ABroadCast(COLOR_YELLOW,string,1);
                    }
                    else
                    {
                        format(string, sizeof(string), "AdmAviso: Carro ID:[%d] foi destruido Por: %s", result, name);
                        ABroadCast(COLOR_YELLOW,string,1);
                    }
                }
                default:
                {
                    MSGPLAYER(playerid, COLOR_GREY, "   Foram encontrados mais de um carro nesse raio");
                }
            }
        }
        return 1;
    }
Pawn do /repararid

pawn Code:
if(!strcmp("/rcarro", cmdtext, true) || !strcmp("/repararid", cmdtext, true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 3)
            {
                MSGPLAYER(playerid, COLOR_GRAD1, "   Vocк nгo estб autorizado a usar este comando !");
                return 1;
            }
            if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341)
            {
                MSGPLAYER(playerid, COLOR_GRAD1, "Vocк nгo estб trabalhando! (/trabalhar)");
                return 1;
            }
            new counter = 0;
            new result;
            new plyName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
            for(new i; i != MAX_VEHICLES; i++)
            {
                new dist = ChecarveiculoThiago(5, playerid, i);
                if(dist)
                {
                    result = i;
                    counter++;
                }
            }
            switch(counter)
            {
                case 0:
                {
                    MSGPLAYER(playerid, COLOR_GREY, "   Nгo hб nenhum carro nesse raio!");
                }
                case 1:
                {
                    new name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    format(string, sizeof(string), "Vocк reparou o carro ID:[%d]", result);
                    MSGPLAYER(playerid, COLOR_GREY, string);
                    if(admtrampando[playerid] == 1 && admhide[playerid] == 1)
                    {
                        format(string, sizeof(string), "AdmAviso: Carro ID:[%d] foi reparado Por: Boot_Server", result);
                        ABroadCast(COLOR_YELLOW,string,1);
                    }
                    else
                    {
                        format(string, sizeof(string), "AdmAviso: Carro ID:[%d] foi reparado Por: %s", result, name);
                        ABroadCast(COLOR_YELLOW,string,1);
                    }
                    RepairVehicle(result);
                }
                default:
                {
                    MSGPLAYER(playerid, COLOR_GREY, "   Foram encontrados mais de um carro nesse raio");
                }
            }
        }
        return 1;
    }

O BUG Й QUE QUANDO DIGITA /REPARARID ( EM CARROS CRIADOS ) DA QUE NГO TEM CARRO NESSE RAIO O MESMO COM O /DESTRUIRID
Reply
#2

A Define CAR_AMOUNT estб mais alta do que a quantidade de veнculos exato do servidor.
Reply
#3

E como Ajeito isso ?
Reply
#4

e Como ajeito isso ?
Reply
#5

Teria que saber a a quantidade de veiculos exatos do servidor e por nela.
Reply
#6

E como vou ficar sabendo a quantidade exata do servidor ?
Reply
#7

Contando e.e
Reply
#8

faz um loop, contando, й facil.

EDIT:

Escreva no inicio do script
PHP Code:
native IsValidVehicle(vehicleid); 
E depois no crie um comando pra contar carros colocando isso:
PHP Code:
new count=0;
    for(new 
vehicleid=0vehicleid MAX_VEHICLESvehicleid++)
    {
        if(
IsValidVehicle(vehicleid))
        {
            
count++;
        }
    }
    new 
cstring[128];
    
format(cstringsizeof(cstring), "Carros no servidor: %i || Maximo de carros permitido: %i || Quantos carros ainda podem ser adicionados: %i"countMAX_VEHICLESMAX_VEHICLES count);
    
SendClientMessage(playerid0x00FF00FFcstring);
    return 
1
Reply
#9

Quando vocк inicia um servidor caseiro aparece:
Number of vehicles models : (QUANTIA).

Sу pega essa quantia e definir "Define CAR_AMOUNT".
Reply
#10

Quote:
Originally Posted by davi54723
View Post
Quando vocк inicia um servidor caseiro aparece:
Number of vehicles models : (QUANTIA).

Sу pega essa quantia e definir "Define CAR_AMOUNT".

Number of vehicles models й o numero de modelos de veнculos existentes no servidor e nгo a quantia de veнculos.
Reply
#11

Quote:
Originally Posted by tonisantolia
View Post
Number of vehicles models й o numero de modelos de veнculos existentes no servidor e nгo a quantia de veнculos.
Use o loop ali que eu postei, tem atй um desses no samp-wiki
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)