[Ajuda] Preciso de ajuda nessa fs pf / ligar /desligar veiculo
#1

galera como faзo pra quando a pessoa apertar CTRL o carro ligar e qnd apertar dnv o carro liga
PHP код:
// [FS] Engine System v3
// Made by Joe Torran C
// Credits to JeNkStA for helping me fix some stuff
// DO NOT REMOVE THESE CREDITS
#include <a_samp>
#include <zcmd>
#define colorRed        0xFF0000FF
#define colorYellow     0xFFFF00FF
forward StartEngine(playerid);
forward DamagedEngine(playerid);
new 
vehEngine[MAX_VEHICLES];
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
vehEngine[vehicleid] == 0)
        {
            
TogglePlayerControllable(playerid0);
            
SendClientMessage(playeridcolorYellow"Vehicle engine NOT started");
            
SendClientMessage(playeridcolorYellow"To start the vehicle's engine press \"Shift\" or type \"/engine\"");
        }
        else if(
vehEngine[vehicleid] == 1)
        {
            
TogglePlayerControllable(playerid1);
            
SendClientMessage(playeridcolorYellow"Vehicle engine running");
        }
    }
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
IsPlayerInAnyVehicle(playerid))
    {
        if(
vehEngine[vehicleid] == 0)
        {
            if(
newkeys == 262144)
            {
                
vehEngine[vehicleid] = 2;
                
SetTimerEx("StartEngine"30000"i"playerid);
                
SendClientMessage(playeridcolorYellow"Vehicle engine starting");
            }
        }
        if(
newkeys == KEY_SECONDARY_ATTACK)
        {
            
RemovePlayerFromVehicle(playerid);
            
TogglePlayerControllable(playerid1);
        }
    }
    return 
1;
}
public 
StartEngine(playerid)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
Float:health;
    new 
rand random(2);
    
GetVehicleHealth(vehicleidhealth);
    if(
IsPlayerInAnyVehicle(playerid))
    {
        if(
vehEngine[vehicleid] == 2)
        {
            if(
health 300)
            {
                if(
rand == 0)
                {
                    
vehEngine[vehicleid] = 1;
                      
TogglePlayerControllable(playerid1);
                      
SetTimerEx("DamagedEngine"10001"i"playerid);
                    
SendClientMessage(playeridcolorYellow"Vehicle engine started");
                }
                if(
rand == 1)
                {
                    
vehEngine[vehicleid] = 0;
                    
TogglePlayerControllable(playerid0);
                    
SendClientMessage(playeridcolorYellow"Vehicle engine failed to start");
                }
            }
            else
            {
            }
        }
    }
    return 
1;
}
public 
DamagedEngine(playerid)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
Float:health;
    
GetVehicleHealth(vehicleidhealth);
    if(
IsPlayerInAnyVehicle(playerid))
    {
        if(
vehEngine[vehicleid] == 1)
        {
            if(
health 100)
            {
                
vehEngine[vehicleid] = 0;
                
TogglePlayerControllable(playerid0);
                
SendClientMessage(playeridcolorYellow"Vehicle engine stopped due to damage");
            }
        }
    }
    return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    
TogglePlayerControllable(playerid1);
    return 
1;
}
CMD:engine(playeridparams[])
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridcolorRed"You need to be in a vehicle to use this command");
    if(
vehEngine[vehicleid] == 0)
    {
        
vehEngine[vehicleid] = 2;
        
SetTimerEx("StartEngine"30000"i"playerid);
        
SendClientMessage(playeridcolorYellow"Vehicle engine starting");
    }
    else if(
vehEngine[vehicleid] == 1)
    {
        
vehEngine[vehicleid] = 0;
        
TogglePlayerControllable(playerid0);
        
SendClientMessage(playeridcolorYellow"Vehicle engine stopped");
        
SendClientMessage(playeridcolorYellow"To re-start the vehicle's engine press \"Shift\" or type \"/engine\"");
    }
    return 
1;
}
public 
OnFilterScriptInit()
{
    print(
"\n  [FS] Engine System v3 by Joe Torran C \n");
    return 
1;

Reply
#2

Vocк crirou outro tуpico e a resposta estб no seu outro tуpico....

Troque
Код:
if(vehEngine[vehicleid] == 0)
        {
            if(newkeys == 262144)
            {
                vehEngine[vehicleid] = 2;
                SetTimerEx("StartEngine", 3000, 0, "i", playerid);
                SendClientMessage(playerid, colorYellow, "Vehicle engine starting");
            }
        }
por
Код:
if(newkeys == KEY_FIRE)
        {
            if(vehEngine[vehicleid] == 0)
            {
                vehEngine[vehicleid] = 2;
                SetTimerEx("StartEngine", 3000, 0, "i", playerid);
                SendClientMessage(playerid, colorYellow, "Tentando dar a partida.");
            }
            else
            {
                vehEngine[vehicleid] = 0;
                SendClientMessage(playerid, colorYellow, "Motor Desligado.");
            }
        }
Reply
#3

Quote:
Originally Posted by GabrielDias_Invision
Посмотреть сообщение
Vocк crirou outro tуpico e a resposta estб no seu outro tуpico....

Troque
Код:
if(vehEngine[vehicleid] == 0)
        {
            if(newkeys == 262144)
            {
                vehEngine[vehicleid] = 2;
                SetTimerEx("StartEngine", 3000, 0, "i", playerid);
                SendClientMessage(playerid, colorYellow, "Vehicle engine starting");
            }
        }
por
Код:
if(newkeys == KEY_FIRE)
        {
            if(vehEngine[vehicleid] == 0)
            {
                vehEngine[vehicleid] = 2;
                SetTimerEx("StartEngine", 3000, 0, "i", playerid);
                SendClientMessage(playerid, colorYellow, "Tentando dar a partida.");
            }
            else
            {
                vehEngine[vehicleid] = 0;
                SendClientMessage(playerid, colorYellow, "Motor Desligado.");
            }
        }
me ajudou muito so tem uma coisa ele nao desliga qnd aperta o ctrl
Reply
#4

dentro do else adiciona:
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
Reply
#5

Quote:
Originally Posted by Kimossab
Посмотреть сообщение
dentro do else adiciona:
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
n foi
Reply
#6

altera o que esta dentro do else para:
pawn Код:
vehEngine[vehicleid] = 0;
        TogglePlayerControllable(playerid, 0);
        SendClientMessage(playerid, colorYellow, "Vehicle engine stopped");
Jб agora esse й um filterscript estupido...
Reply
#7

Quote:
Originally Posted by Kimossab
Посмотреть сообщение
altera o que esta dentro do else para:
pawn Код:
vehEngine[vehicleid] = 0;
        TogglePlayerControllable(playerid, 0);
        SendClientMessage(playerid, colorYellow, "Vehicle engine stopped");
Jб agora esse й um filterscript estupido...
nada '-'
Reply


Forum Jump:


Users browsing this thread: