09.12.2011, 18:17
it only gives errors...
Can someone create me a simple /setskin command? it doesn't matter who's able to use it.
Can someone create me a simple /setskin command? it doesn't matter who's able to use it.
COMMAND:myskin(playerid,params[])
{
if ( sscanf( params, "d", params[ 0 ] ) ) return SendClientMessage( playerid, -1, ""COL_LIGHTBLUE"Usage:{FFFFFF} /myskin <skin>");
if ( !IsValidSkin( params[ 0 ] ) ) return SendClientMessage( playerid, -1, ""COL_RED"ERROR:{FFFFFF} Invalid skin ID.");
SetPlayerSkin(playerid, params[ 0 ]);
Account[playerid][Skin] = params [ 0 ];
new String[180];
format( String, sizeof String, "{FFFFFF}You set your Skin to "COL_LIGHTBLUE"%d{FFFFFF} and it has been saved into your account succesfully!", params[ 0 ] );
SendClientMessage( playerid, -1, String );
return 1;
}
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/setskin", true) == 0) {
if(IsPlayerConnected(playerid)) {
// Change !IsPlayerAdmin(playerid) --> Rcon Administrator to your Admin Variable.
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You cannot use this command!");
/*
if(Admin_Variable[playerid][Admin_enum] < your_level) return SendClientMessage(playerid, -1, "You cannot use this command!");
*/
new
tmp[256],
tmp2[256],
id = strval(tmp),
skin = strval(tmp2);
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, -1, "Usage: /setskin [ID] [Skin ID]");
return 1;
}
if(!strlen(tmp2)) {
SendClientMessage(playerid, -1, "Usage: /setskin [ID] [Skin ID]");
return 1;
}
SetPlayerSkin(id, skin);
}
return 1;
}
// Rest Of Commands
return 0;
}
// Written by DracoBlue.
stock strtok(const string[], &index,seperator=' ')
{
new length = strlen(string);
new offset = index;
new result[MAX_STRING];
while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1))) {
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (string[index] == seperator)) {
index++;
}
return result;
}
CMD:setskin(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 1) { new targetid, skinid; if (!sscanf(params, "ii", targetid, skinid)) { if (targetid != INVALID_PLAYER_ID) { new message[40]; SetPlayerSkin(targetid, skinid); format(message, sizeof(message), "Your skin ID was set to '%d' by an Admin!", skinid); SendClientMessage(targetid, COLOR_ORANGE, message); } else SendClientMessage(playerid, COLOR_GREY, "That player is not connected!"); } else SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /setskin [playerid]"); } else SendClientMessage(playerid, COLOR_GREY, "You are not a level 1+ Admin!"); return 1; }