Jump to content

Since im new scripter here.. outputChatBox Help


Mat101

Recommended Posts

Posted

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!

  • Moderators
Posted

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 
) 

  • Moderators
Posted
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.

Posted

Ok.. Maybe i'm really going off topic now, because i don't want to make lots of topics since im a noob scripter here

1: How to set player postion?

2:How to set player world?

3: How to set player Interior

Thanks!! Sorry if im being (....)

Posted

@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 
) 

Posted

Maybe do a little search?

https://wiki.multitheftauto.com/

There are tutorials, functions and event lists, examples, everything you need to learn, and everything you need for everyday use

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

looks like you set is as gamemode, and there is no script to spawn you then..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

  • Moderators
Posted
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> 

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

This Unofficial MTA Script Editor is checking syntax in real time, try it:

viewtopic.php?f=91&t=24834&start=0

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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