SA-MP Forums Archive
Blocking a CMD - 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)
+--- Thread: Blocking a CMD (/showthread.php?tid=425919)



Blocking a CMD - LeeXian99 - 27.03.2013

Well, I have another question, I think this is related to /god. In a DM, you can use /god, but I want it to be blocked in DM, how to do it?

pawn Код:
CMD:god(playerid,params[])
{
    if(God[playerid] == false)
    {
        SetPlayerHealth(playerid, 100000.0);
        God[playerid] = true;
        return SendClientMessage(playerid, yellow, "Godmode has been enabled!");
    }
    else
    if(God[playerid] == true)
    {
        God[playerid] = false;
        SetPlayerHealth(playerid, 100.0);
        return SendClientMessage(playerid, red, "Godmode has been disabled!");
    }
   
    if(InDM[playerid] == 1) //I've no idea how to do it here
    {
   
    }
    return 1;
}



Re: Blocking a CMD - RajatPawar - 27.03.2013

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
   if(InDM[playerid] == 1)
   {
      return SendClientMessage(playerid, -1, "You can't use commands in a DM match!");
    }
    else return 1;
}
Use this by comparing cmdtext to god, or under InDM, just return 0.


Re: Blocking a CMD - Neil. - 27.03.2013

pawn Код:
CMD:god(playerid,params[])
{
    if(InDM[playerid] == 0)
    {
        if(God[playerid] == false)
        {
            SetPlayerHealth(playerid, 100000.0);
            God[playerid] = true;
            return SendClientMessage(playerid, yellow, "Godmode has been enabled!");
        }
        else if(God[playerid] == true)
        {
            God[playerid] = false;
            SetPlayerHealth(playerid, 100.0);
            return SendClientMessage(playerid, red, "Godmode has been disabled!");
        }
    }
    else if(InDM[playerid] == 1) return SendClientMessage(playerid, -1, "You are not allowed to use this in the DM Arena"); //Change this to whatever you want
    return 1;
}
EDIT: Well, Rajat beat me to it.