/skin command
#3

Sure. Here's a skin command with explainations:

pawn Код:
if(!strcmp(cmdtext, "/skin", true, 5)) // 5 is the length of "/skin" (without quotes)
{
    if(!cmdtext[5]) // if it's only 5 characters (/skin is) tell them the right usage of it
    {
        SendClientMessage(playerid, COLOR_RED, "COST: $20000");
        return SendClientMessage(playerid, -1, "USAGE: /skin [skinid]");
    }
    // Here they entered something after /skin
    // cmdtext[6] is what the player typed after /skin but we can't use it because it's a string so
    // use strval to get the value of cmdtext string
    new skinid = strval(cmdtext[6]);
    if(skinid < 0 || skinid > 299) // IMPORTANT: check if the skin id below 0 or above 299 because it can cause a crash
        return SendClientMessage(playerid, -1, "ERROR: Invalid skin id!");

    if(GetPlayerMoney(playerid) < 20000)
        return SendClientMessage(playerid, COLOR_RED, "ERRO: You don't have enough money to change your skin.");

    GivePlayerMoney(playerid, -20000);
    SetPlayerSkin(playerid, skinid);
    return 1;
}
You may like to check this article about using strcmp for creating commands with multiple parameters.
Reply


Messages In This Thread
/skin command - by Arthur_K - 02.08.2012, 04:27
Re: /skin command - by [MM]RoXoR[FS] - 02.08.2012, 04:58
Re: /skin command - by [KHK]Khalid - 02.08.2012, 05:02
Re: /skin command - by Arthur_K - 02.08.2012, 05:02
Respuesta: Re: /skin command - by HarlemSAMP - 02.08.2012, 05:03
Re: /skin command - by Arthur_K - 02.08.2012, 05:04
Re: /skin command - by [MM]RoXoR[FS] - 02.08.2012, 05:13

Forum Jump:


Users browsing this thread: 5 Guest(s)