CMD:ban(playerid, params[]) //Ban a Player { new pID, reason[128], string[128], Year, Month, Day; if(pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command."); if(sscanf(params, "us[128]", pID, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban (Username/ID) (Reason)"); if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Wrong ID or that player is not connected."); SetTimerEx("BanTimer", 10, 0, "d", pID); format(string,sizeof(string), "{33CCFF}[BAN] %s {FFFFFF}has been banned from the server by {33CCFF}%s (%s).", pInfo[pID][pName], pInfo[playerid][pName], reason); SendClientMessageToAll(-1, string); getdate(Year, Month, Day); pInfo[pID][pBanned] = 1; strcpy(pInfo[pID][pBanAdmin], pInfo[playerid][pName], MAX_PLAYER_NAME); pInfo[pID][pBanReason] = reason; pInfo[pID][pBanD] = Day; pInfo[pID][pBanM] = Month; pInfo[pID][pBanY] = Year; new query[256]; mysql_format(Database, query, sizeof(query), "INSERT INTO `banned` (`Username`, `Admin`, `Reason`, `Day`, `Month`, `Year`) VALUES ('%s', '%s', '%s', '%d', '%d', '%d')", pInfo[pID][pName], pInfo[pID][pBanAdmin], pInfo[pID][pBanReason], pInfo[pID][pBanD], pInfo[pID][pBanM], pInfo[pID][pBanY]); mysql_query(Database, query); //Textdraws TextDrawShowForPlayer(playerid, BanBox1); TextDrawShowForPlayer(playerid, BanBox2); TextDrawShowForPlayer(playerid, BanOverview); TextDrawShowForPlayer(playerid, BanAppeal); TextDrawShowForPlayer(playerid, BanBox3); PlayerTextDrawShow(playerid, PlayerName[playerid]); PlayerTextDrawShow(playerid, AdminName[playerid]); PlayerTextDrawShow(playerid, BanReason[playerid]); PlayerTextDrawShow(playerid, BanDate[playerid]); new PlayerNameTextdraw[256], AdminNameTextdraw[256], BanReasonTextdraw[256], BanDateTextdraw[256]; format(PlayerNameTextdraw, sizeof(PlayerNameTextdraw), "Player Name: %s", pInfo[pID][pName]); format(AdminNameTextdraw, sizeof(AdminNameTextdraw), "Admin Name: %s", pInfo[playerid][pName]); format(BanReasonTextdraw, sizeof(BanReasonTextdraw), "Reason: %s", reason); format(BanDateTextdraw, sizeof(BanDateTextdraw), "Date: %d/%d/%d", pInfo[pID][pBanD], pInfo[pID][pBanM], pInfo[pID][pBanY]); PlayerTextDrawSetString(pID, PlayerName[playerid], PlayerNameTextdraw); PlayerTextDrawSetString(pID, AdminName[playerid], AdminNameTextdraw); PlayerTextDrawSetString(pID, BanReason[playerid], BanReasonTextdraw); PlayerTextDrawSetString(pID, BanDate[playerid], BanDateTextdraw); TogglePlayerControllable(playerid, 0); return 1; } |
forward BanTimer(pID); public BanTimer(pID) { Kick(pID); } |
TextDrawShowForPlayer(playerid, BanBox1);
TextDrawShowForPlayer(playerid, BanBox2);
TextDrawShowForPlayer(playerid, BanOverview);
TextDrawShowForPlayer(playerid, BanAppeal);
TextDrawShowForPlayer(playerid, BanBox3);
PlayerTextDrawShow(playerid, PlayerName[playerid]);
PlayerTextDrawShow(playerid, AdminName[playerid]);
PlayerTextDrawShow(playerid, BanReason[playerid]);
PlayerTextDrawShow(playerid, BanDate[playerid]);
#define scm SendClientMessage
#define func%0(%1) forward%0(%1); public%0(%1)
enum PlayerEnum{
pSid,
pAdmin,
pName[24],
bool:pLogged
};
CMD:ban(pid, p[]){ //Ban a Player
new id,s[300];
if(pInfo[pid][pAdmin] < 1)return scm(pid,-1,"ERROR: You are not authorized to use this command.");
if(sscanf(p,"us[120]",id,p))return scm(pid,-1,"USAGE: /ban (Username/ID) (Reason)");
if(!IsPlayerConnected(id) || !pInfo[pid][pLogged])return scm(pid,-1,"ERROR: Wrong ID or that player is not connected.");
//just simple mysql request, you don't need to change enum info because he will be kicked anyway...
mysql_format(Database,s,sizeof(s),"UPDATE players SET banned='1',banstart=UNIX_TIMESTAMP(),bannersid='%d',banreason='%e' where sqlid='%d'",
pInfo[pid][pSid],p,pInfo[id][pSid]);
//mysql_query(Database, query); is used for threaded inline querys
mysql_tquery(Database,s);
format(s,sizeof(s),"{33CCFF}[BAN] %s {FFFFFF}has been banned from the server by {33CCFF}%s (%s).", pInfo[id][pName],pInfo[pid][pName],p);
SendClientMessageToAll(-1,s);
//first you set the value
//i think player knows his name
//format(s, sizeof(s), "Player Name: %s", pInfo[pID][pName]);
//PlayerTextDrawSetString(id, PlayerName[id], s);
format(s, sizeof(s), "Admin Name: %s", pInfo[pid][pName]);
PlayerTextDrawSetString(id, AdminName[id], s);
format(s, sizeof(s), "Reason: %s", p);
PlayerTextDrawSetString(id, BanReason[id], s);
//no point for that when he knows todays date waste of information
//format(s, sizeof(s), "Date: %d/%d/%d", pInfo[pID][pBanD], pInfo[pID][pBanM], pInfo[pID][pBanY]);
//PlayerTextDrawSetString(id, BanDate[id], s);
//then you show textdraw
TextDrawShowForPlayer(id, BanBox1);
TextDrawShowForPlayer(id, BanBox2);
TextDrawShowForPlayer(id, BanOverview);
TextDrawShowForPlayer(id, BanAppeal);
TextDrawShowForPlayer(id, BanBox3);
//PlayerTextDrawShow(id, PlayerName[id]);
PlayerTextDrawShow(id, AdminName[id]);
PlayerTextDrawShow(id, BanReason[id]);
//PlayerTextDrawShow(id, BanDate[id]);
//then you freeze
TogglePlayerControllable(id, 0);
//kick
//little delay must be there, because information can then reace to player
SetTimerEx("KickPlayer",250,false,"d",id);
return 1;
}
func KickPlayer(pid)return Kick(pid);
Is there even point for wasting so many textdraw slots for simple ban message, because with those slots you can build some good interface systems like cool inventory system, stats etc.
|