02.08.2011, 11:12
Don't use these Godmodes above! This is the right way to make a god command:
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.
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;
}