[Ajuda] Um pequeno BUG ao desligar motor
#1

Boas, gostava que me podessem ajudar aqui.

Quando ligo o motor (CTRL) ele liga, mas quando desligo o motor (CTRL denovo) nao dб, tenho de escrever o /motor para desligar.

Estб aqui o code (й grande):


PHP код:
//=================================[DEFINES]==============================================
#define VEHICLE_PARAMS_UNSET    -1 //This sets if your using the params
#define VEHICLE_PARAMS_OFF  0 //This will set your params OFF
#define VEHICLE_PARAMS_ON   1 //This will set your params ON
#define KEY_SEATBELT 4
#define KEY_MOTOR 1
#define KEY_LIGTH 65536
#define KEY_LIGHT 65536
#define Key_Open 128 
PHP код:
         if(strcmp(cmd"/motor"true) == 0)
        {
            new 
sendername[MAX_PLAYER_NAME];
            new 
carro GetPlayerVehicleID(playerid) - 1;
            new 
carid GetPlayerVehicleID(playerid);
            new 
Float:health;
            new 
veh;
            
veh GetPlayerVehicleID(playerid);
            
GetVehicleHealth(vehhealth);
            new 
succeed random(2);
            if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if(
IsPlayerInAnyVehicle(playerid))
                {
                    if(
EngineStatus[GetPlayerVehicleID(playerid)] == 0)
                    {
                        if(
Batery[carid] >= 1)
                           {
                            if(
DynamicCars[carro][comprado] == 1)
                            {
                                if(
PlayerInfo[playerid][pChave] == carid || PlayerInfo[playerid][pChave2] == carid || PlayerInfo[playerid][pChave3] == carid || PlayerInfo[playerid][pChave4] == carid || PlayerInfo[playerid][pChave5] == carid || PlayerInfo[playerid][pChave6] == carid)
                                {
                                    if(
health >= 600.0)
                                    {
                                           
PlayerActionMessage(playerid,15.0,"acabou de ligar o motor.");
                                           
TogglePlayerControllable(playerid,1);
                                        
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                        
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                        
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                       }
                                    else if((
health <= 600.0) && (health >= 300.0))
                                    {
                                        if(
succeed == 1)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor consegue*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
TogglePlayerControllable(playerid,1);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                        }
                                        else if(
succeed == 2)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor e falha*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                            
GameTextForPlayer(playerid,"~r~Carro Avariado.",90000,5);
                                        }
                                    }
                                    if(
health <= 300.0)
                                    {
                                        if(
succeed == 1)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor consegue*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
TogglePlayerControllable(playerid,1);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                        
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                        }
                                        else if(
succeed == 2)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor e falha*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                        
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                            
GameTextForPlayer(playerid,"~r~Carro Avariado.",90000,5);
                                        }
                                    }
                                
Batery[carid] -= 1;
                                }
                                else
                                {
                                    if(
AdminDuty[playerid] == 0)
                                    {
                                        
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                        
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                            
//                                     ||||||
                                        
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                        
RemovePlayerFromVehicle(playerid);
                                    }
                                    
TogglePlayerControllable(playerid,1);
                                    
GetPlayerName(playeridsendernamesizeof(sendername));
                                    
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"Nгo podes ligar o carro nгo tens as chaves.");
                                    
PlayerActionMessage(playerid,15.0,"tenta ligar o carro.");
                                }
                            }
                             if(
DynamicCars[carro][buy] == 1)
                            {
                                if(
AdminDuty[playerid] == 0)
                                {
                                    
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                    
RemovePlayerFromVehicle(playerid);
                                }
                                
TogglePlayerControllable(playerid,1);
                                
GetPlayerName(playeridsendernamesizeof(sendername));
                                
format(string256"O jogador %s tentou ligar um carro do stand!!"sendername);
                                
AdministratorMessage(COLOR_ORANGEstring,1);
                                
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"Nгo podes ligar o carro nгo tens as chaves.");
                                
PlayerActionMessage(playerid,15.0,"tenta ligar o carro.");
                            }
                            else
                            {
                                if(
DynamicCars[carro][comprado] == 0)
                                {
                                    if(
health >= 600.0)
                                    {
                                           
PlayerActionMessage(playerid,15.0,"acabou de ligar o motor.");
                                           
TogglePlayerControllable(playerid,1);
                                        
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                        
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                       }
                                    else if((
health <= 600.0) && (health >= 300.0))
                                    {
                                        if(
succeed == 1)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor consegue*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
TogglePlayerControllable(playerid,1);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                        }
                                        else if(
succeed == 2)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor e falha*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                            
GameTextForPlayer(playerid,"~r~Carro Avariado.",90000,5);
                                        }
                                    }
                                    if(
health <= 300.0)
                                    {
                                        if(
succeed == 1)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor consegue*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
TogglePlayerControllable(playerid,1);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                                        }
                                        else if(
succeed == 2)
                                        {
                                            
format(stringsizeof(string), "*%s tenta ligar o motor e falha*."GetPlayerNameEx(playerid));
                                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                                            
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                            
GameTextForPlayer(playerid,"~r~Carro Avariado.",90000,5);
                                        }
                                    }
                                    
Batery[carid] -= 1;
                                }
                            }
                        }
                        else
                        {
                            
format(stringsizeof(string), "*%s tenta ligar o motor e falha*."GetPlayerNameEx(playerid));
                            
ProxDetector(10.0playeridstring0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF,0x9501C6FF);
                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                                
//                                     ||||||
                              
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                        }
                    }
                      else
                    {
                        if(
DynamicCars[carro][comprado] == 1)
                        {
                            if(
PlayerInfo[playerid][pChave] == carid || PlayerInfo[playerid][pChave2] == carid || PlayerInfo[playerid][pChave3] == carid || PlayerInfo[playerid][pChave4] == carid || PlayerInfo[playerid][pChave5] == carid || PlayerInfo[playerid][pChave6] == carid)
                            {
                                
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                        
//                                     ||||||
                                    
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                   if(
PlayerInfo[playerid][pSex] == 1)
                                {
                                       
PlayerActionMessage(playerid,15.0,"acabou de desligar o motor.");
                                   }
                                   else
                                   {
                                    
PlayerActionMessage(playerid,15.0,"acabou de desligar o motor.");
                                   }
                            }
                            else
                            {
                                if(
AdminDuty[playerid] == 0)
                                {
                                    
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                    
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                        
//                                     ||||||
                                    
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                    
RemovePlayerFromVehicle(playerid);
                                }
                                
TogglePlayerControllable(playerid,1);
                                
GetPlayerName(playeridsendernamesizeof(sendername));
                                
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"Nгo podes desligar o carro nгo tens as chaves.");
                                
PlayerActionMessage(playerid,15.0,"tenta desligar o carro.");
                            }
                        }
                        if(
DynamicCars[carro][buy] == 1)
                        {
                            if(
AdminDuty[playerid] == 0)
                            {
                                
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                                
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                        
//                                     ||||||
                                    
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                                
RemovePlayerFromVehicle(playerid);
                            }
                            
TogglePlayerControllable(playerid,1);
                            
GetPlayerName(playeridsendernamesizeof(sendername));
                            
format(string256"O jogador %s tentou desligar um carro do stand!!"sendername);
                            
AdministratorMessage(COLOR_ORANGEstring,1);
                            
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"Nгo podes desligar o carro nгo tens as chaves.");
                            
PlayerActionMessage(playerid,15.0,"tenta desligar o carro.");
                        }
                        else
                        {
                        if(
DynamicCars[carro][comprado] == 0)
                        {
                            
EngineStatus[GetPlayerVehicleID(playerid)] = 0;
                            
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                        
//                                     ||||||
                                    
SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                               if(
PlayerInfo[playerid][pSex] == 1)
                            {
                                   
PlayerActionMessage(playerid,15.0,"acabou de desligar o motor.");
                               }
                               else
                               {
                                
PlayerActionMessage(playerid,15.0,"acabou de desligar o motor.");
                               }
                        }
                        }
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERRO:] Nao estas em nenhum veiculo!");
            }
            return 
1;
        } 
Reply
#2

Coloca as funзхes que o CTRL faz ai jovem.
Reply
#3

No CTRL,bote .
pawn Код:
if(EngineStatus[GetPlayerVehicleID(playerid)] == 1) EngineStatus[GetPlayerVehicleID(playerid)] =0;
if(EngineStatus[GetPlayerVehicleID(playerid)] ==0)EngineStatus[GetPlayerVehicleID(playerid)] =1;
Reply
#4

Quote:

No CTRL,bote .

pawn Code:

if(EngineStatus[GetPlayerVehicleID(playerid)] == 1) EngineStatus[GetPlayerVehicleID(playerid)] =0;
if(EngineStatus[GetPlayerVehicleID(playerid)] ==0)EngineStatus[GetPlayerVehicleID(playerid)] =1;
onde meto +/-?
Reply
#5

em OnPlayerKeyStateChange pra ajudar a encontrar o CTRL https://sampwiki.blast.hk/wiki/Keys
Reply
#6

onde meto o OnPlayerKeyStateChange?

nao percebo onde se pхe.
Reply
#7

Quote:
Originally Posted by FuZzYey
Посмотреть сообщение
onde meto +/-?
Devo responder

no cуdigo da Key CTRL, OnPlayerKeyStateChange
Reply
#8

podias me dizer exatamento o sнtio? senao o peturbar
Reply
#9

Ajude-me pff
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)