06.02.2013, 20:40
Guys can u make Kick and Ban commands in dialog for me pls?
My Code:
Example:
My Code:
Код:
if(strcmp(cmd, "/ban", true) == 0) // Bans a player from the server { new reason[128]; if (AccountInfo[playerid][AdminLevel] >= 2 || IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "Use: /ban [Name/ID] [Reason]"); return true; } new giveplayerid = ReturnUser(tmp); new giveplayername[MAX_PLAYER_NAME]; new playername[MAX_PLAYER_NAME]; if (AccountInfo[giveplayerid][AdminLevel] > AccountInfo[playerid][AdminLevel]) { format(string2, sizeof(string2), "INFO: [%i]%s has tried to ban you.",playerid,playername); SendClientMessage(giveplayerid, ABLAU,string,string2); SendClientMessage(playerid, ABLAU, "ADMIN: Error: You aren't authorized to ban an admin with a higher level than yours!"); } else if (giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername)); GetPlayerName(playerid, playername, sizeof(playername)); reason = bigstrtok(cmdtext, idx); if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /ban [name/id] [reason]"); new ip[20]; format(string2, sizeof(string2), "ADMIN: Admin %s has banned %s. [reason: %s ]", playername, giveplayername, reason); SendClientMessageToAll(ABLAU, string,string2); format(string,sizeof(string), "5ADMIN: Admin %s has banned %s. [reason: %s ]", playername, giveplayername, reason); GetPlayerIp(giveplayerid, ip, sizeof(ip)); format(string, sizeof(string), "Gebannnte IP: %s", ip); format(string2, sizeof(string2), "Banned IP: %s", ip); SendClientMessageToAdmins(ABLAU, string,string2, 1); AccountInfo[giveplayerid][AdminLevel] = 0; // Resets the banned player's admin level for security reasons format(reason, sizeof reason, "[%s]%s", playername, reason); BanEx(giveplayerid, reason); } else if(giveplayerid == INVALID_PLAYER_ID) { format(string2, sizeof(string2), "Error: %i isn't an active player.", giveplayerid); SendClientMessage(playerid, ROT, string,string2); } } else SendClientMessage(playerid, ROT, "Error: You aren't authorized to use this command!"); return true; } if(strcmp(cmd, "/kick", true) == 0) // Kicks the player from the server { new reason[128]; if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /kick [name/id] [reason]"); return true; } new giveplayername[MAX_PLAYER_NAME]; new playername[MAX_PLAYER_NAME]; new giveplayerid = ReturnUser(tmp); if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername)); GetPlayerName(playerid, playername, sizeof(playername)); reason = bigstrtok(cmdtext, idx); if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /kick [name/id] [reason]"); format(string2, sizeof(string2), "ADMIN: Admin %s has kicked %s. [Grund: %s ]", playername, giveplayername, reason); SendClientMessageToAll(ABLAU, string,string2); format(string,sizeof(string), "5ADMIN: Admin %s has kicked %s. [Reason: %s ]", playername, giveplayername, reason); Kick(giveplayerid); KickLog(string); } else if(giveplayerid == INVALID_PLAYER_ID) { format(string2, sizeof(string2), "Error: %i isn't an active player.", giveplayerid); SendClientMessage(playerid, ROT, string,string2); } } else SendClientMessage(playerid, ROT, "Error: You aren't authorized to use this command!"); return true; }
