SA-MP Forums Archive
God mode - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: God mode (/showthread.php?tid=398082)



God mode - Scott Zulkifli - 08.12.2012

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.


Re: God mode - YoYo123 - 08.12.2012

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.


Re: God mode - Threshold - 08.12.2012

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;
}



Re: God mode - Konstantinos - 08.12.2012

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;
}



Re: God mode - JaKe Elite - 08.12.2012

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


Re: God mode - Konstantinos - 08.12.2012

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.