[Tutorial] How to Use Variables to Prevent Abuse
#1

Hello, this is quick tutorial I decided to write because I like to write tutorials. This tutorial will teach you how to use variables to prevent abuse of a command, or restrict a command from other players.


So, first of all, we need to chose a variable name. You can easily do this by choosing anything that relates to the variables role as the name. Mine will be "RestrictCommand1" for I am restricting some players from using the first command in my script. Lets make this variable.
At the top of my script, below the includes, I will add:
pawn Код:
new RestrictCommand1[MAX_PLAYERS];

Now, we will make a command and in this command we will make sure that whoever has this variable set equal to 1, we will allow them to use the command.
pawn Код:
if(!strcmp("/givememoney", cmdtext, true)
{
     if(RestrictCommand1[playerid] == 1) //so if this equals one they're allowed to use it
     {
              GivePlayerMoney(playerid, 50000);  //this is what they are allowed to have/use
      }
      else
      {
               Kick(playerid);    //since they aren't allowed to use this, we'll kick them
      }
      return 1;
}

Now, we can easily set their variable by one or more to make sure they can use that command above by just typing anywhere in your script:
pawn Код:
RestrictCommand1[playerid] = 1;
or if we don't want them to use it after they used it:
pawn Код:
RestrictCommand1[playerid] = 0;
Hopefully this helps some people!
Reply


Messages In This Thread
How to Use Variables to Prevent Abuse - by Jacob_Venturas - 11.11.2010, 23:56
Re: How to Use Variables to Prevent Abuse - by The_Moddler - 11.11.2010, 23:58
Re: How to Use Variables to Prevent Abuse - by Hal - 12.11.2010, 00:00
Re: How to Use Variables to Prevent Abuse - by Jacob_Venturas - 12.11.2010, 00:01
Re: How to Use Variables to Prevent Abuse - by Steven82 - 12.11.2010, 00:11
Re: How to Use Variables to Prevent Abuse - by Hal - 12.11.2010, 00:26
Re: How to Use Variables to Prevent Abuse - by Jacob_Venturas - 12.11.2010, 05:42

Forum Jump:


Users browsing this thread: 1 Guest(s)