Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*____________________________________________________________________________________________________________________
- ======================================================================================================================
- L-Infraction System by Lordz™.
- Copyright(c)2012, L-Infractions.
- ======================================================================================================================
- _____________________________________________________________________________________________________________________
- Credits goes to:
- Y_Less for sscanf2 and y_ini.
- ZeeX for zcmd.
- Lordz™ for the script.
- */
- //==============================================================================
- // Includes
- //==============================================================================
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <sscanf2>
- //==============================================================================
- // Color Defines
- //==============================================================================
- #define red 0xFF0000FF
- #define green 0xFF0000
- #define yellow 0xFFFF00C8
- #define orange 0xFF9900AA
- //==============================================================================
- // Dialogs
- //==============================================================================
- #define DPERMIT 5000
- #define RECIEVE 5001
- #define RPERMIT 5003
- #define banned 5004
- //==============================================================================
- // Configurations.
- //==============================================================================
- #define UserPath "L-Infractions/L-Users/%s.ini"
- #define LogPath "L-Infractions/Inf_log.txt"
- #define Permittedusers "L-Infractions/Permitted_Users.txt"
- #define INF_BAN_PATH "L-Infractions/Ban_log.txt"
- #define MAX_INFRACTIONS 10 //MAX infraction level, 10 is the default. You can change it.
- #define INF_DCHAT 9 //Infraction level, which will disable player's chatting ability. This must not be greater than MAX_INFRACTIONS.
- #if INF_DCHAT > MAX_INFRACTIONS
- #error "INF_DCHAT must be defined lower than MAX_INFRACTIONS."
- #endif
- #define INF_FREEZE 8 //Infraction level at which player will be frozen.
- #define FREEZE_TIME 1 //Minutes, a player will be frozen.
- #define Servername "SERVER" //Change the "SERVER" to your server name. NOTE: Your server name must be inside the quotes.
- #define website "www.google.com" //Change this to your website.
- //==============================================================================
- new File:Infban;
- new File:Inflog;
- new File:Permulog;
- public OnFilterScriptInit()
- {
- printf("---------------------------------------------");
- printf("\nL-Infraction system by Lordz™ Loaded!");
- for(new i; i< MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- INI_ParseFile(LPath(i),"loadinfractions", .bExtra = true, .extra = i);
- print("Parsing Infractions");
- }
- }
- print("Parsed Successfully!");
- print("-----------------------------------------");
- return 1;
- }
- public OnFilterScriptExit()
- {
- printf("---------------------------------------------");
- printf("\nL-Infraction system by Lordz™ Unloaded");
- for(new i; i< MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- SaveInfractions(i);
- print("Saving Infractions");
- }
- }
- print("Saved Infractions successfully");
- printf("-------------------------------------------\n");
- return 1;
- }
- //==============================================================================
- // L-Functions
- //==============================================================================
- //Warning:Do not edit, if you're a newbie/don't know.
- new FString[1000];
- #define LFormat(%0) (format(FString, 1000, %0), FString)
- #define LMessage(%0,%1,%2) SendClientMessage(%0, %1, LFormat(%2))
- #define LTime(%0,%1,%2) (((%0)*3600+(%1)*60+(%2))*1000)
- //==============================================================================
- // Infractions Info
- //==============================================================================
- enum LInfo
- {
- InfPermit,
- Infraction
- }
- new LUserInfo[MAX_PLAYERS][LInfo];
- new Timer[MAX_PLAYERS];
- new FREEZE[MAX_PLAYERS];
- stock LPath(playerid)
- {
- new string[128], Lname[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Lname,sizeof(Lname));
- format(string,sizeof(string),UserPath,Lname);
- return string;
- }
- stock SaveInfractions(playerid)
- {
- new Linfname[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Linfname,sizeof(Linfname));
- new INI:Lfile = INI_Open(LPath(playerid));
- new tagstr[30];
- format(tagstr,sizeof(tagstr),"%s's Info", Linfname);
- INI_SetTag(Lfile, tagstr);
- INI_WriteInt(Lfile, "Infractions", LUserInfo[playerid][Infraction]);
- INI_WriteInt(Lfile, "Permitted", LUserInfo[playerid][InfPermit]);
- INI_Close(Lfile);
- return 1;
- }
- stock LBan(playerid)
- {
- new str[128];
- new lstr[128];
- new LYear,LMonth,LDay;
- new Lhour, LMin, LSec;
- new LBname[MAX_PLAYER_NAME];
- getdate(LYear,LMonth,LDay);
- gettime(Lhour,LMin,LSec);
- GetPlayerName(playerid,LBname,sizeof(LBname));
- format(lstr,sizeof(lstr),"%s(ID:%d) has been automatically banned. (Reason:Reached MAXIMUM Infraction Level.)", LBname, playerid);
- SendClientMessageToAll(red, lstr);
- format(str,sizeof(str),"%s has been banned for reaching MAXIMUM Infraction Level. [DATE:%02d/%02d/%d] [TIME:%02d-%02d-%02d]\r\n", LBname, LDay, LMonth, LYear, Lhour, LMin, LSec);
- Infban = fopen(INF_BAN_PATH, io_append);
- fwrite(Infban,str);
- fclose(Infban);
- new ip[16];
- GetPlayerIp(playerid, ip, sizeof(ip));
- new bstr[400];
- format(bstr,sizeof(bstr),"{FF0000}You have been banned from %s\nReason:Reached MAXIMUM Infraction Level.\nPlayerName:%s\nID:%d\nIP:%i\nDATE:%02d/%02d/%02d\nTIME:%02d-%02d-%02d\n{FFFFFF}If you feel that you're innocent, please press {FF0000}F8{FFFFFF}(to take snapshot)\n and post this on {FF0000}forums.\nLink:%s", Servername, LBname, playerid, ip, LDay, LMonth, LYear, Lhour, LMin, LSec, website);
- ShowPlayerDialog(playerid, banned, DIALOG_STYLE_MSGBOX,"{FF0000}L-Infractions > BAN INFO", bstr, "Close", "");
- TogglePlayerControllable(playerid,false);
- return Ban(playerid);
- }
- forward loadinfractions(playerid, name[], value[]);
- public loadinfractions(playerid, name[], value[])
- {
- INI_Int("Infractions", LUserInfo[playerid][Infraction]);
- INI_Int("Permitted", LUserInfo[playerid][InfPermit]);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- INI_ParseFile(LPath(playerid),"loadinfractions", .bExtra = true, .extra = playerid);
- if(LUserInfo[playerid][Infraction] == MAX_INFRACTIONS-1) return LMessage(playerid, red, "WARNING:You are currently having %d Infractions. If you gain one more, you'll be Banned!", MAX_INFRACTIONS-1);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SaveInfractions(playerid);
- return 1;
- }
- CMD:permit(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return LMessage(playerid, red, "You must be logged in as RCON to use this command.");
- new p2;
- new lName[MAX_PLAYER_NAME];
- new pName[MAX_PLAYER_NAME];
- if(sscanf(params,"u",p2))
- {
- LMessage(playerid, red, "Usage: /permit [playerid]");
- return LMessage(playerid, orange, "Function:Will allow the specified player to infract rule breakers.");
- }
- if(p2 == INVALID_PLAYER_ID) return LMessage(playerid, red, "This player ID is invalid.");
- if(LUserInfo[p2][InfPermit] == 1) return LMessage(playerid, red, "Player is already Permitted.");
- if(!IsPlayerConnected(p2)) return LMessage(playerid, red, "Player isn't connected");
- else
- {
- GetPlayerName(playerid,lName,sizeof(lName));
- GetPlayerName(p2,pName,sizeof(pName));
- LUserInfo[p2][InfPermit] = 1;
- LMessage(p2, green, "%s (ID:%d) has permitted you to Infract rule breakers.", lName, playerid);
- LMessage(playerid, green, "You have successfully permitted %s (ID:%d) to infract rule breakers.", pName, p2);
- new string[256];
- format(string,sizeof(string),"{FFFFFF}You have been permitted to Infract rule breakers. \n Permitted by:{FF0000}%s", lName);
- ShowPlayerDialog(playerid, DPERMIT, DIALOG_STYLE_MSGBOX, "{FF0000}L-INFRACTIONS!", string, "Okay", "");
- SaveInfractions(playerid);
- SaveInfractions(p2);
- new lstring[34];
- format(lstring,sizeof(lstring), "%s is permitted\r\n", pName);
- Permulog = fopen(Permittedusers, io_append);
- fwrite(Permulog,lstring);
- fclose(Permulog);
- }
- return 1;
- }
- CMD:rpermit(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return LMessage(playerid, red, "You must be logged in as RCON to use this command.");
- new p2;
- new lName[MAX_PLAYER_NAME];
- new pName[MAX_PLAYER_NAME];
- new reason[60];
- if(sscanf(params,"us[60]",p2,reason))
- {
- LMessage(playerid, red, "Usage: /rpermit [playerid] [reason]");
- return LMessage(playerid, orange, "Function:Will remove the infracting permission from specified player.");
- }
- else
- {
- GetPlayerName(playerid,lName,sizeof(lName));
- GetPlayerName(p2,pName,sizeof(pName));
- if(p2 == INVALID_PLAYER_ID) return LMessage(playerid, red, "This player ID is invalid.");
- if(!IsPlayerConnected(p2)) return LMessage(playerid, red, "Player is not connected");
- if(LUserInfo[p2][InfPermit] == 0) return LMessage(playerid, red, "Player %s is not permitted", pName);
- LUserInfo[p2][InfPermit] = 0;
- LMessage(playerid, yellow, "You have successfully removed the Infraction Permit of %s", pName);
- LMessage(p2, red, "Your Infracting Permission has been removed by %s (Reason:%s)", lName, reason);
- new string[128];
- format(string,sizeof(string), "{FFFFFF}Your infracting permission has been removed by {FF0000}%s\n Reason:%s", lName, reason);
- ShowPlayerDialog(p2,RPERMIT,DIALOG_STYLE_MSGBOX, "{FF0000}L-Infractions", string, "Okay", "");
- SaveInfractions(playerid);
- SaveInfractions(p2);
- }
- return 1;
- }
- CMD:infract(playerid,params[])
- {
- if(LUserInfo[playerid][InfPermit] == 0) return LMessage(playerid, red, "You don't have permission to use this command.");
- new p2;
- new reason[60];
- new string[400];
- new lName[MAX_PLAYER_NAME];
- new pName[MAX_PLAYER_NAME];
- new Lhour,Lmin,Lsec;
- new Year,month,day;
- if(sscanf(params,"us[60]", p2, reason))
- {
- LMessage(playerid, red, "Usage: /infract [playerid] [reason]");
- return LMessage(playerid, orange, "Function:This command will allow to infract a rule breaker.");
- }
- else
- {
- GetPlayerName(playerid,lName,sizeof(lName));
- GetPlayerName(p2,pName,sizeof(pName));
- gettime(Lhour,Lmin,Lsec);
- getdate(Year,month,day);
- if(p2 == INVALID_PLAYER_ID) return LMessage(playerid, red, "This player ID is invalid");
- LUserInfo[p2][Infraction]++;
- new lstr[128];
- format(lstr,sizeof(lstr),"%s(ID:%d) has issued an infraction to %s(ID:%d) (Reason:%s)", lName, playerid, pName, p2, reason);
- SendClientMessageToAll(red, lstr);
- LMessage(p2, yellow, "%s(ID:%d) has given issued you an Infraction. (Reason:%s)", lName, playerid, reason);
- LMessage(playerid, yellow, "You have infracted %s(ID:%d) (Reason:%s)", pName, p2, reason);
- format(string,sizeof(string),"{FFFFFF}You have recieved an infraction at %s\nIssued by:{FF0000}%s\nReason:%s\n{FFFFFF}Date:%02d/%02d/%d\nTime:\nHour:%02d\nMinute:%02d\nSecond:%02d\nCurrent Infractions:{FF0000}%d/%d\n{FF0000}If you feel that you're innocent, please press F8(to take snapshot)\n and post this on forums.\nLink:%s", Servername, lName, reason, day, month, Year, Lhour, Lmin, Lsec, LUserInfo[p2][Infraction], MAX_INFRACTIONS, website);
- ShowPlayerDialog(p2, RECIEVE, DIALOG_STYLE_MSGBOX, "{FF0000}L-Infractions > You have recieved an Infraction", string, "Close", "");
- new logstr[128];
- format(logstr,sizeof(logstr),"%s has issued %s an infraction.(Reason:%s) [DATE:%02d/%02d/%d] [Time:%02d-%02d-%02d]\r\n", lName, pName, reason, day, month, Year, Lhour, Lmin, Lsec);
- Inflog = fopen(LogPath, io_append);
- fwrite(Inflog,logstr);
- fclose(Inflog);
- SaveInfractions(playerid);
- SaveInfractions(p2);
- }
- return 1;
- }
- CMD:setinfractions(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return LMessage(playerid, red, "You must be logged in as RCON to use this command.");
- new p2;
- new inf;
- new lName[MAX_PLAYER_NAME];
- new pName[MAX_PLAYER_NAME];
- if(sscanf(params,"ui",p2,inf))
- {
- LMessage(playerid, red, "Usage: /setinfractions [playerid]");
- return LMessage(playerid, orange, "Fucntion:Will set the infraction level of a player.");
- }
- else
- {
- if(!IsPlayerConnected(playerid)) return LMessage(playerid, red, "Player is not connected");
- if(p2 == INVALID_PLAYER_ID) return LMessage(playerid, red, "Ivalid player ID");
- if(inf < 0 || inf >= MAX_INFRACTIONS) return LMessage(playerid, red, "Invalid Infraction level. (Available: 0-%d)", MAX_INFRACTIONS-1);
- GetPlayerName(playerid,lName,sizeof(lName));
- GetPlayerName(p2,pName,sizeof(pName));
- LUserInfo[p2][Infraction] = inf;
- LMessage(playerid, green, "[L-Infractions] You have successfully set %s's(ID:%d) Infraction level to %d", pName, p2, inf);
- LMessage(p2, yellow, "[L-Infractions] Your infraction level has been set to %d by %s(ID:%d)", inf, lName, playerid);
- SaveInfractions(playerid);
- SaveInfractions(p2);
- }
- return 1;
- }
- CMD:rinfraction(playerid,params[])
- {
- if(LUserInfo[playerid][InfPermit] == 0) return LMessage(playerid, red, "You are not having permission to use this command.");
- if(Timer[playerid] == 1) return LMessage(playerid, red, "You must wait atleast 5 minutes to use this command");
- new p2;
- new lName[MAX_PLAYER_NAME];
- new pName[MAX_PLAYER_NAME];
- if(sscanf(params,"u",p2))
- {
- LMessage(playerid, red, "Usage: /rinfraction [playerid]");
- return LMessage(playerid, orange, "Function:Will reduce the infraction of a player -1.");
- }
- else
- {
- GetPlayerName(playerid,lName,sizeof(lName));
- GetPlayerName(p2, pName, sizeof(pName));
- if(LUserInfo[p2][Infraction] == 0) return LMessage(playerid, red, "Player's Infraction level is 0 and can't be reduced anymore.");
- LUserInfo[p2][Infraction]--;
- LMessage(playerid, green, "You have successfully reduced %s's(ID:%d) Infraction level {FF0000}(-1)", pName, p2);
- LMessage(p2, yellow, "Your Infraction level has been reuced by %s(ID:%d) {FF0000} (-1)", lName, playerid);
- SaveInfractions(playerid);
- SaveInfractions(p2);
- SetTimerEx("InfTimer",LTime(0,5,0),false,"d",playerid);
- Timer[playerid] = 1;
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(LUserInfo[playerid][Infraction] == MAX_INFRACTIONS) return LBan(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(LUserInfo[playerid][Infraction] == INF_FREEZE)
- {
- FREEZE[playerid] = 1;
- if(FREEZE[playerid] == 1)
- {
- TogglePlayerControllable(playerid,false);
- SetTimerEx("FRZ_TIMER",LTime(0,FREEZE_TIME,0),false,"d",playerid);
- LMessage(playerid, red, "You have been automatically frozen for %d minutes. (Reason:Recieved %d Infractions.)", FREEZE_TIME, INF_FREEZE);
- }
- }
- return 1;
- }
- forward InfTimer(playerid);
- forward FRZ_TIMER(playerid);
- public InfTimer(playerid)
- {
- if(Timer[playerid] == 1) return Timer[playerid] = 0;
- return 1;
- }
- public FRZ_TIMER(playerid)
- {
- if(FREEZE[playerid] == 1)
- {
- FREEZE[playerid] = 0;
- TogglePlayerControllable(playerid,true);
- LMessage(playerid, green, "You are now unfrozen.");
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(LUserInfo[playerid][Infraction] == INF_DCHAT)
- {
- LMessage(playerid, red, "[L-Infraction]You are not allowed to chat since you have got %d INFRACTIONS.", INF_DCHAT);
- }
- return 0;
- }
- CMD:myinfractions(playerid,params[])
- {
- LMessage(playerid, yellow, "You currently have {FF0000}%d Infractions.", LUserInfo[playerid][Infraction]);
- return 1;
- }
- CMD:infractions(playerid,params[])
- {
- if(LUserInfo[playerid][InfPermit] == 0) return LMessage(playerid, red, "You do not have permission to use this command.");
- new p2;
- if(sscanf(params,"u",p2))
- {
- LMessage(playerid, red, "Usage: /infractions [playerid]");
- return LMessage(playerid, orange, "Function:Will show how many infractions does a player have.");
- }
- else
- {
- if(p2 == INVALID_PLAYER_ID) return LMessage(playerid, red, "This player ID is not valid.");
- if(!IsPlayerConnected(p2)) return LMessage(playerid, red, "Player is not connected.");
- new lName[MAX_PLAYER_NAME];
- GetPlayerName(p2,lName,sizeof(lName));
- LMessage(playerid, orange, "_________________________________________________");
- LMessage(playerid, orange, "");
- LMessage(playerid, green, "L-Infraction System by Lordz™");
- LMessage(playerid, orange, "_________________________________________________");
- LMessage(playerid, yellow, "Player %s(ID:%d) currently has %d Infractions", lName, p2, LUserInfo[p2][Infraction]);
- }
- return 1;
- }
- stock Infract(playerid,reason[])
- {
- new infName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,infName,sizeof(infName));
- LMessage(playerid, red, "[L-Infraction] %s has been Infracted! (Reason:%s)", infName, reason);
- return LUserInfo[playerid][Infraction]++;
- }
- //==============================================================================
- // Copyright (c)L-Infractions 2012
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement