17.06.2011, 09:36
I'm going to show you an example using ZCMD.
So at the top of your script your going to make an array called
Then were going to make a "private" command.
And here is command to allow the player to use the "private" command
*Also, how the array works is its called canUse and then the bracks [] contain a number, which we use for our playeird, so it sets canUse[NUMBER HERE] to our playerid, so it stays unique to that player.. so make sure to also put this OnPlayerDisconnect
^ We do this because say I'm id 0, then canUse[playerid] becomes canUse[0] and if I disconnect without making it equal 0 again, if someone joins as id 0, then canUse[0] would still be equal to 1, assuming I had done /allowcmd.
So by doing what I show above, it makes the variable (array) equal to 0 for the new joiner.
So at the top of your script your going to make an array called
pawn Код:
canUse[MAX_PLAYERS];
pawn Код:
CMD:sayhello(playerid, params[])
{
if(canUse[playerid] == 0) return SendClientMessage(playerid, 0xFFFF00AA, "You can't use this command!"); //Checks if the array we made was equal to 0, if so sends that client message
SendClientMessage(playerid, 0xFFFF00AA, "Hello!"); //This will be sent if the array canUse[playerid] is not 0, so it can be 1, 2, etc.
return 1;
}
pawn Код:
CMD:allowcmd(playerid, params[])
{
if(canUse[playerid] == 1) return SendClientMessage(playerid, 0xFFFF00AA, "You can already use the private commands!"); //Checks if they can already use the commands or not
canUse[playerid] = 1; //Sets the array to 1, allowing the sayhello command to work
return 1;
}
*Also, how the array works is its called canUse and then the bracks [] contain a number, which we use for our playeird, so it sets canUse[NUMBER HERE] to our playerid, so it stays unique to that player.. so make sure to also put this OnPlayerDisconnect
pawn Код:
canUse[playerid] = 0;
So by doing what I show above, it makes the variable (array) equal to 0 for the new joiner.