Eshtiz Posted February 20, 2012 Share Posted February 20, 2012 Hello ( Again ), I've been trying to fix an unique feature but it keeps failing and disables all other chats and puts them together (classic MTA chat or whatever). I'm trying to make this chat into a radio: function factionOOC(thePlayer, commandName, ...) local logged = getElementData(thePlayer, "loggedin") if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local theTeam = getPlayerTeam(thePlayer) local theTeamName = getTeamName(theTeam) local playerName = getPlayerName(thePlayer) local playerFaction = getElementData(thePlayer, "faction") if not(theTeam) or (theTeamName=="Citizen") then outputChatBox("You are not in a faction.", thePlayer) else local message = table.concat({...}, " ") if (togState[playerFaction]) == true then return end exports.logs:logMessage("[OOC: " .. theTeamName .. "] " .. playerName .. ": " .. message, 6) for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do if isElement( arrayPlayer ) then if getElementData( arrayPlayer, "bigearsfaction" ) == theTeam then outputChatBox("((" .. theTeamName .. ")) " .. playerName .. ": " .. message, arrayPlayer, 3, 157, 157) elseif getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then outputChatBox("((OOC Faction Chat)) " .. playerName .. ": " .. message, arrayPlayer, 3, 237, 237) end end end end end end end addCommandHandler("f", factionOOC, false, false) like this: function radio(source, radioID, message) radioID = tonumber(radioID) or 1 local hasRadio, itemKey, itemValue, itemID = exports.global:hasItem(source, 6) if hasRadio then local theChannel = itemValue if radioID ~= 1 then local count = 0 local items = exports['item-system']:getItems(source) for k, v in ipairs(items) do if v[1] == 6 then count = count + 1 if count == radioID then theChannel = v[2] break end end end end if theChannel == 1 then outputChatBox("Please Tune your radio (( /tuneradio # ))", source, 255, 194, 14) elseif theChannel > 1 then triggerClientEvent (source, "playRadioSound", getRootElement()) local username = getPlayerName(source) local languageslot = getElementData(source, "languages.current") local language = getElementData(source, "languages.lang" .. languageslot) local languagename = call(getResourceFromName("language-system"), "getLanguageName", language) local factionID = getElementData(source,"faction") if not (factionID == -1) then local theTeam = getPlayerTeam(source) local factionrank = tonumber(getElementData(source,"factionrank")) local ranks = getElementData(theTeam,"ranks") factionRankTitle = ranks[factionrank] .. " - " else factionRankTitle = "" end message = trunklateText( source, message ) outputChatBox("[" .. languagename .. "] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. message, source, 0, 102, 255) for key, value in ipairs(getElementsByType( "player" )) do local logged = getElementData(source, "loggedin") if (isElement(value)) and (logged==1) and (value~=source) then if (exports.global:hasItem(value, 6, theChannel)) then triggerClientEvent (value, "playRadioSound", getRootElement()) local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language) outputChatBox("[" .. languagename .. "] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. trunklateText( value, message2 ), value, 0, 102, 255) if (exports.global:hasItem(value, 88) == false) then -- Show it to people near who can hear his radio for k, v in ipairs(exports.global:getNearbyElements(value, "player",7)) do local logged2 = getElementData(v, "loggedin") if (logged2==1) then if (exports.global:hasItem(v, 6, targetChannel) == false) then local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, v, message, language) outputChatBox("[" .. languagename .. "] " .. getPlayerName(value) .. "'s Radio: " .. trunklateText( v, message2 ), v, 255, 255, 255) end end end end end end end --Show the radio to nearby listening in people near the speaker for key, value in ipairs(getElementsByType("player")) do if getElementDistance(source, value) < 10 then if (value~=source) then local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language) outputChatBox("[" .. languagename .. "] " .. getPlayerName(source) .. " [RADIO] says: " .. message2, value, 255, 255, 255) end end end else outputChatBox("Your radio is off. ((/toggleradio))", source, 255, 0, 0) end else outputChatBox("You do not have a radio.", source, 255, 0, 0) end end I'm trying to add the sound, required radio to use /f(action chat) BUT no channel!!! Plus that nearby players can hear/see the text. It isn't really working as I said earlier, I'm simply trying to make the /f chat into a radio but no channel, it uses the faction's "default channel" like the chat. Link to comment
Paper Posted February 22, 2012 Share Posted February 22, 2012 Wait, you want to show the output just to the players in a definied team and it shows to all players? Link to comment
Eshtiz Posted February 22, 2012 Author Share Posted February 22, 2012 In a definied team (faction), everyone who's in that faction will be able to see it PLUS nearby people, just like a radio and a required radio/item to use /f (factionOOC) Link to comment
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