Jump to content

Since im new scripter here.. outputChatBox Help


Mat101

Recommended Posts

Hello,

I'm Wondering if this will send to all players or to the player.

addEventHandler("onPlayerWasted", root, 
    function() 
        outputChatBox("You Got Wasted!!",true) 
    end 
) 

Does that send it to the player or to all?

And i have another question...

onPlayerWasted is there any way to... Example : Mat101 Has Just killed you. (mat101 example mean the player name)

Thanks for help!

Link to comment
  • Discord Moderators

Yes that will output to all players, because you haven't specified anything else and it's by default the root element.

int totalAmmo, element killer, int killerWeapon, int bodypart [, bool stealth ] 

The source of this event is the player that died or got killed.

So we can carry out your example:

addEventHandler("onPlayerWasted", getRootElement(), function(ammo, killer) 
if getElementType(killer) == "player" then 
outputChatBox(getPlayerName(killer)).." has just killed you!", source, 0, 255, 0) 
end 
end 
) 

Link to comment
  • Discord Moderators
Nice man, what does 255 mean?

https://wiki.multitheftauto.com/wiki/OutputChatBox

outputChatBox ( string text [, element visibleTo=getRootElement(), [b]int r=255, int g=255, int b=255[/b], bool colorCoded=false ] ) 

These last optional highlighted arguments can specify what colour the message should be in, defined in RGB (Red Green Blue).

255 0 0

0 255 0

0 0 255

255 is the max value, you mix these to produce different colours.

Link to comment

@Zango, The script is crashing with this code

addEventHandler("onPlayerWasted", getRootElement(), function(ammo, killer) 
    if getElementType(killer) == "player" then 
    outputChatBox(getPlayerName(killer)).." has just killed you!", source, 0, 255, 0) 
    end 
    end 
) 

Link to comment
  • Discord Moderators
The whole script doesn't work,

Here is a picture..

http://img442.imageshack.us/img442/9148/90058203.jpg

try this,

addEventHandler("onPlayerWasted", getRootElement(), function(ammo, killer) 
    if getElementType(killer) == "player" then 
    outputChatBox(getPlayerName(killer).." has just killed you!", source, 0, 255, 0) 
    end 
    end 
) 

Yeah syntax was knackered,

outputChatBox(getPlayerName(killer[b]))..[/b]" has just killed you!", source, 0, 255, 0) 

should be:

outputChatBox(getPlayerName(killer[b]).[/b]." has just killed you!", source, 0, 255, 0) 

as said above, I apologise.

And as varez mentioned, this isn't a gamemode, just run this serverside script along with freeroam for example.

meta.xml if you were in doubt:

<meta> 
<script src="server.lua" /> 
</meta> 

Link to comment
The whole script doesn't work,

Here is a picture..

http://img442.imageshack.us/img442/9148/90058203.jpg

try this,

addEventHandler("onPlayerWasted", getRootElement(), function(ammo, killer) 
    if getElementType(killer) == "player" then 
    outputChatBox(getPlayerName(killer).." has just killed you!", source, 0, 255, 0) 
    end 
    end 
) 

Yeah syntax was knackered,

outputChatBox(getPlayerName(killer[b]))..[/b]" has just killed you!", source, 0, 255, 0) 

should be:

outputChatBox(getPlayerName(killer[b]).[/b]." has just killed you!", source, 0, 255, 0) 

as said above, I apologise.

And as varez mentioned, this isn't a gamemode, just run this serverside script along with freeroam for example.

meta.xml if you were in doubt:

<meta> 
<script src="server.lua" /> 
</meta> 

Please check the post he did b4 thats what i actually fixed, i removed one of the ")" cause it was making an error.

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