17.01.2010, 02:48
How to make the such:
When I enter a command
/skin1
varies skin on ID skin 105
When I enter a command
/skin1
varies skin on ID skin 105
public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[128], string[128], cmd[128], idx, skinid;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/changeskin", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR, "Usage: /changeskin [skinid]");
skinid = strval(tmp);
if(IsValidSkin(skinid) == 0) return SendClientMessage(playerid, COLOR, "Error: invalid skin ID!");
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, COLOR, string);
return 1;
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/changeskin", true, 11) == 0)
{
new string[128], skinid;
if(!cmdtext[11]) return SendClientMessage(playerid, COLOR, "Usage: /changeskin [skinid]");
skinid = strval(cmdtext[12]);
switch(skinid)
{
case 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289: { return SendClientMessage(playerid, COLOR, "Error: invalid skin ID!"); }
default:
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, COLOR, string);
}
}
return 1;
}
return 0;
}
if(strcmp(cmd, "/myskin", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, red, "Usage: /myskin [skinid]");
return 1;
}
new skin;
skin = strval(tmp);
format(string, sizeof(string), "You change your skin to this skin ID: %d", skin);
SendClientMessage(playerid, COLOR_GREEN, string);
SetPlayerSkin(playerid, skin);
return 1;
}
CMD:setskin(playerid, params[])
{
new level, id;
if(sscanf(params, "dd", id, level)) return SendClientMessage(playerid, WHITE, "{FF0000}USAGE:{FFFFFF} /setskin [playerid] [skin id]");
{
if(level > 299 || level < 1) return SendClientMessage(playerid, GREY, "Invalid skin ID!");
SetPlayerSkin(id, level);
}
return 1;
}
CMD:setskin(playerid, params[])
{
new id, ammount, name[MAX_PLAYER_NAME], string[128];
if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SendClientMessage(playerid, COLOR_GREY,"You are not authorized to use this command");
else if(sscanf(params,"ui", id, ammount)) return SendClientMessage(playerid, COLOR_GREY,"[True:RP]: /setskin [playerid/partofname] [skinmodel]");
else if(ammount > 299 || ammount < 1) return SendClientMessage(playerid, COLOR_GREY,"Wrong Skin ID! Available ID's: 1-299");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREY,"Invalid player id");
else
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"Your skin have been set to %i by admin %s", ammount, name);
SendClientMessage(id, COLOR_GREEN, string);
PlayerInfo[id][pSkin] = ammount;
SetPlayerSkin(id, PlayerInfo[id][pSkin]);
}
return 1;
}