Jump to content

English Only ... #1


justn

Recommended Posts

This didn't help at all... did you read what i wanted? :/

Actually that code is what you want, although it's a bit sloppy.

Try using this, it should work.

addEventHandler ( "onPlayerChat", root, function ( message ) 
    for i=1, string.len ( message ) do 
        local n = message:sub ( i, i ) 
        if ( n:byte ( ) < 32 or n:byte ( ) > 127 ) then 
            cancelEvent ( ) 
            outputChatBox ( "English characters only...", source, 255, 0, 0 ) 
            return; 
        end 
    end  
end ) 

Link to comment
This didn't help at all... did you read what i wanted? :/

Actually that code is what you want, although it's a bit sloppy.

Try using this, it should work.

addEventHandler ( "onPlayerChat", root, function ( message ) 
    for i=1, string.len ( message ) do 
        local n = message:sub ( i, i ) 
        if ( n:byte ( ) < 32 or n:byte ( ) > 127 ) then 
            cancelEvent ( ) 
            outputChatBox ( "English characters only...", source, 255, 0, 0 ) 
            return; 
        end 
    end  
end ) 

In The Netherlands ( so Dutch ) we also use English letters... it's quite hard to actually make a script like that haha!

Link to comment
This didn't help at all... did you read what i wanted? :/

Actually that code is what you want, although it's a bit sloppy.

Try using this, it should work.

addEventHandler ( "onPlayerChat", root, function ( message ) 
    for i=1, string.len ( message ) do 
        local n = message:sub ( i, i ) 
        if ( n:byte ( ) < 32 or n:byte ( ) > 127 ) then 
            cancelEvent ( ) 
            outputChatBox ( "English characters only...", source, 255, 0, 0 ) 
            return; 
        end 
    end  
end ) 

In The Netherlands ( so Dutch ) we also use English letters... it's quite hard to actually make a script like that haha!

Well yes, a lot of Spanish does too. I actually don't think you can fully block other languages unless well you want to write an English dictionary in a table lol. I could be wrong though.

Link to comment
Actually that code is what you want

Ah... because when I tested his.. i said something arabic in chat . and it still worked :P

I actually don't think you can fully block other languages unless well you want to write an English dictionary in a table lol.

Hahah. I had that suggestion, but I don't think I wanna take a long time creating a english dictionary...

__

@xXMADEXx: In your code, the event doesn't get cancelled

Link to comment
Any help?

What you can do, is try to fetch the google translate page ( or write a php script with an API if there is one ) and let it detect if it's English or not. Keep in mind that typos will be blocked too. so people with bad English won't be able to talk either!

Link to comment

cancelEvent() doesn't work.. and Freeroam is not running.. I edited his code a bit:

addEventHandler ( "onPlayerChat", root, function ( message,messageType ) 
    if ( messageType == 0 ) then 
        for i=1, string.len ( message ) do 
            local n = message:sub ( i, i ) 
            if ( n:byte ( ) < 32 or n:byte ( ) > 127 ) then 
                cancelEvent ( ) 
                outputChatBox ( "#0075ff(Language): #FFFFFFMain chat is for #0075ffEnglish #FFFFFFonly !", source, 255, 0, 0,true ) 
                return; 
            end 
        end 
    end 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...