Eshtiz Posted February 7, 2012 Posted February 7, 2012 I'm trying to add a new chat, /i /info /ichat This is what I got so far: function infochat(thePlayer, commandName, ...) if ( exports.global:isPlayerBronzeDonator(thePlayer) or exports.global:isPlayerAdmin(thePlayer) ) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local message = table.concat({...}, " ") local title = "" local hidden = getElementData(thePlayer, "hiddenadmin") or 0 if ( exports.global:isPlayerAdmin(thePlayer) ) then if (hidden == 1) or (exports.global:getPlayerAdminTitle(thePlayer) == "Player") then if not (exports.global:isPlayerBronzeDonator(thePlayer)) then title = "Bronze Donator" else title = exports.global:getPlayerDonatorTitle(thePlayer) end else title = exports.global:getPlayerAdminTitle(thePlayer) end elseif ( exports.global:isPlayerBronzeDonator(thePlayer) ) then title = exports.global:getPlayerDonatorTitle(thePlayer) end for key, value in ipairs(getElementsByType("player")) do if ( exports.global:isPlayerBronzeDonator(value) or exports.global:isPlayerAdmin(value) ) then if ( getElementData(value, "infochat") == 1 ) then outputChatBox("[Donator] " .. title .. " " .. getPlayerName(thePlayer) .. ": " .. message, value, 160, 164, 104) end end end end end end addCommandHandler("i", infochat, false, false) addCommandHandler("info", infochat, false, false) addCommandHandler("ichat", infochat, false, false) There is no error messages but it doesn't work.
Kenix Posted February 7, 2012 Posted February 7, 2012 Server side. function infochat( thePlayer, commandName,... ) if exports.global:isPlayerBronzeDonator( thePlayer ) or exports.global:isPlayerAdmin( thePlayer ) then local tArgs = { ... } if #tArgs == 0 then outputChatBox( "SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14 ) else local message = table.concat( tArgs, " " ) local title = "" local hidden = getElementData( thePlayer, "hiddenadmin" ) or 0 if exports.global:isPlayerAdmin( thePlayer ) then if hidden == 1 or exports.global:getPlayerAdminTitle( thePlayer ) == "Player" then if not exports.global:isPlayerBronzeDonator( thePlayer ) then title = "Bronze Donator" else title = exports.global:getPlayerDonatorTitle( thePlayer ) end else title = exports.global:getPlayerAdminTitle( thePlayer ) end elseif exports.global:isPlayerBronzeDonator( thePlayer ) then title = exports.global:getPlayerDonatorTitle( thePlayer ) end for key, value in pairs( getElementsByType 'player' ) do if exports.global:isPlayerBronzeDonator( value ) or exports.global:isPlayerAdmin( value ) then if getElementData( value, "infochat" ) == 1 then outputChatBox( "[Donator] " .. title .. " " .. getPlayerName( thePlayer ) .. ": " .. message, value, 160, 164, 104 ) end end end end end end addCommandHandler( "i", infochat, false, false ) addCommandHandler( "info", infochat, false, false ) addCommandHandler( "ichat", infochat, false, false )
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 Got this now; WARNING: loading script failed: chat-system/s_chat_system.lua:1084 ' Syntax shows but no chat.
Kenix Posted February 7, 2012 Posted February 7, 2012 It should work.( i have debugger in notepad++ and i not see syntax errors ) You bad copypaste Show code in 1084 line.
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 Yeh, you're right, the bug message is gone, but there's no chat, only syntax.
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 Show code in 1084 line. Here: function infochat( thePlayer, commandName,... ) if exports.global:isPlayerBronzeDonator( thePlayer ) or exports.global:isPlayerAdmin( thePlayer ) then local tArgs = { ... } if #tArgs == 0 then outputChatBox( "SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14 ) else local message = table.concat( tArgs, " " ) local title = "" local hidden = getElementData( thePlayer, "hiddenadmin" ) or 0 if exports.global:isPlayerAdmin( thePlayer ) then if hidden == 1 or exports.global:getPlayerAdminTitle( thePlayer ) == "Player" then if not exports.global:isPlayerBronzeDonator( thePlayer ) then title = "Bronze Donator" else title = exports.global:getPlayerDonatorTitle( thePlayer ) end else title = exports.global:getPlayerAdminTitle( thePlayer ) end elseif exports.global:isPlayerBronzeDonator( thePlayer ) then title = exports.global:getPlayerDonatorTitle( thePlayer ) end for key, value in pairs( getElementsByType 'player' ) do if exports.global:isPlayerBronzeDonator( value ) or exports.global:isPlayerAdmin( value ) then if getElementData( value, "infochat" ) == 1 then outputChatBox( "[Donator] " .. title .. " " .. getPlayerName( thePlayer ) .. ": " .. message, value, 160, 164, 104 ) end end end end end end addCommandHandler( "i", infochat, false, false ) addCommandHandler( "info", infochat, false, false ) addCommandHandler( "ichat", infochat, false, false ) It's the fifth 'end'
Kenix Posted February 7, 2012 Posted February 7, 2012 Very strange i not see errors ... i use 2 debuggers and not see error. Try convert to utf-8 without BOM
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