2 way command
#1

moO! how to make it so that /gods turns the health and armour back to 100 the /gods already turns armour and health to infinity i just wanna know how to get it back to like a normal player

pawn Код:
if(strcmp(cmdtext, "/gods", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE ON");
            SetPlayerArmour(playerid, INFINITY);
            SetPlayerHealth(playerid, INFINITY);
        }
        return 1;
    }
    else
    {
        if(strcmp(cmdtext, "/gods", true) == 0)
        {
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE OFF");
        }
    }
Reply
#2

Maybe, just a wild guess :
pawn Код:
new god[MAX_PLAYERS];


if(strcmp(cmdtext, "/gods", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(god[playerid] == 0)
            {
            god[playerid] = 1;
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE ON");
            SetPlayerArmour(playerid, INFINITY);
            SetPlayerHealth(playerid, INFINITY);
            }
           
            if(god[playerid] == 1)
            {
            god[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE OFF");
            }
        }
    return 1;
    }
Reply
#3

pawn Код:
new GodMode[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    GodMode[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/god", false))
    {
        if(IsPlayerAdmin(playerid))
        {
            if(GodMode[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_MAGENTA, "GOD MODE ON");
                SetPlayerArmour(playerid, INFINITY);
                SetPlayerHealth(playerid, INFINITY);
                GodMode[playerid] = 1;
            }
            else if(GodMode[playerid] == 1)
            {
                SendClientMessage(playerid, COLOR_MAGENTA, "GOD MODE OFF");
                SetPlayerHealth(playerid, 0);
                SetPlayerArmour(playerid, 0);
                GodMode[playerid] = 0;
            }
        }
        else SendClientMessage(playerid, COLOR_MAGENTA, "You are not an admin!"0;
    }
    return 0;
}
Reply
#4

Yeah that should work, anyway what did you define INFINITY as? i want something similar to this
Reply
#5

oops, sorry, forgot to add " == " anyways, use TheInnocentOnes code :P
Reply
#6

i defined the infinity

EDIT:ViruZZzZ_ChiLLL yours worked kinda just when /gods is turns on then right back off and theincorrectone just works kinda to just when you type /god it Says invalid command but command still works
Reply
#7

I didn't ask who defined it, i asked what it is defined as
Reply
#8

Well its because TheInnocentOne forgot to return 1;
add a return 1;

EDIT : Here :
pawn Код:
new god[MAX_PLAYERS]; // On top

public OnPlayerConnect(playerid)
{
  god[playerid] = 0;
  return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/gods", true) == 0)
  {
        if(IsPlayerAdmin(playerid))
        {
            if(god[playerid] == 0)
            {
            god[playerid] = 1;
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE ON");
            SetPlayerArmour(playerid, INFINITY);
            SetPlayerHealth(playerid, INFINITY);
            }
           
            if(god[playerid] == 1)
            {
            god[playerid] = 0;
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            SendClientMessage(playerid, COLOR_MAGENTA, "GODSMODE OFF");
            }
        }
    return 1;
    }
    return 0;
}
Also, I would recommend you to use dcmd :P
its easier + faster
Reply
#9

ah its easy

pawn Код:
#define INFINITY (Float:0x7F800000)
thats it then to setplayerhealth just

pawn Код:
SetPlayerHealth(playerid, INFINITY);
SetPlayerArmour(playerid, INFINITY);
the armour is just an addon for me xD
Reply
#10

what number is 0x7F800000? im not good with hex
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)