Here you go!!
Made by me now(take credits if u want :P); pawn Код:
|
Originally Posted by Scrpting Help Rules
8. Do not post untested code.
|
CMD:fix(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "SpyBot: You are not in a vehicle!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, "SpyBot: Your vehicle has been successfully repaired!");
return 1;
}
//OnGameModeInit
SetTimer("Timer", 1000, true);
new bool:AutoFix[MAX_PLAYERS];
if(!strcmp("/afix", cmdtext, true))
{
if(AutoFix[playerid])
{
AutoFix[playerid] = false;
return SendClientMessage(playerid, COLOR, "Autofix stopped");
}
else
{
if(!IsPlayerInAnyVehicle(i)) return SendClientMessage(playerid, COLOR, "You need to be in a vehicle to start autofix");
AutoFix[playerid] = true;
return SendClientMessage(playerid, COLOR, "Autofix started");
}
return 1;
}
forward Timer();
public Timer()
{
new Float:health, var1;
for(new i = 0, m = GetMaxPlayers(); i < m; i++)
{
if(!IsPlayerConnected(i)) continue;
if(AutoFix[i] && IsPlayerInAnyVehicle(i))
{
var1 = GetPlayerVehicleID(i);
GetVehicleHealth(var1 , health);
if(health < 500) SetVehicleHealth(var1, 1000.0);
}
}
}
new AutoFixTimer[MAX_PLAYERS];
if(!strcmp("/afix", cmdtext, true))
{
if(AutoFixTimer[playerid])
{
KillTimer(AutoFixTimer[playerid]);
AutoFixTimer[playerid] = false;
return SendClientMessage(playerid, COLOR, "Autofix stoped");
}
else
{
if(!IsPlayerInAnyVehicle(i)) return SendClientMessage(playerid, COLOR, "You need to be in a vehicle to start autofix");
AutoFixTimer[playerid] = SetTimerEx("AutoFix", 1000, true, "i", playerid);
return SendClientMessage(playerid, COLOR, "Autofix started");
}
return 1;
}
forward AutoFix(playerid);
public AutoFix(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid), Float:health;
GetVehicleHealth(vid , health);
if(health < 500) SetVehicleHealth(vid , 1000.0);
}
}
CMD:autofix(playerid)
{
if(GetPVarInt(playerid,"Autofix"))
{
DeletePVar(playerid,"Autofix");
SendClientMessage(playerid,-1,"Autofix disabled!");
}
else
{
SetPVarInt(playerid,"Autofix",true);
SendClientMessage(playerid,-1,"Autofix enabled!");
}
return 1;
}
if(GetVehicleHealth(vehicleid) < 1000) if(GetPVarInt(playerid,"Autofix")) RepairVehicle(vehicleid);
new fixtimer[MAX_PLAYERS],bool:actived[MAX_PLAYERS];
CMD:autofix(playerid)
{
if(actived[playerid]) return SendClientMessage(playerid,-1,"disabled"),KillTimer(fixtimer[playerid]),actived[playerid] = false;
fixtimer[playerid] = SetTimerEx("fixt",1000,true,"i",playerid);
actived[playerid] = true;
SendClientMessage(playerid,-1,"actived")
return 1;
}
forward fixt(playerid);
public fixt(playerid)
{
if(!IsPlayerInAnyVehicle(playerid)) return 0;
RepairVehicle(GetPlayerVehicleID(playerid));
return 1;
}