Help with if pressed and if released
#3

Now you only need to add some security checks and done
pawn Код:
// global
new
    gSpeedTimer[MAX_PLAYERS] = {-1, ...}
;
// OnPlayerKeyStateChange
    if(PRESSED(KEY_SPRINT)) {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
            gSpeedTimer[playerid] = SetTimerEx("GTSpeed", 1000, true, "i", GetPlayerVehicleID(playerid));
        }
    }
    if(RELEASED(KEY_SPRINT)) {
        if(gSpeedTimer[playerid] != -1) {
            KillTimer(gSpeedTimer[playerid]);
            gSpeedTimer[playerid] = -1;
        }
    }
// OnPlayerStateChange
    if(oldstate == PLAYER_STATE_DRIVER) {
        if(gSpeedTimer[playerid] != -1) {
            KillTimer(gSpeedTimer[playerid]);
            gSpeedTimer[playerid] = -1;
        }
    }
//
forward GTSpeed(vehicleid);
public GTSpeed(vehicleid) {
    const
        Float: multiplier = 1.1
    ;
    new
        Float: X,
        Float: Y,
        Float: Z
    ;
    GetVehicleVelocity(vehicleid, X, Y, Z);
    SetVehicleVelocity(vehicleid, X * multiplier, Y * multiplier, Z * multiplier);
}
Reply


Messages In This Thread
Help with if pressed and if released - by ignas1125 - 18.03.2014, 13:36
Re: Help with if pressed and if released - by Sascha - 18.03.2014, 13:59
AW: Help with if pressed and if released - by Nero_3D - 18.03.2014, 14:08
Re: Help with if pressed and if released - by ignas1125 - 18.03.2014, 14:27

Forum Jump:


Users browsing this thread: 1 Guest(s)