Jump to content

[REL] orangeppop's intelligent chat system


bovine3dom

Recommended Posts

Basically, it just uses string.find to find stuff within your message. <3

==== orangeppop's intelligent chat system ====

==Basic Information ==

orangeppop's intelligent chat system looks for punctuation in your chat message in order to deliver a more immersive chatting experience for Roleplay and Freeroam scripts. It consists of:

+ Ranged Chat

+ Team Chat (CB Radio)

+ Public Chat

== Ranged Chat ==

Use MTA's normal chat system ( bound by default to ' T ') as you would normally. The default distance for ranged chat is 10 metres.

The advanced features of the chat sytem useable in the ranged chat are:

+ If a message ends in an exclamation mark ( ! ), it will go for 20 metres.

+ If a message ends in a question mark ( ? ), it will go for 10 metres.

+ If a message is enclosed in brackets ( ( message) ), it will go for 10 metres as OOC chat (out of character).

Examples:

hey

orangeppop says: hey

hey!

orangeppop shouts: hey!

hey?

orangeppop asks: hey?

(hey)

((orangeppop says (OOC): hey))

== Team Chat ==

Use MTA's normal team chat system ( bound by default to ' Y ') as you would normally. The same features as ranged chat apply (except they have no affect on the distances; all messages are sent to all of your teamates)

== Ranged 'Action' Chat ==

/me [text] is now ranged to 10 metres. For public action chat, use /me #[text].

== Public Chat ==

To speak to the whole server, use #[text] in both /me and normal chat.

== Smiley Recognition ==

Most smileys will be converted into actions (e.g. :) -> *orangeppop smiles)

To stop this from happening, simply place a full stop anywhere in your message else the rest of the message will be discarded.

=== Coming Soon! ===

+ A whisper with punctuation check... just need to think of something. :D

=== Known Issues ===

If you have a function triggered by an event handler like this:

addEventHandler("onColShapeHit", getRootElement(), etc.)

It will be triggered whenever someone uses ranged chat.

Download: http://community.mtasa.com/index.html?p ... ils&id=251

EDIT: 1.2.1 released

Link to comment
  • 2 weeks later...

I took a look at the resource and it seems you have a lot of code duplication. It doesn't mean it's bad, but it's just not optimised. For example instead of defining local chatRadius everywhere you could define it at start globally (or locally, but outside the function) so it could be changed easily too.

Like you have this:

            elseif angry or angry1 then 
                local chatRadius = 10  
                local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
                local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
                destroyElement( chatSphere ) 
                for index, nearbyPlayer in ipairs( nearbyPlayers ) do  
                    outputChatBox( playerName.." is angry", nearbyPlayer, 200, 200, 200 ) 
                end 
            elseif evil then 
                local chatRadius = 10  
                local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
                local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
                destroyElement( chatSphere ) 
                for index, nearbyPlayer in ipairs( nearbyPlayers ) do  
                    outputChatBox( playerName.." grins evilly", nearbyPlayer, 200, 200, 200 ) 
                end 
            elseif fuming then 
                local chatRadius = 10  
                local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
                local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
                destroyElement( chatSphere ) 
                for index, nearbyPlayer in ipairs( nearbyPlayers ) do  
                    outputChatBox( playerName.." is fuming", nearbyPlayer, 200, 200, 200 ) 
                end 

Could be done faster with just

http://lordy.pastebin.com/d55333e66

If you can get what I mean there then you could use it, if you don't, then don't try experimenting because I know I didn't explain it too well there. But the main idea is that if you define the nearbyplayers and the radius each time it could be more meaningful to define them before the if statements and inside the if statements only set the variables that vary (hence variables). And after the ifs you can just outputChatBox(prefix..playerName..suffix..message, playerstooutput, r, g, b) and you can use it for all your types. If you want to even make a normal chat with it all you have to do is inside the elseif part just define prefix = ""; suffix = ": "; playerName=getClientName(thePlayer); playersToOutput=getRootElement() ; r,g,b = getPlayerTeamColor(thePlayer) and then still use the same outputChatBox without code duplication.. but again, if I didn't make sense, don't try to understand :D

Link to comment
Basically, it just uses string.find to find stuff within your message. <3

==== orangeppop's intelligent chat system ====

==Basic Information ==

orangeppop's intelligent chat system looks for punctuation in your chat message in order to deliver a more immersive chatting experience for Roleplay and Freeroam scripts. It consists of:

+ Ranged Chat

+ Team Chat (CB Radio)

+ Public Chat

== Ranged Chat ==

Use MTA's normal chat system ( bound by default to ' T ') as you would normally. The default distance for ranged chat is 10 metres.

The advanced features of the chat sytem useable in the ranged chat are:

+ If a message ends in an exclamation mark ( ! ), it will go for 20 metres.

+ If a message ends in a question mark ( ? ), it will go for 10 metres.

+ If a message is enclosed in brackets ( ( message) ), it will go for 10 metres as OOC chat (out of character).

Examples:

hey

orangeppop says: hey

hey!

orangeppop shouts: hey!

hey?

orangeppop asks: hey?

(hey)

((orangeppop says (OOC): hey))

== Team Chat ==

Use MTA's normal team chat system ( bound by default to ' Y ') as you would normally. The same features as ranged chat apply (except they have no affect on the distances; all messages are sent to all of your teamates)

== Ranged 'Action' Chat ==

/me [text] is now ranged to 10 metres. For public action chat, use /me #[text].

== Public Chat ==

To speak to the whole server, use #[text] in both /me and normal chat.

== Smiley Recognition ==

Most smileys will be converted into actions (e.g. :) -> *orangeppop smiles)

To stop this from happening, simply place a full stop anywhere in your message else the rest of the message will be discarded.

=== Coming Soon! ===

+ A whisper with punctuation check... just need to think of something. :D

=== Known Issues ===

If you have a function triggered by an event handler like this:

addEventHandler("onColShapeHit", getRootElement(), etc.)

It will be triggered whenever someone uses ranged chat.

Download: http://community.mtasa.com/index.html?p ... ils&id=251

EDIT: 1.2.1 released

Is it also possible to get this chat on the right side of the screen and to leave the original chat at the left place?

Because I want this and also the normal chat..

Link to comment

Thehookerkiller01: It's possible, but right now I have neither the time nor the ability to do so.

LordAzamath: Thanks for the heads up but I had put it there so that people could hopefully learn a bit from my code (otherwise I wouldn't have defined it anywhere as a variable; I would have just put it in as an argument). I might make getNearbyPlayers()

Nevermore: is it reproducible? It won't do it for me. I suspect that you have another resource that is stopping the cancelEvent() or that you have edited it by accident.

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...