20.07.2013, 00:55
(
Последний раз редактировалось RedFusion; 20.07.2013 в 01:26.
)
This script replaces the NOS canister continuously (if there is one installed) in your vehicle while you hold the nos activation button.
It starts when you press the nos button and stops when you release it.
[ame]http://www.youtube.com/watch?v=kBiuQBubfBI&[/ame]
pawn Код:
#include <a_samp>
new NosTimer[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("HoldNos Loaded");
return 1;
}
public OnFilterScriptExit()
{
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) KillTimer(NosTimer[playerid]);
return 1;
}
public OnPlayerDisconnect(playerid) KillTimer(NosTimer[playerid]);
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER) KillTimer(NosTimer[playerid]);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid, nos;
vehicleid = GetPlayerVehicleID(playerid);
nos = GetVehicleComponentInSlot(vehicleid, CARMODTYPE_NITRO);
if(nos == 0) return 1;
if( ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) || ((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION)) ) //Press
{
KillTimer(NosTimer[playerid]);
NosTimer[playerid] = SetTimerEx("UpdatePlayerNos", 2000, true, "i", playerid);
}
if( ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)) || ((oldkeys & KEY_ACTION) && !(newkeys & KEY_ACTION)) ) //Release
{
RemoveVehicleComponent(vehicleid, nos);
AddVehicleComponent(vehicleid, nos);
KillTimer(NosTimer[playerid]);
}
}
return 1;
}
forward UpdatePlayerNos(playerid);
public UpdatePlayerNos(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid, nos;
vehicleid = GetPlayerVehicleID(playerid);
nos = GetVehicleComponentInSlot(vehicleid, CARMODTYPE_NITRO);
if(nos == 0) return 1;
AddVehicleComponent(vehicleid, nos);
}
return 1;
}