[Ajuda]Carro org
#1

Boa tarde, utilizo o sistema criado pelo Josma_cmd para proteger os carros de determinadas profissхes. Sу que apenas alguns carros estгo sendo protegidos, os outros qualquer um com qualquer profissгo podem pegar. A seguir o cуdigo:

PHP код:
forward VerificarVeiculo(playerid); 
public 
VerificarVeiculo(playerid

    for(new 
0<= 77c++) 
    { 
        if(
IsPlayerInVehicle(playeridVPolicia[c]) && PlayerInfo[playerid][Emprego] < POLICIA
        { 
            
SendClientMessage(playeridRED"Vocк nгo й um Policial!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVMedicos[c]) && PlayerInfo[playerid][Emprego] < MEDICO
        { 
            
SendClientMessage(playeridRED"Vocк nгo й Mйdico!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVPCivil[c]) && PlayerInfo[playerid][Emprego] < POLICIACIVIL
        { 
            
SendClientMessage(playeridRED"Vocк nгo й Policial Civil!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVExercito[c]) && PlayerInfo[playerid][Emprego] < EXERCITO
        { 
            
SendClientMessage(playeridRED"Vocк nгo й um Soldado!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVMotoristas[c]) && PlayerInfo[playerid][Emprego] < MOTORISTA
        { 
            
SendClientMessage(playeridRED"Vocк nгo й Motorista!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVTaxi[c]) && PlayerInfo[playerid][Emprego] < TAXISTA
        { 
            
SendClientMessage(playeridRED"Vocк nгo й Taxista!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
        if(
IsPlayerInVehicle(playeridVMecanicos[c]) && PlayerInfo[playerid][Emprego] < MECANICO
        { 
            
SendClientMessage(playeridRED"Vocк nгo й Mecвnico!"); 
            
RemovePlayerFromVehicle(playerid); 
            return 
1
        } 
    } 
    return 
1

public 
OnPlayerStateChange(playeridnewstateoldstate

    if(
newstate == PLAYER_STATE_DRIVERVerificarVeiculo(playerid); 
    return 
1

Variбveis e os veнculos:

PHP код:
new VPolicia[25]; 
new 
VMotoristas[14]; 
new 
VTaxi[10]; 
new 
VPCivil[14]; 
new 
VExercito[10]; 
new 
VMecanicos[8]; 
new 
VMedicos[4]; 
//------------------------------------------------------------------------------ 
VPolicia[0] = CreateVehicle(596,1600.986,-1695.992,5.711,270.0,1,0,0); 
VPolicia[1] = CreateVehicle(596,1584.231,-1667.675,5.713,89.0,1,0,0); 
VPolicia[2] = CreateVehicle(596,1584.464,-1671.687,5.713,89.0,1,0,0); 
VPolicia[3] = CreateVehicle(596,1601.041,-1684.020,5.711,270.0,1,0,0); 
VPolicia[4] = CreateVehicle(596,1601.030,-1687.798,5.711,270.0,1,0,0); 
VPolicia[5] = CreateVehicle(596,1601.080,-1691.872,5.711,270.0,1,0,0); 
VPolicia[6] = CreateVehicle(596,1601.250,-1700.203,5.711,270.0,1,0,0); 
VPolicia[7] = CreateVehicle(596,1601.299,-1704.329,5.711,270.0,1,0,0); 
VPolicia[8] = CreateVehicle(599,1595.394,-1710.482,6.276,179.0,0,1,0); 
VPolicia[9] = CreateVehicle(599,1591.495,-1710.480,6.276,179.0,0,1,0); 
VPolicia[10] = CreateVehicle(599,1587.474,-1710.465,6.276,179.0,0,1,0); 
VPolicia[11] = CreateVehicle(599,1583.421,-1710.407,6.276,179.0,0,1,0); 
VPolicia[12] = CreateVehicle(599,1578.599,-1710.413,6.276,179.0,0,1,0); 
VPolicia[13] = CreateVehicle(599,1574.638,-1710.466,6.276,179.0,0,1,0); 
VPolicia[14] = CreateVehicle(599,1570.481,-1710.494,6.276,179.0,0,1,0); 
VPolicia[15] = CreateVehicle(427,1545.282,-1684.328,6.139,271.0,0,1,0); 
VPolicia[16] = CreateVehicle(427,1545.144,-1680.314,6.139,271.0,0,1,0); 
VPolicia[17] = CreateVehicle(427,1545.086,-1676.321,6.139,271.0,0,1,0); 
VPolicia[18] = CreateVehicle(427,1545.161,-1672.018,6.139,271.0,0,1,0); 
VPolicia[19] = CreateVehicle(427,1545.023,-1667.918,6.139,271.0,0,1,0); 
VPolicia[20] = CreateVehicle(427,1544.891,-1663.079,6.139,271.0,0,1,0); 
VPolicia[21] = CreateVehicle(427,1544.838,-1659.169,6.139,271.0,0,1,0); 
VPolicia[22] = CreateVehicle(427,1544.853,-1654.959,6.139,271.0,0,1,0); 
VPolicia[23] = CreateVehicle(427,1544.698,-1651.034,6.139,271.0,0,1,0); 
VMedicos[0] = CreateVehicle(487,2032.265,-1437.753,17.443,0.0,1,3,0); 
VMedicos[1] = CreateVehicle(416,2015.717,-1411.519,17.292,90.0,1,3,0); 
VMedicos[2] = CreateVehicle(416,2007.567,-1411.484,17.292,90.0,1,3,0); 
//------------------------------------------------------------------------------ 
VMotoristas[0] = CreateVehicle(431,1778.5635,-1932.6882,13.4773,271.2094,75,59,0); // CAR BUS 35 
VMotoristas[1] = CreateVehicle(431,1801.9137,-1932.2784,13.4853,270.9595,75,59,0); // CAR BUS 36 
VMotoristas[2] = CreateVehicle(431,1801.8395,-1927.6409,13.8785,270.9595,75,59,0); // CAR BUS 37 
VMotoristas[3] = CreateVehicle(431,1801.7214,-1920.3905,14.2732,270.9595,75,59,0); // CAR BUS 38 
VMotoristas[4] = CreateVehicle(431,1801.6460,-1916.1437,13.7640,270.9595,75,59,0); // CAR BUS 39 
VMotoristas[5] = CreateVehicle(431,1801.5204,-1908.1831,14.6722,270.9595,75,59,0); // CAR BUS 40 
VMotoristas[6] = CreateVehicle(431,1801.4320,-1901.8870,16.6537,270.9595,75,59,0); // CAR BUS 41 
VMotoristas[7] = CreateVehicle(431,1778.5748,-1887.7195,13.4955,270.9589,75,59,0); // CAR BUS 42 
VMotoristas[8] = CreateVehicle(431,1778.6583,-1892.6221,13.7154,270.9589,75,59,0); // CAR BUS 43 
VMotoristas[9] = CreateVehicle(431,1778.6969,-1894.8433,13.9352,270.9589,75,59,0); // CAR BUS 44 
VMotoristas[10] = CreateVehicle(431,1778.7831,-1899.9912,13.9351,270.9589,75,59,0); // CAR BUS 45 
VMotoristas[11] = CreateVehicle(431,1778.8674,-1904.9474,14.1548,270.9589,75,59,0); // CAR BUS 46 
VTaxi[0] = CreateVehicle(420,2348.3257,-1216.8136,22.2818,91.7268,6,1,0); // CAR TAXI 62 
VTaxi[1] = CreateVehicle(420,2348.4399,-1220.6471,22.5018,91.7268,6,1,0); // CAR TAXI 63 
VTaxi[2] = CreateVehicle(420,2348.5952,-1225.7711,22.3035,91.7268,6,1,0); // CAR TAXI  64 
VTaxi[3] = CreateVehicle(420,2349.0576,-1236.5712,23.1585,91.7898,6,1,0); // CAR TAXI  65 
VTaxi[4] = CreateVehicle(420,2346.5806,-1247.1989,23.3629,91.7898,6,1,0); // CAR TAXI  66 
VTaxi[5] = CreateVehicle(420,2346.8591,-1256.1066,23.3604,91.7898,6,1,0); // CAR TAXI 67 
VTaxi[6] = CreateVehicle(420,2326.6223,-1255.0775,24.4659,91.7898,6,1,0); // CAR TAXI 68 
VTaxi[7] = CreateVehicle(420,2327.3557,-1245.4520,22.5201,91.7898,6,1,0); // CAR TAXI 69 
VTaxi[8] = CreateVehicle(420,2327.2222,-1234.2198,23.1826,91.7898,6,1,0); // CAR TAXI 70 
VPCivil[0] = CreateVehicle(599,612.2184,-601.9387,17.4199,270.3361,0,0,0); // POLICIA CIVIL 71 
VPCivil[1] = CreateVehicle(599,641.2914,-609.5253,16.5255,358.7163,0,0,0); // POLICIA CIVIL 72 
VPCivil[2] = CreateVehicle(599,635.5573,-609.3969,16.5240,358.7161,0,0,0); // POLICIA CIVIL  73 
VPCivil[3] = CreateVehicle(599,626.9663,-609.2063,16.7428,358.7161,0,0,0); // POLICIA CIVIL 74 
VPCivil[4] = CreateVehicle(599,621.1761,-609.0725,17.4377,358.6588,0,0,0); // POLICIA CIVIL 75 
VPCivil[5] = CreateVehicle(599,611.1563,-591.2136,17.4200,268.2535,0,0,0); // POLICIA CIVIL 76 
VPCivil[6] = CreateVehicle(599,611.3029,-586.4069,17.4032,268.2578,0,0,0); // POLICIA CIVIL 77 
VPCivil[7] = CreateVehicle(523,609.4646,-592.6144,17.4830,88.5419,0,0,0); // POLICIA CIVIL 78 
VPCivil[8] = CreateVehicle(523,609.5167,-590.0276,17.7276,88.5418,0,0,0); // POLICIA CIVIL 79 
VPCivil[9] = CreateVehicle(523,615.4717,-609.8049,16.7818,179.7153,0,0,0); // POLICIA CIVIL 80 
VPCivil[10] = CreateVehicle(523,612.6893,-609.7911,16.7818,179.7152,0,0,0); // POLICIA CIVIL  81 
VPCivil[11] = CreateVehicle(523,610.8326,-609.7819,16.7818,179.7152,0,0,0); // POLICIA CIVIL 82 
VPCivil[12] = CreateVehicle(523,607.8777,-609.7672,16.7818,179.7152,0,0,0); // POLICIA CIVIL 83 
VMecanicos[0] = CreateVehicle(525,2510.0513,-1471.7223,23.7425,272.2389,32,8,0); // Carro Mecвnicos 84 
VMecanicos[1] = CreateVehicle(525,2509.8628,-1466.5664,23.7444,269.9965,32,8,0); // Carro Mecвnicos 85 
VMecanicos[2] = CreateVehicle(525,2537.4363,-1449.8331,23.7100,180.4893,32,8,0); // Carro Mecвnicos 86 
VMecanicos[3] = CreateVehicle(525,2525.0835,-1458.7998,23.6599,91.6055,32,8,0); // Carro Mecвnicos 87 
VMecanicos[4] = CreateVehicle(525,2512.3074,-1456.0919,23.6820,89.4558,32,8,0); // Carro Mecвnicos 88 
VMecanicos[5] = CreateVehicle(525,2499.4614,-1463.3643,23.7448,269.6478,32,8,0); // Carro Mecвnicos 89 
VMecanicos[6] = CreateVehicle(525,2474.2190,-1463.2863,23.7292,270.5597,32,8,0); // Carro Mecвnicos 90 
VExercito[0] = CreateVehicle(520,301.6661,2007.4637,18.8050,4.1775,0,0,0); // Carro EXERCITO 91 
VExercito[1] = CreateVehicle(520,304.4239,1976.6892,18.7670,4.2973,0,0,0); //Carro EXERCITO 92 
VExercito[2] = CreateVehicle(432,279.0942,1956.4875,17.6525,270.5890,43,0,0); //Carro EXERCITO 93 
VExercito[3] = CreateVehicle(432,277.3454,1989.5237,17.6524,267.6175,43,0,0); //Carro EXERCITO 94 
VExercito[4] = CreateVehicle(432,279.2259,2022.6987,17.6561,270.5171,43,0,0); //Carro EXERCITO 95 
VExercito[5] = CreateVehicle(470,320.3241,1884.7653,17.6729,179.7270,43,0,0); //Carro EXERCITO 96 
VExercito[6] = CreateVehicle(470,320.2679,1872.8568,17.6325,179.7293,43,0,0); //Carro EXERCITO 97 
VExercito[7] = CreateVehicle(470,320.2195,1862.6141,17.6340,179.7300,43,0,0); //Carro EXERCITO 98 
VExercito[8] = CreateVehicle(470,320.2019,1858.8929,17.6329,179.7301,43,0,0); //Carro EXERCITO 99 
Desde jб agradeзo!
Reply
#2

Tente usando esse exemplo:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        for(new i = 0; i < sizeof(VPolicia); i++)
        {
            if(vid  == VPolicia[i])
            {
                if(PlayerInfo[playerid][Emprego] != POLICIA_MILITAR)
                {
                    SendClientMessage(playerid,-1,"Voce nгo й da policia militar.");
                    RemovePlayerFromVehicle(playerid);
                    TogglePlayerControllable(playerid, 1);
                }
            }
        }
    }
    return 1;
}
Ou:
Em vez de usar assim:
pawn Код:
PlayerInfo[playerid][Emprego] < POLICIA
Vocк usa assim:
pawn Код:
PlayerInfo[playerid][Emprego] != POLICIA
!= й diferente
< menor
ou seja, usando < se a profissгo do player for um ID maior que o ID da policia irб poder pegar. Entгo todos < desse cуdigo vocк troca por !=
Reply
#3

Nгo funcionou :/. Alterei o "<" para "!=" e apenas alguns veнculos estгo protegidos :/
Tentei pelo OnPlayerStateChange tambйm mas deu erro na hora de compilar(Vбrios erros em outras linhas nada haver)
Reply
#4

Deixa sua public como comentбrio (coloque /* no inicio da public e */ no final) e teste com essa:
pawn Код:
public VerificarVeiculo(playerid)
{
    for(new c = 0; c < sizeof(VPolicia); c++)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vid = GetPlayerVehicleID(playerid);
            if(vid == VPolicia[c] && PlayerInfo[playerid][Emprego] != POLICIA)
            {
                SendClientMessage(playerid, RED, "Vocк nгo й um Policial!");
                RemovePlayerFromVehicle(playerid);
                return 1;
            }
        }
    }
    return 1;
}
So fiz com os carro da policia, entгo teste nele, se der certo segue o exemplo do cуdigo, se nгo der avisa!
Reply
#5

Tenta aк

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        for(new i = 0; i < sizeof(VPolicia); i++)
        {
            if(vid  == VPolicia[i])
            {
                if(PlayerInfo[playerid][Emprego] == POLICIA_MILITAR) {
                } else {
                    SendClientMessage(playerid,-1,"Voce nгo й da policia militar.");
                    RemovePlayerFromVehicle(playerid);
                    TogglePlayerControllable(playerid, 1);
                }
            }
        }
    }
    return 1;
}
Reply
#6

Deu a mesma coisa, apenas alguns carros estгo protegidos :/

E um Warning:

PHP код:
E:\SA-MP\Servidores\PF\gamemodes\Master[RPG].pwn(4510) : warning 235: public function lacks forward declaration (symbol "VerificarVeiculo")
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Warning

Reply
#7

Desta forma funcionou em todos os veнculos:

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVERVerificarVeiculo(playerid);
    return 
1;
}
public 
VerificarVeiculo(playerid)
{
    for(new 
0sizeof(VPolicia); c++)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            new 
vid GetPlayerVehicleID(playerid);
            if(
vid == VPolicia[c] && PlayerInfo[playerid][Emprego] != POLICIA)
            {
                
SendClientMessage(playeridRED"Vocк nгo й um Policial!");
                
RemovePlayerFromVehicle(playerid);
                return 
1;
            }
        }
    }
    for(new 
0sizeof(VMedicos); c++)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            new 
vid GetPlayerVehicleID(playerid);
            if(
vid == VMedicos[c] && PlayerInfo[playerid][Emprego] != MEDICO)
            {
                
SendClientMessage(playeridRED"Vocк nгo й um Mйdico!");
                
RemovePlayerFromVehicle(playerid);
                return 
1;
            }
        }
    }
    return 
1;

rep ++ para vocкs, sу que tem um warning na hora de compilar:
PHP код:
E:\SA-MP\Servidores\PF\gamemodes\Master[RPG].pwn(4516) : warning 235: public function lacks forward declaration (symbol "VerificarVeiculo")
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Warning

Reply
#8

Vocк tirou a forward?
pawn Код:
forward VerificarVeiculo(playerid);
Reply
#9

Quote:
Originally Posted by humildadeforever
Посмотреть сообщение
Vocк tirou a forward?
pawn Код:
forward VerificarVeiculo(playerid);
Sim linda, tirei :/
Reply
#10

forward IsAMecCar(carid);//para criar a public IsAMecCar







Vai editando e tenta com esses codigos Retirei esses codigos Do Gf


if(newstate == PLAYER_STATE_DRIVER)
{// 38 / 49 / 56 = SS
new newcar = GetPlayerVehicleID(playerid);
new oldcar = gLastCar[playerid];
new HouseCar = PlayerInfo[playerid][pPHousekey]+totalveiculos;
TelePos[playerid][0] = 0.0;
TelePos[playerid][1] = 0.0;
new carid=GetVehicleModel(newcar);
if(carid == 0 || carid == 0 || carid == 0) { }
else
{
if(IsMecCar(newcar))
{
if(!IsMec(playerid))
{
SendClientMessage(playerid, COR_AZTECAS, "Vocк nгo й um Mecanico, por isso nгo tem a chave desse veнculo !");
RemovePlayerFromVehicleEx(playerid);
}
}









public IsAMecCar(carid)//Agora essa e a public a ser criada
{
if((carid >= 378 && carid <= 382))// Aqui e onde voce define de qual org o carro e entao aki o os carros do 378 ao 382 sao dos mecanicos
{
return true;
}
return 0;
}

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)