Help with enums! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with enums! (
/showthread.php?tid=445906)
Help with enums! -
PaulDinam - 23.06.2013
I made an enum with all admin commands and require level, then I made a stock to send a message of the cmds.
here are the codes:
Enum:
pawn Код:
enum A_COMMANDS
{
aCommand[24],
aLevel
}
new AdminCommands[][A_COMMANDS] = {
{"goto", ADMIN_1},
{"gethere", ADMIN_1},
{"ban", ADMIN_1},
{"kick", ADMIN_1},
{"ajail", ADMIN_1},
{"slap", ADMIN_1},
{"freeze", ADMIN_1},
{"unfreeze", ADMIN_1},
{"mute", ADMIN_1},
{"getcar", ADMIN_1},
{"gotocar", ADMIN_1}
};
Now the stock:
pawn Код:
stock DisplayLevelCommands(playerid, level)
{
new count = 0, cmds[256];
SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
for(new i = 0; i < sizeof(AdminCommands); i++)
{
if(AdminCommands[i][aLevel] == level)
{
format(mstr, sizeof(mstr), " /%s |", AdminCommands[i][aCommand]);
strcat(cmds, mstr);
count++;
if(count == 8)
{
strcat(cmds, "\n");
count = 0;
}
}
}
SCM(playerid, COLOR_WHITE, cmds);
return 1;
}
The problem is that when the count is equal to 8, the \n doesn't works the cmds are at the same line.
Picture:

Re: Help with enums! -
Macluawn - 23.06.2013
\n doesnt work in SendClientMessage
Re: Help with enums! -
NoahF - 23.06.2013
You must separate all the commands into many SCMs.
Re: Help with enums! -
Youarex - 23.06.2013
This is probably not the best approach to write such function, but it should work.
Код:
stock DisplayLevelCommands(playerid, level)
{
new count = 0, cmds[128];
SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
while(count < sizeof(AdminCommands))
{
if(AdminCommands[count][aLevel] == level)
{
format(mstr, sizeof(mstr), " /%s |", AdminCommands[count][aCommand]);
strcat(cmds, mstr);
count++;
if(count % 8 == 0)
{
SCM(playerid, COLOR_WHITE, cmds);
cmds = "";
}
}
}
SCM(playerid, COLOR_WHITE, cmds);
return 1;
}
Re: Help with enums! -
PaulDinam - 23.06.2013
Thanks Youarex, I made this one something more comfortable:
pawn Код:
stock DisplayLevelCommands(playerid, level)
{
new count = 0, cmds[128];
SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
for(new i = 0; i < sizeof(AdminCommands); i++)
{
if(AdminCommands[i][aLevel] == level)
{
if(count != 0)
format(mstr, sizeof(mstr), " /%s ", AdminCommands[i][aCommand]);
else if(count == 0)
format(mstr, sizeof(mstr), "> /%s ", AdminCommands[i][aCommand]);
strcat(cmds, mstr);
count++;
if(count == 10 || count != 10 && i == sizeof(AdminCommands)-1)
{
SCMEx(playerid, -1, "{C3C3C3}%s", cmds);
count = 0;
cmds = "";
}
}
}
return 1;
}