Autofix
#1

Hi frnds I have created Autofix script but there is no commands ok AutoFix but vehicle automatically get autofix can anyone create a command? (toggling command) /af, /autofix or anything u want...
for ex - /af (In-Game Text) AutoFix On /af (in-gametext) Autofix off... like that.. please...

Код:
forward AutoFix();
Код:
	//In GameModeInIt
	SetTimer("AutoFix", 1000, 1);
Код:
public AutoFix() {
	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 < 950) {
				    RepairVehicle(GetPlayerVehicleID(playerid));

				}
			}
		}
	}
	return 1;
}
can anyone make command /autofix (that players can toggles)
Reply
#2

Код:
new bFix[MAX_PLAYERS];

// AutoFix
public AutoFix() {
	for(new playerid=0; playerid<MAX_PLAYERS; playerid++) {
		if(IsPlayerConnected(playerid)) {
                    if(!bFix[playerid]) return 0; // Dont repair the vehicle
		    new Float:health, cid;
		    if (IsPlayerInAnyVehicle(playerid)) {
		    	cid = GetPlayerVehicleID(playerid);
				GetVehicleHealth(cid, health);
				if (health < 950) {
				    RepairVehicle(GetPlayerVehicleID(playerid));

				}
			}
		}
	}
	return 1;
}

// OnPlayerConnect
function OnPlayerConnect(playerid)
{
    bFix[playerid] = false;
    return 1;
}

// OnPlayerCommandText
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/autofix", cmdtext, true) == 0)
    {
        if(bFix[playerid])
        {
            bFix[playerid] = false;
        }
        else
        {
            bFix[playerid] = true;
        }
        return 1;
    }
    return 1;
}
Reply
#3

thank you so much ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)