Wes Posted March 10, 2013 Posted March 10, 2013 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.
PaiN^ Posted March 10, 2013 Posted March 10, 2013 We don't do scripts here, You do a script and we well help .. Or you can ask for a paid script ..
Sasu Posted March 10, 2013 Posted March 10, 2013 Im boring 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")
Anderl Posted March 10, 2013 Posted March 10, 2013 Why do you even need code in both sides? You can do it all in the server side.
Sasu Posted March 10, 2013 Posted March 10, 2013 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
PaiN^ Posted March 10, 2013 Posted March 10, 2013 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
Sasu Posted March 10, 2013 Posted March 10, 2013 Pain, I forgot that I can do on client side but in server side we cant don ._.. Say me a example.
Anderl Posted March 10, 2013 Posted March 10, 2013 (edited) Re-read the page, there is a "Server - Syntax 2" box. Edited March 10, 2013 by Guest
iPrestege Posted March 10, 2013 Posted March 10, 2013 bindKey(source, "b", "down", "chatbox", "global") This is an example for server side.
Sasu Posted March 10, 2013 Posted March 10, 2013 bindKey(source, "b", "down", "chatbox", "global") This is an example for server side. Lol sorry. I didnt see that . 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?
Wes Posted March 10, 2013 Author Posted March 10, 2013 Thank you I test it and I'll tell you this. Nope it doesnt work.. I press B and nothing happens...
iPrestege Posted March 10, 2013 Posted March 10, 2013 bindKey(source, "b", "down", "chatbox", "global") This is an example for server side. Lol sorry. I didnt see that . 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
Sasu Posted March 10, 2013 Posted March 10, 2013 Create a client side Im boring 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
iPrestege Posted March 10, 2013 Posted March 10, 2013 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 )
Wes Posted March 10, 2013 Author Posted March 10, 2013 Thank you it's working now!! Both is working, im gonna use the server sided one, thank you pal!
Wes Posted March 10, 2013 Author Posted March 10, 2013 How can I fix that the players cant send an empty message? So he presses a space and he can send that empty.
Sasu Posted March 10, 2013 Posted March 10, 2013 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 )
PaiN^ Posted March 10, 2013 Posted March 10, 2013 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 ..
Sasu Posted March 10, 2013 Posted March 10, 2013 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now