make commands in SELF-ONLY commands
#2

Hi,

I'll do this for you:

Here we got the /myskin [SkinID] command:
pawn Код:
if(strcmp(cmd, "/myskin", true) == 0)
{
    if(LastMySkin[playerid]+600 > gettime()) return SendClientMessage(playerid, COLOR_GRAD2, "ERROR: You can only use this command once every 10 minutes!"); //600 seconds = 10 minutes
    //I wouldn't use IsPlayerConnected at commands, because a player who is not connected won't type any commands.
    //As there is no second parameter, we can use this command without strtok.
    if(!strlen(cmdtext[strlen(cmd)+1]) //If nothing follows after /myskin (The parameter).
    {
        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /myskin [SkinID]");
        return 1;
    }
    new skin; //We take a new variable
    skin = strval(cmdtext[strlen(cmd)+1]); //and set the value (integer) of the parameter into it.
    if(skin > 299 || skin < 1) return SendClientMessage(playerid, COLOR_GREY, "Wrong skin ID!"); //Checks if valid SkinID
    if(PlayerInfo[playerid][pDonateRank] >= 2) //Checks for the donation Rank
    {
        //Executes the actual command
        PlayerInfo[playerid][pChar] = skin;
        format(string, sizeof(string), "Your changed your skin to %d", skin);
        SendClientMessage(para1, COLOR_WHITE, string);
        SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);
        LastMySkin[playerid] = gettime(); //Checks when the player typed the command (This is better than timers).
    }
    //Returns an error message if the Rank is too low.
    else SendClientMessage(playerid, COLOR_GRAD1, "ERROR: You need to be Donator Rank #2 to use this command. Please check /donate .");
    return 1;
}
That would be the command, no you need to define the new Player-Variable 'LastMySkin':
pawn Код:
//Just place this at top of your GameMode or FilterScript, whatever you use...
new LastMySkin[MAX_PLAYERS];
And last but not least, we set the variable to 0 when the player connects:
pawn Код:
//Under OnPlayerConnect:
LastMySkin[playerid] = 0;
I hope I have explained everything, and that I haven't forgotten anything for the command, by writing the explanations.

I hope this helps you.
If you have any questions, feel free to ask.

Regards,
Jeffry
Reply


Messages In This Thread
make commands in SELF-ONLY commands - by rekatluos - 23.09.2011, 09:15
Re: make commands in SELF-ONLY commands - by Jeffry - 23.09.2011, 10:29
Re: make commands in SELF-ONLY commands - by rekatluos - 23.09.2011, 10:35

Forum Jump:


Users browsing this thread: 1 Guest(s)