Jump to content

global chat


Wes

Recommended Posts

Posted

Hey! Can someone send me a download link to a global chat script?

I mean for example the player presses the B button, then what he wrote is going to be seen by everyone on the chat, like [GLOBAL] PlayerName: Message.

Thank you.

Posted

We don't do scripts here, You do a script and we well help ..

Or you can ask for a paid script ..

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

Im boring :S

Server:

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ) 
    local name = getPlayerName(thePlayer) 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message, getRootElement(), 255, 255, 255, true) 
    end 
addCommandHandler("global", globalMessage) 

Client:

bindKey("b", "down", "chatbox", "global") 

State: Inactive

Posted

Why do you even need code in both sides? You can do it all in the server side.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
Why do you even need code in both sides? You can do it all in the server side.

Anderl its imposible bind a key to command in server side. Search that on wiki. https://wiki.multitheftauto.com/wiki/BindKey

It's not ..!

If it was, It would have been a client only function

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

It isn't, re-read the page.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Pain, I forgot that I can do on client side but in server side we cant don ._.. Say me a example.

State: Inactive

Posted (edited)

Re-read the page, there is a "Server - Syntax 2" box.

Edited by Guest

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
bindKey(source, "b", "down", "chatbox", "global") 

This is an example for server side.

Lol sorry. I didnt see that xD. Thanks for correcting me.

EDIT: so...

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ) 
    local name = getPlayerName(thePlayer) 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message, getRootElement(), 255, 255, 255, true) 
    end 
addCommandHandler("global", globalMessage) 
bindKey(getRootElement(), "b", "down", "chatbox", "global") 

Is it correctly?

State: Inactive

Posted

Thank you I test it and I'll tell you this.

Nope it doesnt work.. I press B and nothing happens...

Posted
bindKey(source, "b", "down", "chatbox", "global") 

This is an example for server side.

Lol sorry. I didnt see that xD. Thanks for correcting me.

EDIT: so...

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ) 
    local name = getPlayerName(thePlayer) 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message, getRootElement(), 255, 255, 255, true) 
    end 
addCommandHandler("global", globalMessage) 
bindKey(getRootElement(), "b", "down", "chatbox", "global") 

Is it correctly?

No that's wrong won't work -_-

  

Posted

Create a client side

Im boring :S

Server:

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ) 
    local name = getPlayerName(thePlayer) 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message, getRootElement(), 255, 255, 255, true) 
    end 
addCommandHandler("global", globalMessage) 

Client:

bindKey("b", "down", "chatbox", "global") 

Because I dont know how to do all in server side :S

State: Inactive

Posted

Try this server side :

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
    end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
  
addEventHandler("onPlayerJoin", getRootElement(),  
function() 
  bindKey(source, "b", "down", "chatbox", "global"); 
end 
) 

:wink:

  

Posted

How can I fix that the players cant send an empty message? So he presses a space and he can send that empty.

Posted

Thanks to me? :C

function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
if message then 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
    end 
end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
  
addEventHandler("onPlayerJoin", getRootElement(), 
function() 
  bindKey(source, "b", "down", "chatbox", "global"); 
end 
) 

State: Inactive

Posted
How can I fix that the players cant send an empty message? So he presses a space and he can send that empty.
Thanks to me? :C
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
if message then 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
    end 
end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
  
addEventHandler("onPlayerJoin", getRootElement(), 
function() 
  bindKey(source, "b", "down", "chatbox", "global"); 
end 
) 

I really don't think this will do it ..

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
How can I fix that the players cant send an empty message? So he presses a space and he can send that empty.
Thanks to me? :C
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
if message then 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
    end 
end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
  
addEventHandler("onPlayerJoin", getRootElement(), 
function() 
  bindKey(source, "b", "down", "chatbox", "global"); 
end 
) 

I really don't think this will do it ..

¬¬ I did the introduction.

State: Inactive

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