[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
#2

Well, very basic, also, for this types of things, it's better to use booleans, since they are only true or false, and they don't get messed up.

Also, this:

pawn Код:
if (strcmp("/givemeadmin", cmdtext, true, 10) == 0)
Should be:

pawn Код:
if(!strcmp("/givemeadmin", cmdtext, true)
Reply
#3

But this just disables the whole command. And to prevent abuse, use if statements such as if(IsPlayerAdmin to prevent 'abuse', but allow a certain player to still use the command.

This should be for disabling commands.
Reply
#4

Quote:
Originally Posted by The_Moddler
Посмотреть сообщение
Well, very basic, also, for this types of things, it's better to use booleans, since they are only true or false, and they don't get messed up.

Also, this:

pawn Код:
if (strcmp("/givemeadmin", cmdtext, true, 10) == 0)
Should be:

pawn Код:
if(!strcmp("/givemeadmin", cmdtext, true)
Wow, now I think using true or false is better, but GodFather has taught me to use numerical values. I should start using boolean, since I am always getting mixed up and causing so many bugs! Thanks.

Quote:
Originally Posted by Hal
Посмотреть сообщение
But this just disables the whole command. And to prevent abuse, use if statements such as if(IsPlayerAdmin to prevent 'abuse', but allow a certain player to still use the command.

This should be for disabling commands.
I think you're quite retarded, sir, especially from seeing your last response to my post you made. See, what I am doing is restricting the command to be used by others, unless they have there variable set at one. Of course this command will be disabled for some, or maybe all because they don't have their variables set to 1. Please, read my posts before you start accusing me of false problems in my tutorials.
Reply
#5

This is very simple, i would of thought even basic .pawn scripters would know this..oh well good job i guess

6/10 maybe just 5/10
Reply
#6

Quote:
Originally Posted by Jacob_Venturas
Посмотреть сообщение
I think you're quite retarded, sir, especially from seeing your last response to my post you made. See, what I am doing is restricting the command to be used by others, unless they have there variable set at one. Of course this command will be disabled for some, or maybe all because they don't have their variables set to 1. Please, read my posts before you start accusing me of false problems in my tutorials.
Just unneeded variables that can be replaced with more specific ones.

Don't try to flame me by calling me retarded, you will just loose in a flame war.

Quote:

tutorials.

Correction- Tutorial*
Reply
#7

Quote:
Originally Posted by Steven82
Посмотреть сообщение
This is very simple, i would of thought even basic .pawn scripters would know this..oh well good job i guess

6/10 maybe just 5/10
Some basic scripters don't know how to use variables at all. I also said I wanted to write a tutorial because I like to write tutorials. Thanks for the rating but this isn't a contest to see whose tutorial is the best on here.

Quote:
Originally Posted by Hal
Посмотреть сообщение
Just unneeded variables that can be replaced with more specific ones.

Don't try to flame me by calling me retarded, you will just loose in a flame war.


Correction- Tutorial*
Thank you for your comments. Leave this thread, retard.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)