09.11.2011, 15:38
Quote:
Kostas: that's not optimised at all AND it will NOT work correctly.
1) If you test that the player is a driver, then why checking if he's in a vehicle? 2) Use one if inside another if instead of using "&&" 3) newkays==KEY_SUBMISSION will work very bad Here's something that works faster, that is easier to read and that works better: Код:
#define KeyPressed(%0) (newkeys & %0) && !(oldkeys & %0) public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { if (KeyPressed(KEY_SUBMISSION)) RepairVehicle(GetPlayerVehicleID(playerid)); } return 1; } |
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
if (newkeys & KEY_SUBMISSION) RepairVehicle(GetPlayerVehicleID(playerid));
}
return 1;
}