20.04.2009, 00:28
I saw in a server when you press 2 you get x10 nitro, how can I do this?
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SUBMISSION)
{
if(IsPlayerInAnyVehicle(playerid))
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}
return 1;
}
new bool: NitroActive[MAX_PLAYERS]; IsPlayerInInvalidNosVehicle(playerid,vehicleid) { #define MAX_INVALID_NOS_VEHICLES 29 new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] = { 581,523,462,521,463,522,461,448,468,586, 509,481,510,472,473,493,595,484,430,453, 452,446,454,590,569,537,538,570,449 }; vehicleid = GetPlayerVehicleID(playerid); if(IsPlayerInVehicle(playerid,vehicleid)) { for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++) { if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i]) { return true; } } } return false; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == KEY_SUBMISSION) { if(IsPlayerInAnyVehicle(playerid)) { if(!IsPlayerInInvalidNosVehicle(playerid, GetPlayerVehicleID(playerid))) { if(NitroActive[playerid] == false) { AddVehicleComponent(GetPlayerVehicleID(playerid),1010); SendClientMessage(playerid,COLOR_BASIC,"Nitro: On."); GameTextForPlayer(playerid,"+Nitro!", 1000, 1); PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0); NitroActive[playerid] = true; } } else { SendClientMessage(playerid, COLOR_RED, "Can't Add Nitro to this Vehicle."); } } } }