Author Topic: Anti-Advertisement - Protection for commands and chat!  (Read 1047 times)

Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM
Anti-Advertisement - Protection for commands and chat!
« on: February 24, 2013, 10:54:31 am »
Anti - Advertisement

As I've seen many guys advertising in our server, I thought of creating an anti-advertisement script which detects advertisements on both commands and chat. This is just an include, a stock function which returns true if player has advertised or returns false if not. This also finds website advertising whether if there is any URL at the text or not.

Function:
DetectAdv(string[])

Unfortunately, it even detects if our forum is too advertised. It can be fixed if needed by detecting our weburl and ignoring or by creating a command /website. There's also a define which ignores or doesn't ignores website advertising.


Examples

public OnPlayerText(playerid, text[]){ if(DetectAdv(string) //If it's advertised! {  return Kick(playerid), 0; //Adding 0 so as that the text wont be in chat. } else {  //Chat } return 1;}CMD:sendtext(playerid, params[]) //In commanding!{ new p2, msg[128]; if(sscanf(params, "rs[128]", p2, msg)) return SendClientMessage(playerid, -1, "Usage: /sendtext [playerid] [text]"); new Lname[MAX_PLAYER_NAME]; GetPlayerName(playerid, Lname, sizeof(Lname)); if(DetectAdv(msg)) return SendClientMessage(playerid, -1, "You cannot advertise!"); new string[128]; format(string, sizeof(string), "Text from %s: %s", Lname, msg); SendClientMessage(p2, -1, string); return 1;}?>


I hope this can work on every commands by adding it on callback 'OnPlayerCommandPerformed' or 'OnPlayerCommandText'. I haven't tested in that yet, but I'll check it  soon.

Here's a stock function which I've forgot to include in the script. This isn't necessary, but might be useful for saving advertisement logs.

stock Advlog(playerid, adv[]){ new File:ad = fopen("Advertisements.txt", io_append); new Hour, Min, Sec, Day, Mon, Year; gettime(Hour, Min, Sec); getdate(Year, Mon, Day); new string[200]; new Lname[MAX_PLAYER_NAME]; GetPlayerName(playerid, Lname, sizeof(Lname)); new pIP[16]; GetPlayerIp(playerid, pIP, sizeof(pIP)); format(string, sizeof(string), "%s has been found advertising in our server! (IP: %s) (Date: %d/%d/%d) (Time: %d:%d:%d) (Text: %s)\r\n", Lname, pIP, Day, Mon, Year, Hour, Min, Sec, adv); if(ad) {  fwrite(ad, string);  fclose(ad); } return 1;}?>


Use:
public OnPlayerText(playerid, text[]){ if(DetectAdv(text)) {   Advlog(playerid, text);  return  SetTimerEx("KICK", 500, false, "d", playerid), 0; } return 1;}forward KICK(playerid);public KICK(playerid){ Kick(playerid); return 1;}?>



Script sent to server scripter - YoUnG_MoNeY



PS: I've a request to add it soon because anti-advertisements could be better if added before. It might be there in update, but if faster; we could be protected more. :)
« Last Edit: February 24, 2013, 11:02:15 am by Lordz »

Share on Bluesky Share on Facebook


Offline BlackBloods

  • Level 5
  • Sr. Member
  • *
  • Posts: 360
  • YG Graphix Editor
  • Location: Dubai
    • www.yg-gaming.com
  • In-Game: [YG]BlackBloods
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #1 on: February 24, 2013, 11:36:12 am »
nice
but they can adv in pm


Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #2 on: February 24, 2013, 12:02:30 pm »
nice
but they can adv in pm

No, I've tested it. They can't adv through Pm's if detection function is there. :)

Here's the command PM of my script
CMD:pm(playerid, params[]){ if(ServerInfo[PM] == 0) return SendClientMessage(playerid, red, "Sorry, currently PMing has been disabled by server Management!"); if(Loggedin[playerid] == 0) return SendClientMessage(playerid, red, "You must either register or login to use this command!"); new p2, msg[128]; if(sscanf(params, "rs[128]", p2, msg)) {  SendClientMessage(playerid, red, "Usage: /pm [playerid] [message]");  return SendClientMessage(playerid, orange, "Function: Will send a private message to the specified player only."); } if(p2 == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid player id!"); if(!IsPlayerConnected(p2)) return SendClientMessage(playerid, red, "This player is not connected!"); if(pm[p2] == 0) return SendClientMessage(playerid, red, "This user has disabled recieving PMs! (PMing Failed)"); if(p2 == playerid) return SendClientMessage(playerid, red, "You cannot PM yourself!"); new Lname[MAX_PLAYER_NAME], Pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, Lname, sizeof(Lname)); GetPlayerName(p2, Pname, sizeof(Pname)); new string[128]; if(DetectAdv(msg)) {  format(string, sizeof(string), "%s (ID:%d) has been kicked from the server! (Reason:Advertising via PM)", Lname, playerid);  SendClientMessageToAll(red, string);  new Hour, Min, Sec, Year, Mon, Day;  gettime(Hour, Min, Sec);  getdate(Year, Mon, Day);  new pl[16];  GetPlayerIp(playerid, pl, sizeof(pl));  new lstring[256];  format(lstring, sizeof(lstring), "%s has been kicked from the server for advertising through PMS! (Text:%s) (DATE: %d/%d/%d) (TIME: %d:%d:%d) (IP: %s)\r\n", Lname, msg, Day, Mon, Year, Hour, Min, Sec, pl);  new File:adv = fopen("/Server/Logs/Advertised.txt", io_append);  if(adv)  {   fwrite(adv, lstring);   fclose(adv);  }  return SetTimerEx("KICK", 500, false, "d", playerid); } format(string, sizeof(string), "PM from %s (ID:%d) : %s", Lname, playerid, msg); SendClientMessage(p2, yellow, string); format(string, sizeof(string), "PM to %s (ID:%d) : %s", Pname, p2, msg); SendClientMessage(playerid, grey, string); PlaySound(p2, SOUNDNOT); if(ServerInfo[Readpms] == 1) {  if(!IsPlayerAdmin(playerid))  {   if(UserInfo[playerid][Level] != MAX_LEVEL)   {    format(string, sizeof(string), "[PM] %s(%d) to %s(%d): %s", Lname, Pname, msg);    MessageAdmins(MAX_LEVEL, pink, string);   }  } } new fstr[256], Year, Mon, Day, Hour, Min, Sec; getdate(Year, Mon, Day); gettime(Hour, Min, Sec); format(fstr, sizeof(fstr), "|- %s to %s: %s -| (Date: %d/%d/%d) (Time: %d:%d:%d)\r\n", Lname, Pname, msg, Day, Mon, Year, Hour, Min, Sec); new File:pmlog = fopen(pmPath, io_append); if(pmlog) {  fwrite(pmlog, fstr);  fclose(pmlog); } new str[128]; format(str, sizeof(str), "%s : %s (%d:%d:%d)", Lname, msg, Hour, Min, Sec); for(new i = 1; i < MAX_PM-1; i++) Pms[i] = Pms[i+1]; Pms[MAX_PM-1] = str; return 1;}?>

« Last Edit: February 24, 2013, 12:17:57 pm by Lordz »

Offline dude

  • Level 5
  • Sr. Member
  • *
  • Posts: 385
  • Spaghetti
  • Location: The Netherlands
    • www.meatspin.com
  • In-Game: dude
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #3 on: February 24, 2013, 12:16:21 pm »
What about advertising in /cw and /me?

Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #4 on: February 24, 2013, 12:19:06 pm »
What about advertising in /cw and /me?

As I said, if this function is implemented in those commands, they won't be able to advertise. For every commands, I guess implementing the function on command callbacks could work. I prefer doing on place where its needed.

Offline YoUnG_MoNeY

  • Management
  • Sr. Member
  • *
  • Posts: 773
  • Location: United Arab Emirates
    • YG
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #5 on: February 24, 2013, 01:58:41 pm »
Good job lordz.


2012 - The worse year i have ever seen!! @@
If you are PMing me any pictures then please don't use [img][img]

Offline [YG]Jono

  • Sr. Member
  • *
  • Posts: 998
  • Loyal, Honorable & Experienced Admin at YG 0.3x!
  • Location: Melbourne, Australia
  • In-Game: [YG]Jono
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #6 on: February 24, 2013, 02:08:04 pm »
Nice Job, that should really help!

Thanks to [xB]SpiDeY

Offline [RD]Hawk

  • VIP Level 2
  • Sr. Member
  • *
  • Posts: 889
  • One step closer to u.. One step closer to ur death
  • Location: England, London, Eastbourne
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #7 on: February 24, 2013, 03:06:06 pm »
Nice work!
Make sure twice it works for every cmd


Also known for the famous, not very used quote

LiKe A Bo$$

Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #8 on: February 24, 2013, 07:11:21 pm »
Good job lordz.

Thanks YoUnG. :)
Nice Job, that should really help!
Hope so, it might really help.
Nice work!
Make sure twice it works for every cmd

It works perfect if the function is added on every text commands. :)

Thanks to others too. :)

Offline BlackBloods

  • Level 5
  • Sr. Member
  • *
  • Posts: 360
  • YG Graphix Editor
  • Location: Dubai
    • www.yg-gaming.com
  • In-Game: [YG]BlackBloods
Re: Anti-Advertisement - Protection for commands and chat!
« Reply #9 on: February 24, 2013, 11:28:43 pm »
good job lordz


Offline Jenna

  • Level 6
  • Jr. Member
  • *
  • Posts: 24
  • Location: Finland
Good job Lordz. :]

Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM

Offline [RD]KiRaN

  • Level 9
  • Sr. Member
  • *
  • Posts: 318
  • " Rest In Peace "
  • Location: Antartica :)
Ufff.........
Amazing  ;)  8)

Offline Adi

  • Level 5
  • Sr. Member
  • *
  • Posts: 583
  • Friendly and Experienced Level 5 Admin on YG 3E
  • Location: ISB,Pakistan
Nyc Work Bro
Even though i couldnt understand **** of the pawn code :p

Offline [LS]Flo_W

  • Level 5
  • Sr. Member
  • *
  • Posts: 304
  • Loyal Admin at 3x
  • Location: Faisalabad (Punjab), Pakistan
  • In-Game: [LS]Flo_W
It would be Awesome if Added  8) 8) 8) 8) 8) 8)