Private Commands
#5

I'm going to show you an example using ZCMD.

So at the top of your script your going to make an array called
pawn Код:
canUse[MAX_PLAYERS];
Then were going to make a "private" command.

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;
}
And here is command to allow the player to use the "private" command

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;
^ 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.
Reply


Messages In This Thread
Private Commands - by Panormitis - 17.06.2011, 06:47
Re: Private Commands - by Gamer_Z - 17.06.2011, 06:54
Re: Private Commands - by Panormitis - 17.06.2011, 07:22
Re: Private Commands - by Panormitis - 17.06.2011, 09:20
Re: Private Commands - by PrawkC - 17.06.2011, 09:36
Re: Private Commands - by Lorenc_ - 17.06.2011, 09:55
Re: Private Commands - by PrawkC - 17.06.2011, 09:58
Re: Private Commands - by Gamer_Z - 17.06.2011, 09:58
Re: Private Commands - by Double-O-Seven - 17.06.2011, 10:17
Re: Private Commands - by Lorenc_ - 17.06.2011, 10:45

Forum Jump:


Users browsing this thread: 2 Guest(s)