Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-29-2007, 04:54 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Detect HTML

I made this quickly for my message system that used GUIs.

I'll probably eventually make it simply remove the HTML, but for now it's a way to tell if they inputted HTML.

An example is if you have a GUI message system, and someone massed <img src="block.png"> for example. You could disable HTML, but then if you needed colors, etc, you couldn't use them.

The way I used it was this:
PHP Code:
if ( player.chat.starts":mass" ) )
  {
    
temp.txt player.chat.substring).trim();
    
temp.removeHTMLtemp.txt );
    
triggerserver"gui"name"massMessage"temp.);
  } 
Here is the class.

Script for class functions_removehtml:
PHP Code:
public function removeHTMLtext )
{
  
this.html = { "a""b""body""br""center""font""hl""hr""i""ignorelinebreaks""img""p""spam""ul""ol""li""div" };

  for ( 
temp.this.html )
  {
    
temp."<" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
    
temp."</" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
  }
  return 
text;
}
//#CLIENTSIDE
public function removeHTMLtext )
{
  
this.html = { "a""b""body""br""center""font""hl""hr""i""ignorelinebreaks""img""p""spam""ul""ol""li""div" };

  for ( 
temp.this.html )
  {
    
temp."<" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
    
temp."</" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
  }
  return 
text;

It's a very simple script, but I figured someone might get some use out of it. When I make it remove HTML, I will update it.

Feel free to leave feedback!
Thanks,
Chris Zakuto

EDIT: Updated it to remove the HTML instead of just giving an error. It removes the < right before it, making it not work. There was also another error that I fixed.
__________________

Last edited by cbk1994; 11-29-2007 at 05:04 AM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.