Jump to content

[HELP] Error in script


Black2

Recommended Posts

Posted

Hello, I I downloaded a script Here in Communidade MTA made by Crazy,This script has a bar to enter and this bar if you type the letter "T" opens the chat I would love it if some of you could help me Thx.Sorry Bad English :fadein: I do not understand almost anything moon so I was wondering how can I do to not open the chat when you type the letter "T",Thx Again.

Client

nilSound = { 
    ["meta"] = {}, 
    ["length"] = 0, 
    ["pointer"] = nil, 
    ["stream_title"] = nil, 
    ["url"] = nil, 
    ["row"] = nil 
} 
  
currentSound = nilSound 
  
function soundStarted(success,length,streamName) 
    if success then 
        currentSound.pointer = source 
        currentSound.meta = getSoundMetaTags(source) 
        currentSound.length = length 
        if length == 0 then 
            outputChatBox('#FFFF00RADIO: #FFFFFF"'..streamName..'" stream started.',255,0,0,true) 
            if currentSound.meta.title then 
                outputChatBox('#000000*#FFFF00Title: #FFFFFF"'..currentSound.meta.title,255,0,0,true) 
            end 
            if currentSound.meta.artist then 
                outputChatBox('#000000*#FFFF00Artist: #FFFFFF"'..currentSound.meta.artist,255,0,0,true) 
            end 
            if currentSound.meta.stream_name then 
                outputChatBox('#000000*#FFFF00Stream name: #FFFFFF"'..currentSound.meta.stream_name,255,0,0,true) 
            end 
            if currentSound.meta.stream_title then 
                outputChatBox('#000000*#FFFF00Stream title: #FFFFFF"'..currentSound.meta.stream_title,255,0,0,true) 
            elseif currentSound.stream_title then 
                outputChatBox('#000000*#FFFF00Stream title: #FFFFFF"'..currentSound.stream_title,255,0,0,true) 
            end 
        else 
            outputChatBox("*********************************",0,0,0) 
            --[[if currentSound.meta.title then 
                outputChatBox('#FFFF00RADIO: #FFFFFF"'..currentSound.meta.title..'" sound started.',255,0,0,true) 
            else 
                outputChatBox('#FFFF00RADIO: #FFFFFFSound started.',255,0,0,true) 
            end]]-- 
            if currentSound.meta.title then 
                outputChatBox('#000000*#FFFF00Title: #FFFFFF'..currentSound.meta.title,255,0,0,true) 
            end 
            if currentSound.meta.artist then 
                outputChatBox('#000000*#FFFF00Artist: #FFFFFF'..currentSound.meta.artist,255,0,0,true) 
            end 
            outputChatBox('#000000*#FFFF00Length: #FFFFFF'..tostring(getRealTime(length/1000).minute)..":"..tostring(getRealTime(length/1000).second),255,0,0,true) 
            outputChatBox("*********************************",0,0,0) 
        end 
    else 
        outputChatBox("#FFFF00RADIO: #FFFFFFFailed to play sound/stream.",255,0,0,true) 
    end 
end 
  
  
function startSound(url,row) 
    outputChatBox("#FFFF00RADIO: #FFFFFFTrying to play "..url,255,0,0,true) 
    if currentSound.pointer then 
        stopSound(currentSound.pointer) 
    end 
    currentSound = nilSound 
    currentSound.url = url 
    if row then 
        currentSound.row = row 
    end 
    playSound(url) 
end 
  
function onSoundStop() 
    if currentSound.length ~= 0 then 
        if guiCheckBoxGetSelected(GUIEditor_Checkbox[2]) == true then 
            startSound(currentSound.url) 
        else 
            if guiCheckBoxGetSelected(GUIEditor_Checkbox[1]) == true then 
                local totalSounds = guiGridListGetRowCount(GUIEditor_Grid[2]) - 1 
                if currentSound.row + 1 > totalSounds then 
                    startSound(guiGridListGetItemText(GUIEditor_Grid[2],0,soundColumn),0) 
                else 
                    startSound(guiGridListGetItemText(GUIEditor_Grid[2],totalSounds,soundColumn),currentSound.row + 1) 
                end 
            else 
                currentSound = nilSound 
            end 
        end 
    else 
        currentSound = nilSound 
        outputChatBox("#FFFF00RADIO: #FFFFFFStream stopped.",255,0,0,true) 
    end 
end 
  
function onSoundChange(title) 
    currentSound.meta = getSoundMetaTags(source) 
    currentSound.stream_title = title 
    if currentSound.stream_title then 
        outputChatBox("#FFFF00RADIO: #FFFFFFNow playing "..currentSound.stream_title,255,0,0,true) 
    else 
        outputChatBox("#FFFF00RADIO: #FFFFFFNow playing "..currentSound.url,255,0,0,true) 
    end 
    outputChatBox("*********************************",0,0,0) 
    if currentSound.meta.title then 
        outputChatBox('#000000*#FFFF00Title: #FFFFFF"'..currentSound.meta.title,255,0,0,true) 
    end 
    if currentSound.meta.artist then 
        outputChatBox('#000000*#FFFF00Artist: #FFFFFF"'..currentSound.meta.artist,255,0,0,true) 
    end 
    if currentSound.meta.stream_name then 
        outputChatBox('#000000*#FFFF00Stream name: #FFFFFF"'..currentSound.meta.stream_name,255,0,0,true) 
    end 
    if currentSound.meta.stream_title then 
        outputChatBox('#000000*#FFFF00Stream title: #FFFFFF"'..currentSound.meta.stream_title,255,0,0,true) 
    elseif currentSound.stream_title then 
        outputChatBox('#000000*#FFFF00Stream title: #FFFFFF"'..currentSound.stream_title,255,0,0,true) 
    end 
    outputChatBox("*********************************",0,0,0) 
end 
  
--Controls start 
addCommandHandler("vol_up", 
function () 
    if currentSound.pointer then 
        local curVolume = getSoundVolume(currentSound.pointer) 
        if curVolume < 1 then 
            setSoundVolume(currentSound.pointer,curVolume+0.1) 
        else 
            setSoundVolume(currentSound.pointer,1) 
        end 
    end 
end) 
  
addCommandHandler("vol_down", 
function () 
    if currentSound.pointer then 
        local curVolume = getSoundVolume(currentSound.pointer) 
        if curVolume > 0 then 
            setSoundVolume(currentSound.pointer,curVolume-0.1) 
        else 
            setSoundVolume(currentSound.pointer,0) 
        end 
    end 
end) 
  
addCommandHandler("stopsound", 
function () 
    if currentSound.pointer then 
        stopSound(currentSound.pointer) 
        currentSound = nilSound 
        outputChatBox("#FFFF00RADIO: #FFFFFFSound stopped ",255,0,0,true) 
    end 
end) 
--Controls end 
  
--Events start 
addEventHandler("onClientSoundStream",getResourceRootElement(getThisResource()),soundStarted) 
addEvent("onClientSoundStop",false) 
setTimer( 
function () 
    if currentSound.pointer then 
        if currentSound.length ~= 0 then 
            if getSoundPosition(currentSound.pointer) == 0 then 
                triggerEvent("onClientSoundStop",currentSound.pointer) 
            end 
        else 
            if getSoundPosition(currentSound.pointer) == 0 then 
                triggerEvent("onClientSoundStop",currentSound.pointer) 
            end 
        end 
    end 
end,1000,0) 
addEventHandler("onClientSoundStop",getResourceRootElement(getThisResource()),onSoundStop) 
addEventHandler("onClientSoundChangedMeta",getResourceRootElement(getThisResource()),onSoundChange) 

Client gui

screenX,screenY=guiGetScreenSize() 
  
function loadStreamAndSoundList() 
    local streams = xmlLoadFile("streams.xml") 
    if not streams then 
        streams = xmlCreateFile("streams.xml","streams") 
        xmlSaveFile(streams) 
    end 
    local sounds = xmlLoadFile("sounds.xml") 
    if not sounds then 
        sounds = xmlCreateFile("sounds.xml","sounds") 
        xmlSaveFile(sounds) 
    end 
    local streamNodes = xmlNodeGetChildren(streams) 
    local soundNodes = xmlNodeGetChildren(sounds) 
    for i,v in ipairs(streamNodes) do 
        local row = guiGridListAddRow(GUIEditor_Grid[1]) 
        guiGridListSetItemText(GUIEditor_Grid[1],row,streamColumn,xmlNodeGetValue(v),false,false) 
    end 
    for i,v in ipairs(soundNodes) do 
        local row = guiGridListAddRow(GUIEditor_Grid[2]) 
        guiGridListSetItemText(GUIEditor_Grid[2],row,soundColumn,xmlNodeGetValue(v),false,false) 
    end 
    xmlUnloadFile(streams) 
    xmlUnloadFile(sounds) 
end 
  
function updateStreamAndSoundList() 
    local streams = xmlCreateFile("streams.xml","streams") 
    xmlSaveFile(streams) 
    local sounds = xmlCreateFile("sounds.xml","sounds") 
    xmlSaveFile(sounds) 
    local totalStreams = guiGridListGetRowCount(GUIEditor_Grid[1]) 
    local totalSounds = guiGridListGetRowCount(GUIEditor_Grid[2]) 
    for i=0,totalStreams-1 do 
        xmlNodeSetValue(xmlCreateChild(streams,"url"),guiGridListGetItemText(GUIEditor_Grid[1],i,streamColumn)) 
    end 
    for i=0,totalSounds-1 do 
        xmlNodeSetValue(xmlCreateChild(sounds,"url"),guiGridListGetItemText(GUIEditor_Grid[2],i,soundColumn)) 
    end 
    xmlSaveFile(streams) 
    xmlSaveFile(sounds) 
    xmlUnloadFile(streams) 
    xmlUnloadFile(sounds) 
end 
  
function loadGUI() 
    GUIEditor_Window = {} 
    GUIEditor_TabPanel = {} 
    GUIEditor_Tab = {} 
    GUIEditor_Button = {} 
    GUIEditor_Checkbox = {} 
    GUIEditor_Label = {} 
    GUIEditor_Edit = {} 
    GUIEditor_Grid = {} 
  
    GUIEditor_Window[1] = guiCreateWindow(0.1895,0.2396,0.6455,0.5078,"Sound & Radio Player",true) 
    guiWindowSetSizable(GUIEditor_Window[1],false) 
    GUIEditor_TabPanel[1] = guiCreateTabPanel(0.0136,0.0641,0.9728,0.9128,true,GUIEditor_Window[1]) 
    GUIEditor_Tab[1] = guiCreateTab("Streams",GUIEditor_TabPanel[1]) 
    GUIEditor_Grid[1] = guiCreateGridList(0.0124,0.0361,0.4557,0.9367,true,GUIEditor_Tab[1]) 
    guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
    streamColumn = guiGridListAddColumn(GUIEditor_Grid[1],"URL",0.9) 
    GUIEditor_Label[1] = guiCreateLabel(0.4806,0.0572,0.2799,0.0693,"Add stream",true,GUIEditor_Tab[1]) 
    GUIEditor_Label[2] = guiCreateLabel(0.4774,0.1386,0.1711,0.0542,"URL:",true,GUIEditor_Tab[1]) 
    GUIEditor_Edit[1] = guiCreateEdit(0.5879,0.1295,0.3919,0.0693,"",true,GUIEditor_Tab[1]) 
    GUIEditor_Button[1] = guiCreateButton(0.591,0.2319,0.3872,0.0753,"Add stream",true,GUIEditor_Tab[1]) 
    GUIEditor_Label[3] = guiCreateLabel(0.4759,0.3584,0.1322,0.0542,"Remove",true,GUIEditor_Tab[1]) 
    GUIEditor_Button[2] = guiCreateButton(0.591,0.4277,0.3872,0.0753,"Remove stream",true,GUIEditor_Tab[1]) 
    GUIEditor_Tab[2] = guiCreateTab("Sounds",GUIEditor_TabPanel[1]) 
    GUIEditor_Grid[2] = guiCreateGridList(0.0124,0.0361,0.4557,0.9367,true,GUIEditor_Tab[2]) 
    guiGridListSetSelectionMode(GUIEditor_Grid[2],2) 
  
    soundColumn = guiGridListAddColumn(GUIEditor_Grid[2],"URL",0.9) 
    GUIEditor_Checkbox[1] = guiCreateCheckBox(0.4821,0.1386,0.3157,0.0633,"Radio mode",false,true,GUIEditor_Tab[2]) 
    GUIEditor_Label[4] = guiCreateLabel(0.4821,0.0693,0.1851,0.0542,"Settings",true,GUIEditor_Tab[2]) 
    GUIEditor_Checkbox[2] = guiCreateCheckBox(0.4821,0.2139,0.1882,0.0602,"Repeat sound",false,true,GUIEditor_Tab[2]) 
    GUIEditor_Label[5] = guiCreateLabel(0.4883,0.3072,0.1649,0.0512,"Add sound",true,GUIEditor_Tab[2]) 
    GUIEditor_Label[6] = guiCreateLabel(0.4883,0.3976,0.1477,0.0753,"URL:",true,GUIEditor_Tab[2]) 
    GUIEditor_Edit[2] = guiCreateEdit(0.591,0.3916,0.3919,0.0753,"",true,GUIEditor_Tab[2]) 
    GUIEditor_Button[3] = guiCreateButton(0.591,0.488,0.395,0.0723,"Add sound",true,GUIEditor_Tab[2]) 
    GUIEditor_Label[7] = guiCreateLabel(0.4899,0.6024,0.1337,0.0602,"Remove",true,GUIEditor_Tab[2]) 
    GUIEditor_Button[4] = guiCreateButton(0.591,0.6657,0.395,0.0723,"Remove sound",true,GUIEditor_Tab[2]) 
    guiSetVisible(GUIEditor_Window[1],false) 
    loadStreamAndSoundList() 
    --Add Stream 
    addEventHandler("onClientGUIClick",GUIEditor_Button[1], 
    function () 
        if guiGetText(GUIEditor_Edit[1]) ~= "" then 
            local row = guiGridListAddRow(GUIEditor_Grid[1]) 
            guiGridListSetItemText(GUIEditor_Grid[1],row,streamColumn,guiGetText(GUIEditor_Edit[1]),false,false) 
            guiSetText(GUIEditor_Edit[1],"") 
            updateStreamAndSoundList() 
        end 
    end) 
    --Add Sound 
    addEventHandler("onClientGUIClick",GUIEditor_Button[3], 
    function () 
        if guiGetText(GUIEditor_Edit[2]) ~= "" then 
            local row = guiGridListAddRow(GUIEditor_Grid[2]) 
            guiGridListSetItemText(GUIEditor_Grid[2],row,streamColumn,guiGetText(GUIEditor_Edit[2]),false,false) 
            guiSetText(GUIEditor_Edit[2],"") 
            updateStreamAndSoundList() 
        end 
    end) 
    --Remove stream 
    addEventHandler("onClientGUIClick",GUIEditor_Button[2], 
    function () 
        if guiGridListGetSelectedItem(GUIEditor_Grid[1]) ~= -1 then 
            local row, column = guiGridListGetSelectedItem(GUIEditor_Grid[1]) 
            guiGridListRemoveRow(GUIEditor_Grid[1],row) 
            updateStreamAndSoundList() 
        end 
    end) 
    --Remove sound 
    addEventHandler("onClientGUIClick",GUIEditor_Button[4], 
    function () 
        if guiGridListGetSelectedItem(GUIEditor_Grid[2]) ~= -1 then 
            local row, column = guiGridListGetSelectedItem(GUIEditor_Grid[2]) 
            guiGridListRemoveRow(GUIEditor_Grid[2],row) 
            updateStreamAndSoundList() 
        end 
    end) 
    addEventHandler("onClientGUIClick",getResourceRootElement(getThisResource()), 
    function () 
        if getElementType(source) == "gui-edit" then 
            guiSetInputEnabled(true) 
        else 
            guiSetInputEnabled(false) 
        end 
    end) 
    --Play Stream 
    addEventHandler("onClientGUIDoubleClick",GUIEditor_Grid[1], 
    function () 
        if guiGridListGetSelectedItem(GUIEditor_Grid[1]) ~= -1 then 
            local row, column = guiGridListGetSelectedItem(GUIEditor_Grid[1]) 
            startSound(guiGridListGetItemText(GUIEditor_Grid[1],row,column)) 
        end 
    end) 
    --Play Sound 
    addEventHandler("onClientGUIDoubleClick",GUIEditor_Grid[2], 
    function () 
        if guiGridListGetSelectedItem(GUIEditor_Grid[2]) ~= -1 then 
            local row, column = guiGridListGetSelectedItem(GUIEditor_Grid[2]) 
            startSound(guiGridListGetItemText(GUIEditor_Grid[2],row,column),row) 
        end 
    end) 
    addCommandHandler("radio", 
    function () 
        showCursor(not guiGetVisible(GUIEditor_Window[1])) 
        guiSetVisible(GUIEditor_Window[1],not guiGetVisible(GUIEditor_Window[1])) 
    end) 
end 
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loadGUI) 

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