18.03.2014, 14:08
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);
}