new cmd[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/aadmin", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; new giveplayerid; if (IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /makeadmin [playerid] [level]"); SendClientMessage(playerid, ORANGE, "FUNCTION: Player will be an admin."); return 1; } giveplayerid = ReturnUser(tmp); tmp = strtok(cmdtext, idx); new level = strval(tmp); if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, player, sizeof(player)); PlayerInfo[giveplayerid][AdminLevel] = level; printf("Admin %s made %s a level %d admin.", player, giveplayer, level); format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player); SendClientMessage(giveplayerid, 0x00C2ECFF, string); format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]); SendClientMessage(playerid, 0x00C2ECFF, string); } else if(giveplayerid == INVALID_PLAYER_ID) { format(string, sizeof(string), "%i is not an active player.", giveplayerid); SendClientMessage(playerid, 0xE60000FF, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!"); } return 1; }
OnPlayerConnect(playerid) { PlayerInfo[playerid][AdminLevel] = 0; return 1; }
Originally Posted by Cueball2
Lmao Ali, maybe this can help: https://sampwiki.blast.hk/wiki/zcmd
|
if(strcmp("/gfh", cmdtext, true, 5) == 0) //normal command - unfortunately, the cellmax is needed { new tmp[128]; //create a tmp, just like strtok tmp = zcmd(1, cmdtext); //the "1" is the position of the var - see next example if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "You did not add an ID"); //check string length, just like strtok Kick(strval(tmp)); //kick the value of the tmp string return 1; }
Originally Posted by [SFSF
Ali ]
pawn Code:
|