Quote:
Originally Posted by CyberGhost
With enable/disable
Edited ur code:
pawn Код:
//Top of script new AutoFix[MAX_PLAYERS];
//OnGameModeInit SetTimer("AutoRepair", 1000, 1);
//OnPlayerConnect AutoFix[playerid] = 0;
//Command COMMAND:autorepair(playerid, params[]) { if(AutoFix[playerid] == 0) { AutoFix[playerid] = 1; SendClientMessage(playerid, COLOR_GREEN, "( ! ) You turned on autorepair."); } else { AutoFix[playerid] = 0; SendClientMessage(playerid, COLOR_GREEN, "( ! ) You turned off autorepair."); } return 1; }
//Anywhere in your script but not in other Callbacks :P forward AutoRepair(); public AutoRepair() { for(new i = 0; i < MAX_PLAYERS; i++) { new Float:VH; GetVehicleHealth(GetPlayerVehicleID(i), VH); if(AutoFix[i] == 1) { if(IsPlayerInAnyVehicle(i) && VH < 1000) { RepairVehicle(GetPlayerVehicleID(i)); } } } return 1; }
My code:
pawn Код:
new AutoFix[MAX_PLAYERS];
public OnPlayerConnect(playerid) { AutoFix[playerid] = 0; return 1; }
COMMAND:autorepair(playerid, params[]) { if(AutoFix[playerid] == 0) { AutoFix[playerid] = 1; SendClientMessage(playerid, COLOR_GREEN, "( ! ) You turned on autorepair."); } else { AutoFix[playerid] = 0; SendClientMessage(playerid, COLOR_GREEN, "( ! ) You turned off autorepair."); } return 1; }
public OnPlayerUpdate(playerid) { if(AutoFix[playerid] == 1 && IsPlayerInAnyVehicle(playerid)) { RepairVehicle(GetPlayerVehicleID(playerid)); } return 1; }
|
thank you alot i changed your callback a bit and now it works