How can i make a /god command for players?
#1

How can i make a /god command for players? usinz ZCMD
Reply
#2

You can do:

Код:
new GodMode[MAX_PLAYERS];
CMD:god(playerid, params[])
{
SetPlayerHealth(playerid, 99999);
GodMode[playerid] = true;
}
If your using 0.3z do:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(GodMode[playerid] == true) return 0;
}
if using 0.3x or below:

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(GodMode[playerid] == true) return 0;
}
By returning 0 the player won't take the damage. They should never go below 99999 in health. Put:

Код:
if(!IsPlayerAdmin(playerid)) return 0;
If you want to restrict the command to admins(RCON).
Reply
#3

i have made this now:
first of all add this near the other enums and news:
pawn Код:
new Godmode[MAX_PLAYERS];
Under OnPlayerConnect
pawn Код:
Godmode[playerid] = 0;
and the command:
if you want the command only for admins:
pawn Код:
CMD:god(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
        if(Godmode[playerid] == 0)
        {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
        }
        if(Godmode[playerid] == 1)
        {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
and for all of the players:
pawn Код:
CMD:god(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Godmode[playerid] == 0)
        {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
        }
        if(Godmode[playerid] == 1)
        {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not logged in");
    }
    return 1;
}
and under OnPlayerTakeDamage:
0.3z
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
        if(Godmode[playerid] == 1) return 0;
}
0.3x:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
        if(Godmode[playerid] == 1) return 0;
}
Reply
#4

Quote:
Originally Posted by XK
Посмотреть сообщение
i have made this now:
first of all add this near the other enums and news:
pawn Код:
new Godmode[MAX_PLAYERS];
Under OnPlayerConnect
pawn Код:
Godmode[playerid] = 0;
and the command:
if you want the command only for admins:
pawn Код:
CMD:god(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
        if(Godmode[playerid] == 0)
        {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
        }
        if(Godmode[playerid] == 1)
        {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
and for all of the players:
pawn Код:
CMD:god(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Godmode[playerid] == 0)
        {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
        }
        if(Godmode[playerid] == 1)
        {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not logged in");
    }
    return 1;
}
and under OnPlayerTakeDamage:
0.3z
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
        if(Godmode[playerid] == 1) return 0;
}
0.3x:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
        if(Godmode[playerid] == 1) return 0;
}
When i use /god a message shows up you have enabled god and under it you have disabled god
Reply
#5

pawn Код:
CMD:godon(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
            return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
pawn Код:
CMD:godoff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
            return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
i have checked this code and it worked for me now
Reply
#6

and i have tested the first code that i wrote and it worked fine
Reply
#7

Quote:
Originally Posted by XK
Посмотреть сообщение
pawn Код:
CMD:godon(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
            Godmode[playerid] = 1;
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SendClientMessage(playerid, -1, "You have enabled the god mode");
            return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
pawn Код:
CMD:godoff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
    {
            Godmode[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            SendClientMessage(playerid, -1, "You have disabled the god mode");
            return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not an admin");
    }
    return 1;
}
i have checked this code and it worked for me now
Thank you +REP
Reply
#8

For one /god command:

pawn Код:
new bool:GodModeActive[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    if(GodModeActive[playerid] ? SetPlayerHealth(playerid, (Float:0x7F800000)) : SetPlayerHealth(playerid, 100.0)) {}
    return 1;
}

CMD:god(playerid, params[])
{
    //if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not an admin."); //Change this to your admin variable.
    //Uncomment the line above if you want to restrict this command to admins only.
    if(GodModeActive[playerid])
    {
        GodModeActive[playerid] = false;
        SendClientMessage(playerid, -1, "God mode disabled.");
        SetPlayerHealth(playerid, 100.0);
    }
    else if(!GodModeActive[playerid])
    {
        GodModeActive[playerid] = true;
        SendClientMessage(playerid, -1, "God mode activated.");
        SetPlayerHealth(playerid,(Float:0x7F800000));
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)