02.07.2016, 20:21
Hello. Who uses the sampgdk library, tell me. How to work with commands and arguments? For example, /giveadmin [playerid] [levev]. How to lay cmdtext arguments? Or maybe someone has a mini (
) command processor?
I use this:
But it is a bad option. Because if there is too long a command or something, the server crashed.
) command processor?I use this:
Код:
char idx[16] = " ";
char newcmdtext[32];
strcpy(newcmdtext, cmdtext);
char *cmd = strtok(newcmdtext, idx);
if (strcmp(cmd, "/giveadmin") == 0) {
// if(PlayerInfo[playerid].State < LOGGED_PLAYER || AdminInfo[playerid].AdminLevel < ADMIN_LEVEL_MAX) return 0;
int id, level;
if(sscanf(cmdtext, "%s%d%d", cmd, &id, &level) != 3) return PlayerInfo[playerid].SendMessage(0xFFFFFFAA, "ERROR!");
PlayerInfo[playerid].SendMessage(0xFFFFFFAA, string_format("ID: %d LEVEL: %d", id, level).c_str());
return true;
}


