SA-MP Forums Archive
[Ajuda] Respawna no veiculos - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Respawna no veiculos (/showthread.php?tid=634034)



Respawna no veiculos - Maxwilson01 - 12.05.2017

Olб, estou com problema jб tentei de vбrias formas alguma coisa estou errando..

Seguinte, nesse cуdigo ele era pra respawnar somente veнculos do servidor exceto os veнculos sets e se player estiver dentro do veiculo ele nгo ser respawnado, porйm quando e utilizado comandos de respawnar ele faz com todos os veнculos incluнdo os sets atй quem estб dentro do veiculo.

PHP код:
stock RetSpawnVeh()
{
  static 
boolinVeh;
    for(new 
veiculo 0veiculo MAX_VEHICLESveiculo++){
        for(new 
carcar MAX_CARROScar++){
        
inVeh false;
        for(new 
Player 0GetMaxPlayers(); Player++){
            if(
VeiculoID(veiculo) == Set[car])
            if(
IsPlayerInVehicle(Playerveiculo))
                
inVeh true;
                break;
        }
// Terceiro for
        
        
if(!inVeh){
            
SetVehicleToRespawn(veiculo);
        }
        }
// Segundo for
    
}//Primeiro for
    
return 1;  

Se alguйm poder me ajuda agradeзo


Re: Respawna no veiculos - Felpz - 12.05.2017

Quote:
Originally Posted by Maxwilson01
Посмотреть сообщение
Olб, estou com problema jб tentei de vбrias formas alguma coisa estou errando..

Seguinte, nesse cуdigo ele era pra respawnar somente veнculos do servidor exceto os veнculos sets e se player estiver dentro do veiculo ele nгo ser respawnado, porйm quando e utilizado comandos de respawnar ele faz com todos os veнculos incluнdo os sets atй quem estб dentro do veiculo.

PHP код:
stock RetSpawnVeh()
{
  static 
boolinVeh;
    for(new 
veiculo 0veiculo MAX_VEHICLESveiculo++){
        for(new 
carcar MAX_CARROScar++){
        
inVeh false;
        for(new 
Player 0GetMaxPlayers(); Player++){
            if(
VeiculoID(veiculo) == Set[car])
            if(
IsPlayerInVehicle(Playerveiculo))
                
inVeh true;
                break;
        }
// Terceiro for
        
        
if(!inVeh){
            
SetVehicleToRespawn(veiculo);
        }
        }
// Segundo for
    
}//Primeiro for
    
return 1;  

Se alguйm poder me ajuda agradeзo
Код:
stock RetSpawnVeh()
{
new bool:inVeh;
for(new i = 0; i < MAX_VEHICLES; i++)
{
inVeh = false;
for(new v = 0; v < MAX_PLAYERS; v++)
{
if(IsPlayerInVehicle( v, i))
{
inVeh = true;
}
}
if(!inVeh) SetVehicleToRespawn(i);
}
return 1;
}
Poste o resultado...


Re: Respawna no veiculos - Maxwilson01 - 12.05.2017

Respawnando todos os veнculos incluindo os sets.
Pra respawnar todos menos os veнculos sets.


Re: Respawna no veiculos - RodrigoMSR - 12.05.2017

A o нndice da variбvel Set й para jogadores, veнculos ou outra coisa?


Re: Respawna no veiculos - Maxwilson01 - 12.05.2017

Set para veiculo Set, uso ela quando quero comparar ou fazer condiзхes.


Re: Respawna no veiculos - Showzs - 13.05.2017

Dб respawn em todos os veнculos desocupados.

Код:
stock RetSpawnVeh( )
{
    for( new v = 0; v < MAX_VEHICLES; v++ )
    {
        if( !IsVehicleOccupied( v ))
        {
            SetVehicleToRespawn( v );
        }
    }
    return 1;
}
Dб respawn em todos os veнculos exceto veнculos set.

Код:
stock RetSpawnVeh( )
{
    for( new v = 0; v < MAX_VEHICLES; v++ )
    {
        if( !IsVehicleOccupied( v ) && !IsVeiculoSet( v ))
        {
            SetVehicleToRespawn( v );
        }
    }
    return 1;
}
Outras stocks

Код:
stock IsVehicleOccupied( vehicleid )
{
    foreach( Player, i ) if( IsPlayerInVehicle( i, vehicleid ) && GetPlayerState( i ) == PLAYER_STATE_DRIVER )
    return 1; return 0;
}

stock IsVeiculoSet( v )
{
    if( Set[ v ] == 1 ) return true;
        else return false;
}
Include foreach ( usada na stock IsVehicleOccupied )

Код:
#include <foreach>

https://sampforum.blast.hk/showthread.php?tid=570868