Simple help me please Godmode
#9

Don't use these Godmodes above! This is the right way to make a god command:

pawn Код:
//At top
#include <zcmd> //Credits to Zeex

new HasGod[MAX_PLAYERS];

public OnPlayerConnect(playerid) //This is a callback
{
    HasGod[playerid] = 0;
    return 1;
}
//Otside ANY callback
CMD:god(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(HasGod[playerid] == 0)
        {
            HasGod[playerid] = 1;
            SendClientMessage(playerid, -1, "God mode turned on!");
        }
        else if(HasGod[playerid] == 1)
        {
            HasGod[playerid] = 0;
            SendClientMessage(playerid, -1, "God mode turned off!");
        }
    }
    else return SendClientMessage(playerid, -1, "You are not an admin");
    return 1;
}

public OnPlayerUpdate(playerid) //this is a callback
{
    if(HasGod[playerid] == 1)
    {
        SetTimer("SetHealth", 100, true);
    }
    return 1;
}

forward SetHealth(playerid);
public SetHealth(playerid) //this is a callback
{
    SetPlayerHealth(playerid, 100);
    return 1;
}
The other god commands won't hold all the time, after some time, you will die. e.g. get shoot by a minigun would kill you after like 30 seconds or more. Mine can't kill you and it's infinity. The timer is to prevent possible lag, you can set it to 1 second so there's even lower chance to get lag.
Reply


Messages In This Thread
Simple help me please Godmode - by Davz*|*Criss - 02.08.2011, 10:51
Re: Simple help me please Godmode - by Wesley221 - 02.08.2011, 10:54
Re: Simple help me please Godmode - by Davz*|*Criss - 02.08.2011, 10:55
Re: Simple help me please Godmode - by Wesley221 - 02.08.2011, 10:57
Re: Simple help me please Godmode - by Davz*|*Criss - 02.08.2011, 10:58
Re: Simple help me please Godmode - by Wesley221 - 02.08.2011, 10:59
Re: Simple help me please Godmode - by Davz*|*Criss - 02.08.2011, 11:02
Re: Simple help me please Godmode - by iPLEOMAX - 02.08.2011, 11:04
AW: Simple help me please Godmode - by samtey - 02.08.2011, 11:12
Re: Simple help me please Godmode - by iPLEOMAX - 02.08.2011, 11:16

Forum Jump:


Users browsing this thread: 1 Guest(s)