[Ajuda] Ligar/desligar motor.
#2

Fiz aqui para vocк й facil!
qualquer coisa falae!
PHP код:
public OnGameModeInit()
{
    
ManualVehicleEngineAndLights();
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    switch(
newkeys)
    {
        case 
KEY_YES:
        {
            if(
GetVehicleDriverID(vehicleid)==playerid)
            {
                if(
GetVehicleParams(vehicleidVEHICLE_PARAMS_ENGINE)== VEHICLE_PARAMS_ONligarcarro(playerid,0);
                else 
ligarcarro(playerid,1);                
            }
        }
    }
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
GetVehicleParams(vehicleidVEHICLE_PARAMS_ENGINE)== VEHICLE_PARAMS_OFFSendClientMessage(playeridBranco"Aperte [Y] Para desligar o veiculo!");
    }
}
stock ligarcarro(playerid,ligado);
{
    switch(
opcao)
    {
        case 
0:
        {
            
SendClientMessage(playeridBranco"Carro desligado!");
            
SetVehicleParams(vehicleidVEHICLE_PARAMS_ENGINEVEHICLE_PARAMS_OFF);
            
SetVehicleParams(vehicleidVEHICLE_PARAMS_LIGHTSVEHICLE_PARAMS_OFF);
        }
        case 
1:
        {
            
//if(GetVehicleHealthEx(vehicleid) <= 0)                                   return SendClientMessage(playerid, Amarelo, "Motor estб muito danificado!");
            //if(code de combustivel)  return SendClientMessage(playerid, Amarelo, "Sem combustivel");
            
SetVehicleParams(vehicleidVEHICLE_PARAMS_ENGINEVEHICLE_PARAMS_ON);
            
SetVehicleParams(vehicleidVEHICLE_PARAMS_LIGHTSVEHICLE_PARAMS_ON);
            
SendClientMessage(playeridVerde"Carro ligado!");
        }
    }
}
stock GetVehicleParams(vehicleidtype)
{
    new 
params[7];
    
GetVehicleParamsEx(vehicleidparams[0], params[1], params[2], params[3], params[4], params[5], params[6]);
    return 
params[type];
}
stock SetVehicleParams(vehicleidtypeset)
{
    new 
params[7];
    if(
GetVehicleParamsEx(vehicleidparams[0], params[1], params[2], params[3], params[4], params[5], params[6]))
    {
        
params[type] = set;
        
SetVehicleParamsEx(vehicleidparams[0], params[1], params[2], params[3], params[4], params[5], params[6]);
        return 
true;
    }
    return 
false;

Reply


Messages In This Thread
Ligar/desligar motor. - by ChEfIn - 15.01.2017, 22:07
Programando e Relaxando! - by RazorGuigo - 15.01.2017, 22:14

Forum Jump:


Users browsing this thread: 1 Guest(s)