SA-MP Forums Archive
[Ajuda] Ligar veнculo - 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] Ligar veнculo (/showthread.php?tid=612904)



Ligar veнculo - GabrielBiel - 22.07.2016

Boa tarde
Tenho um FS de ligar veнculo, porйm se o player entrar no carro e acelerar, ele anda numa boa. Quero bloquear para quando o player entrar e acelerar o carro nгo andar. Somente se ele apertar CTRL, aн sim liga o veнculo e ele consegue sair com o carro. Alguйm pode ajudar?

PHP код:
public OnGameModeInit()
{
    
ManualVehicleEngineAndLights();
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
IsPlayerInAnyVehicle(playerid) && newkeys == 1)
    {
        if(
motor[playerid] == 0)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_ONlliandlcdmaishe);
            
motor[playerid] = 1;
            
SendClientMessage(playerid, -1"Motor Ligado com Sucesso.");
            return 
1;
        }
        else if(
motor[playerid] == 1)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_OFFlliandlcdmaishe);
            
motor[playerid] = 0;
            
SendClientMessage(playerid,-1"Motor Desligado com Sucesso.");
            return 
1;
        }
        return 
1;
    } 



Respuesta: Ligar veнculo - SammyJ - 22.07.2016

Quote:
Originally Posted by GabrielBiel
Посмотреть сообщение
Boa tarde
Tenho um FS de ligar veнculo, porйm se o player entrar no carro e acelerar, ele anda numa boa. Quero bloquear para quando o player entrar e acelerar o carro nгo andar. Somente se ele apertar CTRL, aн sim liga o veнculo e ele consegue sair com o carro. Alguйm pode ajudar?

PHP код:
public OnGameModeInit()
{
    
ManualVehicleEngineAndLights();
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
IsPlayerInAnyVehicle(playerid) && newkeys == 1)
    {
        if(
motor[playerid] == 0)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_ONlliandlcdmaishe);
            
motor[playerid] = 1;
            
SendClientMessage(playerid, -1"Motor Ligado com Sucesso.");
            return 
1;
        }
        else if(
motor[playerid] == 1)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_OFFlliandlcdmaishe);
            
motor[playerid] = 0;
            
SendClientMessage(playerid,-1"Motor Desligado com Sucesso.");
            return 
1;
        }
        return 
1;
    } 
Se isso for FILTERSCRIPT mude o OnGameModeInit Para OnFilterScriptInit
PHP код:
public OnFilterScriptInit() 

    
ManualVehicleEngineAndLights(); 
    return 
1




Re: Ligar veнculo - GabrielBiel - 22.07.2016

Sim, alterei e deu esse erro
Quote:

C:\Users\Gabriel\Desktop\Project Fatality\filterscripts\motor.pwn(22) : error 021: symbol already defined: "OnFilterScriptInit"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.




Respuesta: Ligar veнculo - SammyJ - 22.07.2016

Tem dois OnFilterScriptInit definido encontre apague o mais retire o cуdigo e poe no outro!


Re: Ligar veнculo - GabrielBiel - 22.07.2016

Estou apagando, porйm dб erro. Poderia dizer como ficaria? Achei os dois...
PHP код:
public OnFilterScriptInit()
{
    print(
"\n===============================");
    print(
"*******************************");
    print(
"\nFilterScript By Willian_Luigi\n");
    print(
"*******************************");
    print(
"===============================\n");
    return 
0;
}
new 
motor[MAX_PLAYERS], farol[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
    
ManualVehicleEngineAndLights();
    return 
1;




Respuesta: Ligar veнculo - SammyJ - 22.07.2016

Apague os dois e coloque este!
PHP код:
public OnFilterScriptInit() 

    print(
"\n==============================="); 
    print(
"*******************************"); 
    print(
"\nFilterScript By Willian_Luigi\n"); 
    print(
"*******************************"); 
    print(
"===============================\n");
    
ManualVehicleEngineAndLights(); 
    return 
1




Re: Ligar veнculo - GabrielBiel - 22.07.2016

Alterei e ainda estб do mesmo jeito, o jogador entra e consegue acelerar normalmente.
PHP код:
public OnFilterScriptInit()
{
    print(
"\n===============================");
    print(
"*******************************");
    print(
"\nFilterScript By Willian_Luigi\n");
    print(
"*******************************");
    print(
"===============================\n");
    
ManualVehicleEngineAndLights();
    return 
1;
}
new 
motor[MAX_PLAYERS], farol[MAX_PLAYERS];
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
IsPlayerInAnyVehicle(playerid) && newkeys == 1)
    {
        if(
motor[playerid] == 0)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_ONlliandlcdmaishe);
            
motor[playerid] = 1;
            
SendClientMessage(playerid, -1"Motor Ligado com Sucesso.");
            return 
1;
        }
        else if(
motor[playerid] == 1)
        {
            new 
car GetPlayerVehicleID(playerid), williandlcdmaishe;
            
GetVehicleParamsEx(carwilliandlcdmaishe);
            
SetVehicleParamsEx(carVEHICLE_PARAMS_OFFlliandlcdmaishe);
            
motor[playerid] = 0;
            
SendClientMessage(playerid,-1"Motor Desligado com Sucesso.");
            return 
1;
        }
        return 
1;
    } 



Re: Ligar veнculo - MBJ - 23.07.2016

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
car GetPlayerVehicleID(playerid);
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(carengine,lightsalarmdoorsbonnetbootobjective);
        if(
Motor[car] == falseSetVehicleParamsEx(car0,lightsalarmdoorsbonnetbootobjective);
        
SendClientMessage(playerid, -1"Seu veiculo esta desligado por favor ligue-o apertando CTRL para poder andar");
    }
    return 
true;