Key_Fire on vehicle
#1

hi there! im doing a Rechargable Nitro sistem, i'll try to explain my situation and the "problem" that i have.

well, the sistem is really simple, first you need to put the command "/ponernitro" so the vehicle where u are on will get a variable that identify that this vehicle id has nitro.

PHP код:
if (strcmp("/ponernitro"cmdtexttrue10) == 0)
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            
SendClientMessage(playerid, -1"No estбs en ningъn vehнculo.");
        }
        else
        {
            if(
CargasNitro[vehicleid] >= 1)
            {
                
SendClientMessage(playerid, -1"El coche ya tiene nitro o aъn le quedan cargas");
            }
            else
            {
                
TieneNitro[vehicleid] = 1// this is the variable that identify if the vehicle have nitro or not, so u can use the command /nos.
                 
SendClientMessage(playerid, -1"Aсadiste un nitro al vehнculo, tiene 3 cargas. para usarlo usa /nos");
                 
CargasNitro[vehicleid] = 3;
            }
        }
        return 
1;
    } 
So, after that, u need to put the cmd "/nos" that will add nitro component, so u can use nitro normally.

PHP код:
    if (strcmp("/nos"cmdtexttrue10) == 0)
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            
SendClientMessage(playerid, -1"No estбs en ningъn vehнculo.");
        }
        else
        {
            if(
TieneNitro[vehicleid] == 1)
            {
                if(
CargasNitro[vehicleid] >= 1)
                {
                    
AddVehicleComponent(vehicleid1010);
                    new 
msg[128], pName[MAX_PLAYER_NAME];
                    
GetPlayerName(playeridpNamesizeof(pName));
                    
format(msgsizeof(msg), "** %s subiу el protector del botуn del nitro, preparandose para activar este en cualquier momento."pName);
                    
SendClientMessage(playerid,0xFFB000B0msg);
                    
ActivoNitro[playerid] = 1;
                }
                else
                {
                    
SendClientMessage(playerid, -1"Tu auto no tiene cargas de nitro.");
                }
            }
            else
            {
                
SendClientMessage(playerid, -1"Tu auto NO tiene nitro.");
            }
         }
        return 
1;
    } 
And, when u press the KEY_FIRE on a vehicle that have TieneNitro = 1, and Nitro component this will gonna happen:

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
vehicleid;
    
vehicleid GetPlayerVehicleID(playerid);
    
    if(
newkeys KEY_FIRE)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            if(
TieneNitro[vehicleid] == 1)
            {
                if(
GetVehicleComponentInSlot(vehicleid,GetVehicleComponentType(1010)) == 1010)
                {
                    if(
ActivoNitro[playerid] == 1)
                    {
                    
SendClientMessage(playerid, -1"ЎACTIVASTE EL NITRO!");
                    
SetTimerEx("UsandoNitro"20000false"d"playerid);
                    }
                }
            }
        }
    }
    return 
1;

UsandoNitro callback:

PHP код:
forward UsandoNitro(playerid);
public 
UsandoNitro(playerid)
{
    new 
vehicleid;
    
vehicleid GetPlayerVehicleID(playerid);
    
SendClientMessage(playerid, -1"Tu nitro se acaba y ahora tiene un uso menos.");
    
RemoveVehicleComponent(vehicleid,1010);
    
CargasNitro[vehicleid] -= 1;

But, the problem is that u can use or active nitro when u push the left ctrl button and the nitro will execute, but, u can use only ctrl button and u will can use nitro infinite times, so, how can i do that the system detect the ctrl left key?

sorry for my english btw!
Reply
#2

PHP код:
[...]
    
    if((
newkeys KEY_FIRE) || (newkeys KEY_ACTION))
[...] 
i "fixed" it!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)