09.01.2014, 15:31
There are problems again.
- As newbie scripter said, only players who are NOT RCON admins can use the command.
- You don't check if the skin is negative or 74 (invalid).
- You send the message to the player who typed the command instead of the player whose skin is set.
- You don't need 128 as size for the string, the message is shorter.
- In case the parameters are wrong, the usage will be displayed. If so, why to declare the name and get the name of the player (who typed the command) when it will be never used?
It can be improved:
No, sID is integer not a string to get its lenght.
- As newbie scripter said, only players who are NOT RCON admins can use the command.
- You don't check if the skin is negative or 74 (invalid).
- You send the message to the player who typed the command instead of the player whose skin is set.
- You don't need 128 as size for the string, the message is shorter.
- In case the parameters are wrong, the usage will be displayed. If so, why to declare the name and get the name of the player (who typed the command) when it will be never used?
It can be improved:
pawn Код:
CMD:setskin(playerid, params[])
{
if (!IsPlayerAdmin(playerid)) return 0;
new
pID,
sID;
if (sscanf(params, "ri", pID, sID)) return SendClientMessage(playerid, COLOR_RED, "INFO: /setskin [PlayerID/Name] [SkinID]");
if (pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player not found.");
if (!(0 <= sID <= 299) || sID == 74) return SendClientMessage(playerid, COLOR_RED, "Skin not found.");
SetPlayerSkin(pID, sID);
new
name[MAX_PLAYER_NAME],
str[57];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof (str), "Admin %s has set your skin to %i.", name, sID);
SendClientMessage(pID, COLOR_RED, str);
return 1;
}