SA-MP Forums Archive
2 way command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 2 way command (/showthread.php?tid=158554)



2 way command - willsuckformoney - 10.07.2010

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");
        }
    }



Re: 2 way command - ViruZZzZ_ChiLLL - 10.07.2010

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;
    }



Re: 2 way command - TheInnocentOne - 10.07.2010

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;
}



Re: 2 way command - Cameltoe - 10.07.2010

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


Re: 2 way command - ViruZZzZ_ChiLLL - 10.07.2010

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


Re: 2 way command - willsuckformoney - 10.07.2010

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


Re: 2 way command - Cameltoe - 10.07.2010

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


Re: 2 way command - ViruZZzZ_ChiLLL - 10.07.2010

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


Re: 2 way command - willsuckformoney - 10.07.2010

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


Re: 2 way command - Cameltoe - 10.07.2010

what number is 0x7F800000? im not good with hex