02.08.2012, 05:02
Sure. Here's a skin command with explainations:
You may like to check this article about using strcmp for creating commands with multiple parameters.
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;
}