Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_sampdb>
- #include <upa>
- #define FILTERSCRIPT
- #include <zcmd>
- //COLOR
- #define PINK 0xFF22EE00
- new
- DB: dbBans;
- forward tempBanPlayer(playerid, iTime, szBannedBy[], szReason[], szIP[]);
- public OnFilterScriptInit() {
- dbBans = db_open("tempban.db");
- return 1;
- }
- public OnFilterScriptExit() {
- db_close(dbBans);
- return 1;
- }
- public OnPlayerConnect(playerid) {
- new
- szPlayerName[MAX_PLAYER_NAME],
- szQuery[93],
- szIP[19];
- GetPlayerIp(playerid, szIP, sizeof(szIP));
- GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
- format(szQuery, sizeof(szQuery), "SELECT banlength FROM bans WHERE ip = '%s' OR name = '%s'", szIP, DB_Escape(szPlayerName));
- new
- DBResult: qHandle = db_query(dbBans, szQuery);
- if(db_num_rows(qHandle) > 0) {
- new
- szDump[32],
- iDump,
- szMessage[64];
- db_get_field_assoc(qHandle, "banlength", szDump, sizeof(szDump));
- iDump = strval(szDump);
- if(iDump-gettime() < 0) {
- format(szMessage, sizeof(szMessage), "{FF00C3}You ban has expired!!!!!!!!!!!!!!!!!");
- SendClientMessage(playerid, PINK, szMessage);
- format(szQuery, sizeof(szQuery), "DELETE FROM bans WHERE name = '%s'", DB_Escape(szPlayerName));
- db_free_result(db_query(dbBans, szQuery));
- } else {
- format(szMessage, sizeof(szMessage), "{FF00C3}In Order to be unbanned, you must wait %d seconds.", iDump-gettime());
- format(szMessage, sizeof(szMessage), "{FF0000}Days Left:%d", iDump-gettime()); // FUCKED D: - Same func for each.. Ofc it's not going to work
- format(szMessage, sizeof(szMessage), "{FF0000}Weeks Left:%d", iDump-gettime()); // FUCKED D: - i know Was reading aobut somethink like this
- SendClientMessage(playerid, PINK, "{14DBF5}You have been temp banned from Metropolis Roleplay.");
- SendClientMessage(playerid, PINK, szMessage);
- Kick(playerid);
- }
- }
- db_free_result(qHandle);
- return 1;
- }
- public tempBanPlayer(playerid, iTime, szBannedBy[], szReason[], szIP[])
- {
- new
- szPlayerNameBanned[MAX_PLAYER_NAME],
- szQuery[270];
- GetPlayerName(playerid, szPlayerNameBanned, MAX_PLAYER_NAME);
- format(szQuery, sizeof(szQuery), "INSERT INTO bans (name, ip, reason, banlength, bannedby) VALUES('%s', '%s', '%s', %d, '%s')", DB_Escape(szPlayerNameBanned), DB_Escape(szIP), DB_Escape(szReason), iTime, DB_Escape(szBannedBy));
- db_free_result(db_query(dbBans, szQuery));
- Kick(playerid);
- return 1;
- }
- CMD:temp(playerid, params[]) {
- new
- iDays,
- iFinalCalculation,
- iHours,
- iWeeks,
- szReason[32],
- iMinutes,
- szIP[19],
- szPlayerName[MAX_PLAYER_NAME],
- iTarget;
- if(!IsPlayerAdmin(playerid) && GetPVarInt(playerid, "Admin") <= 0)
- return SendClientMessage(playerid, PINK, "ERROR: You must login to provide this command, else there is probberly a bug D:");
- if(sscanf(params, "uddds", iTarget, iWeeks, iDays, iHours, iMinutes, szReason))
- return SendClientMessage(playerid, PINK, "{FF0000}Warning: {FFFFFF}/temp (Playerid) (weeks) (days (min) (REason)");
- iFinalCalculation = gettime() + mktime(iHours, iMinutes, 0, iDays);
- if(gettime() == iFinalCalculation)
- return SendClientMessage(playerid, PINK, "ERROR: YOu have not set an correct unban time");
- GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
- GetPlayerIp(iTarget, szIP, sizeof(szIP));
- tempBanPlayer(iTarget, iFinalCalculation, szPlayerName, szReason, szIP);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment