CMD:god(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
SetPlayerHealth(playerid, 9999999);
SetPlayerArmour(playerid, 9999999);
SendClientMessage(playerid, COLOR_WHITE, "God Mode {009900}[On]");
aGod[playerid] = 1;
}
else
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "God Mode {CC0000}[Off]");
aGod[playerid] = 0;
}
return 1;
}
new God[MAX_PLAYERS];
God[playerid] = 0;
PlayerInfo[playerid][pAdmin] >= 2
if(God[playerid] == 0)
{
//code to turn it on.
}
else
{
//code to turn it off.
}
CMD:god(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
if(aGod[playerid] == 0)
{
SetPlayerHealth(playerid, 9999999);
SetPlayerArmour(playerid, 9999999);
SendClientMessage(playerid, COLOR_WHITE, "God Mode {009900}[On]");
aGod[playerid] = 1;
}
else if(aGod[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "God Mode {CC0000}[Off]");
aGod[playerid] = 0;
}
else return SendClientMessage(playerid, 0xFF0000FF, "You are not authorised to use this command!");
}
return 1;
}
#define INFINITY (Float:0x7F800000) // Infinity!
public OnPlayerConnect( playerid )
{
aGod[ playerid ] = 0;
return 1;
}
CMD:god(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
if( aGod[ playerid ] == 0 )
{
SetPlayerHealth(playerid, INFINITY); // It works perfect with health
SetPlayerArmour(playerid, INFINITY); // I've never tried with armour, but it should work as well.
SendClientMessage(playerid, COLOR_WHITE, "God Mode {009900}[On]");
aGod[playerid] = 1;
}
else
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "God Mode {CC0000}[Off]");
aGod[playerid] = 0;
}
}
return 1;
}
Or you could also run a timer every 1 seconds the player who uses god. Health will increase back.
|