[Ajuda] Sistema de gasolina
#1

Estou com um pequeno e creio que й simples problema no sistema de combustivel.
Bem, ao o servidor iniciar, todos os carros que voce entrar o combustivel esta 0 mas usando o comando /abastecercarros o combustivel vai para 100% porem ele nao desce...vou postar aqui os cods do sistema:

PHP код:

    
if(strcmp(cmd,"/abastecer"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
             if(!
IsPlayerInAnyVehicle(playerid))
             {
                   
SendClientMessage(playerid,COLOR_RED,"Precisa estar em um veiculo para abastecer!");
                   return 
true;
            }
             new 
vid GetPlayerVehicleID(playerid);
              if(
Gas[vid] >= 100)
                return 
SendClientMessage(playerid,COLOR_RED,"O tanque ja estб cheio, nao precisa de abastecimento.");
            if(
IsAtGasStation(playerid))
            {
                  
GameTextForPlayer(playerid,"~n~~w~Reabastecendo~n~ ~r~~h~Aguarde",3003,3);
                
SetTimer("Fillup",RefuelWait,0);
                
Controle(playerid0);
                
Refueling[playerid] = 1;
            }
            else
            {
                
SendClientMessage(playerid,COLOR_GREY,"Precisa estar em um posto de gasolina.");
            }
        }
        return 
true;
    }
//comando /abastecercarros
if(strcmp(cmd"/abastecercarros"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] >= 6)
            {
                
GetPlayerName(playeridsendernamesizeof(sendername));
                for(new 
c=0;c<CAR_AMOUNT;c++)
                {
                    
Gas[c] = GasMax;
                }
                
format(stringsizeof(string), "Todos os veiculos foram abastecidos por %s",sendername);
                
SendClientMessageToAll(COLOR_GRAD1string);
            }
            else
            {
                   
SendClientMessage(playeridCOLOR_GRAD1"   Vocк nгo estб autorizado a usar este comando!");
                return 
true;
            }
        }
        return 
true;
    }
//Defines:
#define GasMax    100
#define RefuelWait    5000
//
forward CheckGas();
//
new Gas[CAR_AMOUNT];
new 
Refueling[MAX_PLAYERS];
//
public IsAtGasStation(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerToPoint(15.0,playerid,1941.9850,-1774.6639,19.7006))
        {
            if(
IsAPlane(GetPlayerVehicleID(playerid)))
            {
                return 
true;
            }
        }
        if(
PlayerToPoint(6.0,playerid,1004.0070,-939.3102,42.1797) || PlayerToPoint(6.0,playerid,1944.3260,-1772.9254,13.3906) || PlayerToPoint(6.0,playerid,1400.6882,-1680.5344,42.4339) || PlayerToPoint(6.0,playerid,1496.5316,-1544.0677,23.5481) || PlayerToPoint(6.0,playerid,2737.3364,-1774.2123,43.7973))
        {
//LS
            
return true;
        }
        else if(
PlayerToPoint(6.0,playerid,-90.5515,-1169.4578,2.4079) || PlayerToPoint(6.0,playerid,-1609.7958,-2718.2048,48.5391))
        {
//LS
            
return true;
        }
        else if(
PlayerToPoint(6.0,playerid,-2029.4968,156.4366,28.9498) || PlayerToPoint(8.0,playerid,-2408.7590,976.0934,45.4175))
        {
//SF
            
return true;
        }
        else if(
PlayerToPoint(6.0,playerid,1380.4712,462.7467,20.1107) || PlayerToPoint(8.0,playerid,1385.0475,460.5417,20.1068))
        {
//ppc
            
return true;
        }
        else if(
PlayerToPoint(6.0,playerid,1383.5532,457.1286,19.9561) || PlayerToPoint(8.0,playerid,1379.1952,459.1295,19.9587))
        {
//ppc
            
return true;
        }
        else if(
PlayerToPoint(5.0,playerid,-2243.9629,-2560.6477,31.8841) || PlayerToPoint(8.0,playerid,-1676.6323,414.0262,6.9484))
        {
//Between LS and SF
            
return true;
        }
        else if(
PlayerToPoint(6.0,playerid,2202.2349,2474.3494,10.5258) || PlayerToPoint(10.0,playerid,614.9333,1689.7418,6.6968))
        {
//LV
            
return true;
        }
        else if(
PlayerToPoint(8.0,playerid,-1328.8250,2677.2173,49.7665) || PlayerToPoint(6.0,playerid,70.3882,1218.6783,18.5165))
        {
//LV
            
return true;
        }
        else if(
PlayerToPoint(8.0,playerid,677.1299,-2866.3892,13.0944) || PlayerToPoint(6.0,playerid,-1327.7218,2678.8723,50.0625))
        {
//LV
            
return true;
        }
    }
    return 
0;
}
//
public CheckGas()
{
    for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerConnected(i))
           {
               
OnPlayerSave(i);
               if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && !IsPlayerNPC(i))
               {
                  new 
motlualarporcappormaob;
                new 
vehicle GetPlayerVehicleID(i);
                new 
VehicleModel GetVehicleModel(vehicle);
                   if(
VehicleModel == 487 || VehicleModel == 520 || VehicleModel == 462 || VehicleModel == 497 || VehicleModel == 425 || VehicleModel == 592 || VehicleModel == 519 || VehicleModel == 593 || VehicleModel == 452)
                   {
                       return 
true;
                   }
                if(
Gas[vehicle] >= 1)
                   {
                       if(
Gas[vehicle] <= 10)
                       {
                           
PlayerPlaySound(i10850.00.00.0);
                       }
                      
Gas[vehicle]--;
                   }
                   else
                   {
                    
NoFuel[i] = 1;
                    
GetVehicleParamsEx(vehiclemotlualarporcappormaob);
                    
SetVehicleParamsEx(vehicle0lualarporcappormaob);
                    
GameTextForPlayer(i,"~r~Sem combustivel~n~~y~Chame um mecanico para ajudar",1500,3);
                }
            }
        }
    }
    return 
true;
}
public 
Fillup()
{
    for(new 
i=0i<MAX_PLAYERSi++)
       {
           if(
IsPlayerConnected(i))
           {
            new 
VID;
            new 
FillUp;
            new 
string[128];
            
VID GetPlayerVehicleID(i);
            
FillUp GasMax Gas[VID];
            
FillUp FillUp 2;
            if(
Refueling[i] == 1)
            {
                if(
GetPlayerMoney(i) >= FillUp+4)
                {
                    
Gas[VID] = 100;
                    
format(string,sizeof(string),"* Vocк reabasteceu seu veнculo, por: R$%d.",FillUp);
                    
SendClientMessage(i,COLOR_LIGHTBLUE,string);
                    
Controle(i1);
                    
GivePlayerMoney(i, - FillUp);
                    
SBizzInfo[3][sbTill] += FillUp;
                    
ExtortionSBiz(3FillUp);
                    
Refueling[i] = 0;
                    if(
IsPlayerConnected(i))
                    {
                        if(
GetPlayerOrg(i) == 7)
                        {
                            
SendClientMessage(iCOLOR_LIGHTBLUE"{FF0000}(GOVERNO){FF0000}Voce recebeu R$70 de Impostos da Populacao!");
                            
GivePlayerMoney(i70);
                        }
                    }
                }
                   else
                   {
                       
Controle(i1);
                       
format(string,sizeof(string),"* Voce nao tem dinheiro suficiente para encher o tanque, custo: $%d.",FillUp);
                    
SendClientMessage(i,COLOR_LIGHTBLUE,string);
                   }
             }
        }
    }
    return 
true;

OBS: Os cods nao estao juntos assim, apenas peguei todos e coloquei ae(nao esta nem em ordem...)

Agradeco desde ja a quem poder me ajudar
Reply
#2

ta faltando um settimer ai,segue ai.

//topo do gm
Код:
#define tempogas 14000
Код:
new CheckGastempo;
//gamemodeinit
Код:
CheckGastempo = SetTimer("CheckGas", tempogas, 1);
//tempogas - tempo que diminuirб o combustivel
Reply
#3

continua igual nao desce e ao iniciar o sv a gasolina fica 0, ai eu do /abastecercarros fica 100 porem nao desce..
Reply
#4

experimenta tirar essa OnPlayerSave(i); da public checkgas,creio eu que deve estar salvando o combustivel do veiculo antes de diminuir.
Reply
#5

tirei, mas continua igual :/ quando o combustivel ta 0, nao acontece nada tambem....alguem ajuda ae :/
Reply
#6

:/ pow
Reply
#7

Da uma revisada no CheckGas , quando digo revisar e tentar montar denovo.
Reply
#8

@edit, agora foi obrigado deu as taboas mas nao deu a canoa, refiz a public CheckGas e funciono corretamente como o esperado muito obrigado mesmo, nao deu o cуdigo pronto e me ajudou +rep.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)