Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>
- #include <i-zcmd>
- #include <a_mysql>
- enum pData // We are creating a enum.
- {
- ID,
- PTag// We declare a Tag Enum I like enum it easy to use :). So, I do that in enum but u can also do that new Tag[MAX_PLAYERS];
- };
- new PlayerInfo[MAX_PLAYERS][pData];// I don't think I have to explain that.
- new database;// this is our database variable
- #define COLOR_ORANGE 0xFF9900AA
- #define red 0xFF0000FF
- #define yellow 0xFFFF00AA
- #define C_LIME 0x99FF00FF
- #define cwhite "{FFFFFF}"
- #define mysql_host "" // You have to add ur server host or whatever u using to connect
- #define mysql_user ""
- #define mysql_database ""
- #define mysql_password ""
- public OnFilterScriptInit()
- {
- mysql_log(LOG_ERROR | LOG_WARNING); // MySQL Log to show us error if it got.
- database = mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
- // Well I am a lazy man. So, I like to create tables from my script.
- mysql_function_query(database,"CREATE TABLE IF NOT EXISTS OfficialTag(ID int(10) auto_increment PRIMARY KEY, PLAYERNAME varchar(30), 1stTagDate varchar(30) , 1stRevokalDate varchar(30), TagLog varchar(256) , Allowed int(10))", false, "", "");
- // So we succesfully create the table
- if(mysql_errno(database) != 0) // This is checking that our database then it will print in our server.exe file that it connect if didn't connect then it will say that it didn't connect.
- {
- printf("[MySQL] The connection has been failed to connect.");
- }
- else
- {
- printf("[MySQL] The connection was been successed to connect.");
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- mysql_close(database); // closing the database.
- return 1;
- }
- // Let's start the main function of our clan tag checker
- public OnPlayerConnect(playerid)
- {
- if(strfind(GetName(playerid), "[UR SERVER OFFICIAL TAG NAME]") != -1) // checking the server tag then it will check to database if it not found then it will kick if it found then he will allow you to join.
- {
- new query[256]; // New query var for query
- mysql_format(database, query, sizeof(query), "SELECT * FROM OfficialTag WHERE PLAYERNAME = '%e'", GetName(playerid));// This is getting table is that playername have permission to have official tag
- mysql_tquery(database,query,"OnOfficialTagDataLoad","i",playerid);// Excuting the query.
- }
- return 1;
- }
- GetName(playerid) // This is our simple function to GetName.
- {
- new pnameid[24];
- GetPlayerName(playerid,pnameid,24);
- return pnameid;
- }
- forward public OnOfficialTagDataLoad(playerid); //This is the query which we set on OnPlayerConnect
- public OnOfficialTagDataLoad(playerid)
- {
- new rows,fields; // creating that var to check rows and fields
- cache_get_data(rows,fields,database); // chaching the data on database.
- if(rows)// That checking if that row exist then allowed the person if not then kick him or whatever the way u want to punish but if I were your side then I will kick.
- {
- PlayerInfo[playerid][PTag] = cache_get_field_content_int(0,"Allowed");// Allowing the person to join
- // PlayerInfo[playerid][PTag] = 1;
- }
- else
- {
- SendClientMessage(playerid, red, "You are not an allowed to have an official [Your OFFICIAL SERVER TAG] Tag Holder, you cannot login with the [Your OFFICIAL SERVER TAG] Tag");
- SendClientMessage(playerid, red, "Please logout and join again with a different name that does not consist our [Your OFFICIAL SERVER TAG] Tag");
- SetTimerEx("KickPublic", 200, false, "i", playerid); // We are setting the timer that player able to get that message otherwise it didn't send message to player.
- }
- return 1;
- }
- forward public KickPublic(playerid);
- public KickPublic(playerid)// Timer that we call on OnOfficialTagDataLoad
- {
- Kick(playerid); // Kicking the player.
- return 1;
- }
- // Now is the time to move on our most important part to set the player official tag
- CMD:setofficialtag(playerid, params[])
- {
- if(IsPlayerAdmin(playerid)) // Allowing that rcon admin can use that cmd.
- {
- new player1;// var that we gonna use on that cmd.
- if(sscanf(params, "u", player1)) return SendClientMessage(playerid, red, "USAGE: /setofficialtag [playerid]"); //sscanf better then strtok. Fast.
- if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, COLOR_ORANGE, "Target player is not online.");// Checking is that player online or not
- if(PlayerInfo[player1][PTag] != 1) // Checking if that player already got that permission or not.
- {
- new query[256], year,month,day,string[256];// creating query var and other to use in that cmd.
- getdate(year, month, day); //Getting data to save so we can know when we allow that player to use our official tag.
- PlayerInfo[player1][PTag] = 1; // Setting
- format(string, sizeof(string), "%d/%d/%d", day, month, year); // formating that in string.
- mysql_format(database, query, sizeof(query), "INSERT INTO OfficialTag (PLAYERNAME, 1stTagDate, Allowed) VALUES ('%s', '%s', 1)", GetName(player1), string); //inserting on our precious database.
- mysql_tquery(database, query, "OnTagDataCreate", "i", playerid); // creating the database
- format(string, sizeof(string), "Administrator %s has set you an official member of [Your Official SERVER TAG NAME] Community", GetName(playerid));
- SendClientMessage(player1, yellow, string);
- SendClientMessage(player1, yellow, "You can now wear the Official [Your Official SERVER TAG NAME] Tag in your name, ask any person to change ur nick");//Well we can set his name by using SetPlayerName but I don't like that way.
- format(string, sizeof(string), "Administrator %s has set %s as an official member of [Your Official SERVER TAG NAME] Community.", GetName(playerid), GetName(player1));
- mysql_format(database, query, sizeof(query), "UPDATE OfficialTag SET TagLog = '%s' WHERE PLAYERNAME = '%e'", string, GetName(playerid)); // Updating the taglog.
- mysql_tquery(database,query,"","");//query excuted
- SendClientMessage(playerid, C_LIME, "Tag Permission allowed");
- } else return SendClientMessage(playerid, red, "[ERROR] "cwhite"Player already has the permission to wear the tag.");
- } else return SendClientMessage(playerid, red, "[ERROR] "cwhite"This command is just for rcon admins");
- return 1;
- }
- forward public OnTagDataCreate(playerid);// That query we use to create on our cmd. to insert data
- public OnTagDataCreate(playerid)
- {
- PlayerInfo[playerid][ID] = cache_insert_id();// inserting the id
- return 1;
- }
- CMD:unsetofficialtag(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- new player1, string[256];
- if(sscanf(params, "u", player1)) return SendClientMessage(playerid, red, "USAGE: /unsetofficialtag [playerid]");
- if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, COLOR_ORANGE, "Target is not online.");
- if(PlayerInfo[player1][PTag] != 0)
- {
- new query[256], year,month,day;
- getdate(year, month, day);
- PlayerInfo[player1][PTag] = 0;
- format(string, sizeof(string), "%d/%d/%d", day, month, year);
- mysql_format(database, query, sizeof(query), "UPDATE OfficialTag SET 1stRevokalDate = '%s' AND Allowed = '0' WHERE Nick = '%e'", string, GetName(playerid));// Updating the query
- mysql_tquery(database,query,"","");// query excuted
- format(string, sizeof(string), "Administrator %s has revoked your permission to wear the official community tag of AwC Gaming Community", GetName(playerid));
- SendClientMessage(player1, C_LIME, string);
- format(string, sizeof(string), "Administrator %s has unsetofficialtag %s as an official member of AWC Gaming Community.", GetName(playerid), GetName(player1));
- mysql_format(database, query, sizeof(query), "UPDATE OfficialTag SET TagLog = '%s' WHERE PLAYERNAME = '%e'", string, GetName(playerid)); // Updating the query
- mysql_tquery(database,query,"","");// query excuted
- SendClientMessage(playerid, C_LIME, "Tag permission taken.");
- } else return SendClientMessage(playerid, red, "[ERROR] "cwhite"Player already doesn't have permission to wear the server official tag.");
- } else return SendClientMessage(playerid, red, "[ERROR] "cwhite"This command is just for rcon admins");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement