11.11.2010, 23:56
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:
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.
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:
or if we don't want them to use it after they used it:
Hopefully this helps some people!
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;
pawn Код:
RestrictCommand1[playerid] = 0;