SA-MP Forums Archive
Unlimited nitro doesn't work... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Unlimited nitro doesn't work... (/showthread.php?tid=75123)



Unlimited nitro doesn't work... - Remi-X - 29.04.2009

Script:
pawn Код:
new NitroTimer[MAX_PLAYERS]
new bool:NitroActive[MAX_PLAYERS];
forward public Nitro(playerid);

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys == 1 || newkeys == 9 || newkeys == 33 || newkeys & KEY_FIRE)
    {
        if(!IsPlayerInAnyVehicle(playerid) == true)
        {
            return 0
        }
        else
        {
            new vehicleid;
            vehicleid = GetPlayerVehicleID(playerid);
            new Car = GetPlayerVehicleID(playerid), Model = GetVehicleModel(Car);
            switch(Model)
            {
                case 446,432,448,452,424,453,454,461,462,463,468,471,430,472,449,473,481,484,493,495,509,510,521,538,522,523,532,537,570,581,586,590,569,595,604,611: return SendClientMessage(playerid, RED, "You can't add nitro to this vehicle!");
            }
            if(NitroActive[playerid] == false)
            {
                SendClientMessage(playerid, GRAY, "Nitro turned on.");
                NitroTimer[playerid] = SetTimer("Nitro", 19000, true);
                AddVehicleComponent(vehicleid, 1010);
                NitroActive[playerid] = true;
                return 1;
            }
            else
            {
                SendClientMessage(playerid, GRAY, "Nitro turned off.");
                KillTimer(NitroTimer[playerid]);
                RemoveVehicleComponent(vehicleid,1010);
                NitroActive[playerid] = false;
                return 1;
            }
        }      
    }
    return 1;
}

public Nitro(playerid)
{
    new vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInAnyVehicle(playerid) == 1)
    {
        RemoveVehicleComponent(vehicleid,1010);
        if(NitroActive[playerid] == true)
        {
            AddVehicleComponent(vehicleid, 1010);
            return 1;
        }
    }
    return 1;
Problem:
If i turn nitro on, everything is fine. But after 19 seconds, the nitro will stop. Why? I am removing, and THAN adding notro to my vehicle in the timer...

What's the problem?
And if i hold the fire button for more than 19 seconds, it WILL refill.. That's weard


Re: Unlimited nitro doesn't work... - Vince - 29.04.2009

Quote:
Originally Posted by Remi-X
Script:
pawn Код:
new NitroTimer[MAX_PLAYERS]
new bool:NitroActive[MAX_PLAYERS];
forward public Nitro(playerid);

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys == 1 || newkeys == 9 || newkeys == 33 || newkeys & KEY_FIRE)
pawn Код:
forward Nitro(playerid);
And, OnPlayerKeyStateChange works like this: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


Re: Unlimited nitro doesn't work... - Remi-X - 29.04.2009

Quote:
Originally Posted by Vince
Quote:
Originally Posted by Remi-X
Script:
pawn Код:
new NitroTimer[MAX_PLAYERS]
new bool:NitroActive[MAX_PLAYERS];
forward public Nitro(playerid);

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys == 1 || newkeys == 9 || newkeys == 33 || newkeys & KEY_FIRE)
pawn Код:
forward Nitro(playerid);
And, OnPlayerKeyStateChange works like this: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Don't work.. And OnPlayerKeyStateChange works good..