~Air Posted January 3, 2015 Posted January 3, 2015 Hey guys, I am back with an another problem but I don't know what's false, there is no error. Here is the code: -- Teamchat local function playerChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then local color = getAccountData(acc,"chatc") outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) else outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) end else outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) end outputServerLog("CHAT: "..getPlayerName(source)..": "..message) end end addEventHandler("onPlayerChat", root, playerChat)
Castillo Posted January 3, 2015 Posted January 3, 2015 And the problem is...? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MTA Team botder Posted January 3, 2015 MTA Team Posted January 3, 2015 He sends the message to every player (root) and wonders why everyone can see the message. GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
Castillo Posted January 3, 2015 Posted January 3, 2015 Yeah, I noticed that, but he's not even stating what is the problem with his code. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MTA Team botder Posted January 3, 2015 MTA Team Posted January 3, 2015 Thread title: Teamchat shows on globalchat (messageType == 2) GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
Castillo Posted January 3, 2015 Posted January 3, 2015 Oh, my bad, I didn't read that part, still, it would be good if he put it on the actual topic aswell. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
~Air Posted January 3, 2015 Author Posted January 3, 2015 Sorry, that I didn't write it in the topic So the problem is if you press Y (messageType == 2) everyone can read this message if he isn't in a team or in an another team.
Castillo Posted January 3, 2015 Posted January 3, 2015 Well, that's obvious, isn't it? do you see any team-related function in that code? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
~Air Posted January 3, 2015 Author Posted January 3, 2015 Oh.. yeah sorry im so dumb, but thanks. I'll fix it by myself.
~Air Posted January 5, 2015 Author Posted January 5, 2015 Here is my new code: it's still the same problem: everyone can see it. local function playerChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then local color = getAccountData(acc,"chatc") local team = getPlayerTeam ( source ) if ( not team ) then return end for _, team in ipairs ( getPlayersInTeam ( team ) ) do outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) end else outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) end else outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) end outputServerLog("CHAT: "..getPlayerName(source)..": "..message) end end addEventHandler("onPlayerChat", root, playerChat)
Anubhav Posted January 5, 2015 Posted January 5, 2015 You are outputing it to root. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Castillo Posted January 5, 2015 Posted January 5, 2015 for _, team in ipairs ( getPlayersInTeam ( team ) ) do outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) end You must change 'root' to 'team'. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
~Air Posted January 5, 2015 Author Posted January 5, 2015 for _, team in ipairs ( getPlayersInTeam ( team ) ) do outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) end --> to: for _, team in ipairs ( getPlayersInTeam ( team ) ) do outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, team, 255, 255, 255, true ) end ?
Castillo Posted January 5, 2015 Posted January 5, 2015 Yes. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted January 5, 2015 Posted January 5, 2015 You don't have to change event handler. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
~Air Posted January 6, 2015 Author Posted January 6, 2015 That's my script, but I can see it anyway. local function teamChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then local color = getAccountData(acc,"chatc") local team = getPlayerTeam ( source ) if ( not team ) then return end for _, team in ipairs ( getPlayersInTeam ( team ) ) do outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, team, 255, 255, 255, true ) end else outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, team, 255, 255, 255, true ) end else outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, team, 255, 255, 255, true ) end outputServerLog("CHAT: "..getPlayerName(source)..": "..message) end end addEventHandler("onPlayerChat", root, teamChat)
Castillo Posted January 6, 2015 Posted January 6, 2015 That's because "team" is nil outside that 'if' statement. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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