[FilterScript] /god command for admins
#8

Quote:
Originally Posted by iGetty
View Post
There's plenty different ways to create this
Yep. Here's an example:

pawn Code:
// Creating global player var. We'll use it later to check if player has god mode activated.
new
    bool: GodMode[MAX_PLAYERS char];
// Our timer
static
    GodTimer;
pawn Code:
// Simple god command
CMD:god(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) // Fixed typo
        return SendClientMessage(playerid, -1, "Nope.");
    GodMode{playerid} = !GodMode{playerid};
    SendClientMessage(playerid, -1, GodMode{playerid} ? ("God Mode activated!") : ("God Mode disabled!"));
    return 1;
}
pawn Code:
// Now we're gonna create 2 secs timer to check if player has god mode activated and fix their health.
// 2 secs timer is ok so don't worry, it's not gonna lag.

forward GodModeCheck();
public GodModeCheck()
{
    foreach(new i : Player)
    {
        if (GodMode{i} == true)
        {
            SetPlayerHealth(i, 100); // No need for 1k
        }
    }
    return 1;
}
// Now we're gonna place under OnGameModeInit()

public OnGameModeInit()
{
    GodTimer = SetTimer("GodModeCheck", 1000, true); // 1 sec timer.
    return 1;
}

public OnGameModeExit()
{
    KillTimer(GodTimer);
    return 1;
}
Reply


Messages In This Thread
/god command for admins - by HurtLocker - 12.03.2013, 18:39
Re: /god command for admins - by Bicentric - 12.03.2013, 18:43
Re: /god command for admins - by HurtLocker - 12.03.2013, 18:52
Re: /god command for admins - by Private200 - 12.03.2013, 18:54
Re: /god command for admins - by HurtLocker - 12.03.2013, 18:58
Re: /god command for admins - by iGetty - 12.03.2013, 19:00
Re: /god command for admins - by Private200 - 13.03.2013, 18:24
Re: /god command for admins - by Djole1337 - 13.03.2013, 18:39
Re: /god command for admins - by HurtLocker - 14.03.2013, 21:33
Re: /god command for admins - by Djole1337 - 15.03.2013, 11:02

Forum Jump:


Users browsing this thread: 3 Guest(s)