[AJUDA]Veiculos com horas
#1

Tipo, to com um problema, queria adicionar as horas validas para pegar os veiculos
tipo id 425(Hunter), so poderб ser usado a cada 2 horas, tipo 2 horas sem usar e uma livre pra usar e quando o tempo acabar altumaticamente o player sera injetado do veiculo.
se poderem me ajudar, agradeзo!
Reply
#2

PHP код:
new kUso;
public 
OnPlayerStateChange( playerid, newstate, oldstate )
{
   if( 
kUso[ playerid ] == 0 )
   {
      
SendClientMessage( playerid, -1, "Ninguйm pode usar veiculos agora!" );
      
RemovePlayerFromVehicle( playerid );
   }
   
/* ... */
   
return true;
} 
PHP код:
forward kVerificar( );
public 
kVerificar( )
{
   new 
Knight;
   while( 
Knight != MAX_PLAYERS )
   {
      if( 
IsPlayerConnected( Knight ) )
      {
         if( 
kUso == 0 ) return kUso = true;
         else if( 
kUso == 1 ) return kUso = false;
      }
   }
   return 
true;
} 
SetTimer:
PHP код:
//OnGameModeInit
SetTimer( "kVerificar", /* TEMPO */, true ); 
Reply
#3

PHP код:
forward Check();
public 
OnFilterScriptInit()
{
    
SetTimer("Check", 1000, true);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SetPVarInt(playerid, "Permitido", 0);
    
SetPVarInt(playerid, "Proibido", -1);
    return 
1;
}
public 
Check()
{
    for(new 
i = 0; i < MAX_PLAYERS; i ++)
    {
        
SetPVarInt(i, "Permitido", GetPVarInt(i, "Permitido")+1);
        if(
GetPVarInt(i, "Proibido") >= 0)
        {
            
SetPVarInt(i, "Proibido", GetPVarInt(i, "Proibido")+1);
            if(
GetPVarInt(i, "Proibido") >= 7200)
            {
                
SetPVarInt(i, "Permitido", 0);
                
SetPVarInt(i, "Proibido", -1);
                
SendClientMessage(i, 0xFF0000FF, "Agora vocк pode usar o Hunter novamente.");
            }
            if(
GetVehicleModel(GetPlayerVehicleID(i)) == 425)
            {
                
RemovePlayerFromVehicle(i);
                
SendClientMessage(i, 0xFF0000FF, "Seu tempo para usar o Hunter esgotou. Aguarde duas horas para usб-lo novamente.");
            }
        }
        else if(
GetPVarInt(i, "Permitido") >= 3600)
        {
            
SetPVarInt(i, "Permitido", 0);
            
SendClientMessage(i, 0xFFFF00FF, "Seu tempo para usar o Hunter esgotou. Aguarde duas horas para usб-lo novamente.");
            if(
GetVehicleModel(GetPlayerVehicleID(i)) == 425)
            {
                
SendClientMessage(i, 0xFFFF00FF, "Vocк nгo pode usar o Hunter agora.");
                
RemovePlayerFromVehicle(i);
            }
        }
    }
    return 
1;
} 
Pastebin.com: http://pastebin.com/raw.php?i=0kr5AKEf
Reply
#4

Primeiramente Obrigado por me ajudarem!
aque funcionou do geito q o Shadoww5. so q tem um problema o tempo acaba ai o cara й ejetado mais na mesma hora vc pode pegar o veiculo novamente, intaum nao adiantou nada pra mim a pessoa so й injetada do veiculo.
eu queria q eles nao pudessem pegar o veiculo d jeito nenhum no tempo q tivesse proibido
to precisando muito disso se vcs poderem me ajudar. agradeзo!
Reply
#5

pawn Код:
new bool:dr_PodeEntrar[MAX_PLAYERS];
new dr_Timer[MAX_PLAYERS];

forward PodeEntrarDeNovo(playerid);

public OnPlayerConnect(playerid)
{
     dr_PodeEntrar[playerid] = true;
     return 1;
}

public OnPlayerDisconnect(playerid)
{
     KillTimer(dr_Timer[playerid]);
     return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
     if(newstate == 2) // Motorista
     {
          new vID = GetPlayerVehicleID(playerid);
          if(vID == /*Id_Do_Seu_Veiculo_Proibido*/)
          {
               if(!dr_PodeEntrar[playerid])
               {
                    RemovePlayerFromVehicle(playerid);
                    return SendClientMessage(playerid, 0x777777FF, "   Vocк nгo pode pegar este veiculo.");
               }
               dr_Timer[playerid] = SetTimerEx("PodeEntrarDeNovo", 60000*60*2, "i", playerid);
               dr_PodeEntrar[playerid] = false;
          }
     }
     return 1;
}

public PodeEntrarDeNovo(playerid)
{
     dr_PodeEntrar[playerid] = true;
     return 1;
}
Simples.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)