28.02.2017, 17:13
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.
So, after that, u need to put the cmd "/nos" that will add nitro component, so u can use nitro normally.
And, when u press the KEY_FIRE on a vehicle that have TieneNitro = 1, and Nitro component this will gonna happen:
UsandoNitro callback:
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!
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", cmdtext, true, 10) == 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;
}
PHP код:
if (strcmp("/nos", cmdtext, true, 10) == 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(vehicleid, 1010);
new msg[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(msg, sizeof(msg), "** %s subiу el protector del botуn del nitro, preparandose para activar este en cualquier momento.", pName);
SendClientMessage(playerid,0xFFB000B0, msg);
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;
}
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
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", 20000, false, "d", playerid);
}
}
}
}
}
return 1;
}
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;
}
sorry for my english btw!