God mode
#1

pawn Код:
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;
}
I tried this can not return to the off mode.
Reply
#2

Make a new variable at the top:
pawn Код:
new God[MAX_PLAYERS];
in OnPlayerConnect and OnPlayerDeath and OnPlayerDisconnect:
pawn Код:
God[playerid] = 0;
Instead of this in the if statement:
pawn Код:
PlayerInfo[playerid][pAdmin] >= 2
do this:
pawn Код:
if(God[playerid] == 0)
{
 //code to turn it on.
}
else
{
  //code to turn it off.
}
Hope this helped.
Reply
#3

pawn Код:
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;
}
Reply
#4

YoYo123, he already uses a variable to toggle wether it's on or not.
TIP: You can use Infinity float instead of 9999999.
pawn Код:
#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;
}
Reply
#5

Or you could also run a timer every 1 seconds the player who uses god. Health will increase back.
Reply
#6

Quote:
Originally Posted by Romel
Посмотреть сообщение
Or you could also run a timer every 1 seconds the player who uses god. Health will increase back.
No..No..
I don't recomment it at all. People must use as less as timers they can, there's no point of adding a timer for god mode since there's infinity float for it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)