20.05.2017, 23:59
Your second sscanf is the issue or well both of them kind of are.
First you are asking to put "params" into "options" and it should basically be a 1 or a 2. Then when it's a 1, you're asking again if params (aka also options) to be placed into chatstyle. Ergo you have the same thing being placed in both "options" and "chatstyle". You could make the code a bit simpler by using it like this for example:
Also indendation lost you somewhere, get the practice to use it correctly please!
My question: Is it possible to make this code shorter somehow? Just asking for convenience sake of course (ZCMD).
First you are asking to put "params" into "options" and it should basically be a 1 or a 2. Then when it's a 1, you're asking again if params (aka also options) to be placed into chatstyle. Ergo you have the same thing being placed in both "options" and "chatstyle". You could make the code a bit simpler by using it like this for example:Code:
CMD:setstyle(playerid, params[])
{
new options, style;
if(sscanf(params, "ii", options, style)) {
SendClientMessage(playerid, ADM, "USAGE:{FFFFFF} /setstyle [Options] [StyleID]");
SendClientMessage(playerid, DARKGREEN, "1. Chat Style|2. Walk Style");
return 1;
}
switch(options)
{
case 1:
{
if(chatstyle < 0 || chatstyle > 7)
return SendClientMessage(playerid, DARKGREEN, "That chatstyle does not exist.");
PlayerData[playerid][ChatStyle] = chatstyle;
SendClientMessage(playerid, YELLOW, "Your chatstyle has been updated. Chat styles are played when you type.");
}
}
return 1;
}
CMD:setstyle(playerid, params[])
{
new options, style;
if(sscanf(params, "iI(-1)", options, style)) {
SendClientMessage(playerid, ADM, "USAGE:{FFFFFF} /setstyle [Options] [StyleID]");
SendClientMessage(playerid, DARKGREEN, "1. Chat Style|2. Walk Style");
return 1;
}
switch(options)
{
case 1:
{
if(style == -1) // this means that the user never placed any style id as parameter
{
SendClientMessage(playerid, DARKGREEN, "USAGE: /setstyle 1 [StyleID 0-7]");
return 1;
}
if(chatstyle < 0 || chatstyle > 7)
return SendClientMessage(playerid, DARKGREEN, "That chatstyle does not exist.");
PlayerData[playerid][ChatStyle] = chatstyle;
SendClientMessage(playerid, YELLOW, "Your chatstyle has been updated. Chat styles are played when you type.");
}
}
return 1;
}
My question: Is it possible to make this code shorter somehow? Just asking for convenience sake of course (ZCMD).
Code:
CMD:wi(playerid, params[]) return cmd_windows(playerid, params);
CMD:win(playerid, params[]) return cmd_windows(playerid, params);
CMD:wind(playerid, params[]) return cmd_windows(playerid, params);
CMD:windo(playerid, params[]) return cmd_windows(playerid, params);
CMD:window(playerid, params[]) return cmd_windows(playerid, params);
CMD:windows(playerid, params[])
{
return 1;
}

