#include <a_samp> #define FILTERSCRIPT forward AutoR(); new flying; #define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) public OnFilterScriptInit() { print("\n--------------------------------------"); print("Auto Repair loaded"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { flying = 0; new autofix; if(strcmp(cmdtext, "/funmodeon", true) == 0) { autofix = SetTimer("AutoR", 1000, 1); flying = 1; GameTextForAll("~g~Auto Fix is Enabled", 5000, 3); } if(strcmp(cmdtext, "/funmodeoff", true) == 0) { KillTimer(autofix); flying = 0; GameTextForAll("~r~Auto Fix is disabled. ]Kill Time!]", 5000, 3); } } public AutoR() { for(new playerid=0; playerid<MAX_PLAYERS; playerid++) { if(IsPlayerConnected(playerid)) { new Float:health, cid; if (IsPlayerInAnyVehicle(playerid)) { cid = GetPlayerVehicleID(playerid); GetVehicleHealth(cid, health); if (health < 999) { RepairVehicle(cid); SetVehicleHealth(cid,1000); } } } } return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (flying == 1) { //fly h button if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { if (PRESSED(KEY_CROUCH)) { new Float:x, Float:y, Float:z; GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z); SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3); } } } return 1; }
#include <a_samp>
#define FILTERSCRIPT
forward AutoR();
new flying;
new autofix;
// ... rest of code
I think you should define new autofix globally, so outside of OnPlayerCommandText, like this
pawn Код:
|