Jump to content

Big noob problem ._.


drk

Recommended Posts

Hey, why I get this error:

WARNING: race_userpanel/music_c.lua:83: Bad argument @ 'guiGetVisible' [ expected gui-element at argument 1, got nil ] 
WARNING: race_userpanel/music_c.lua:85: Bad argument @ 'guiGetVisible' [ expected gui-element at argument 1, got nil ] 
WARNING: race_userpanel/music_c.lua:86: Bad argument @ 'guiSetVisible' [ expected gui-element at argument 1, got nil ] 
  

the code is

function showWindow() 
    if ( guiGetVisible ( music ) == true ) then 
        guiSetVisible ( music, false ) 
    elseif ( guiGetVisible ( music ) == false ) then 
        guiSetVisible ( music, true ) 
    end 
end 
bindKey ( "F3", "down", showWindow ) 

music variable is the gui:

function musicPlayer() 
    music = guiCreateWindow(0.2988,0.2317,0.4238,0.5617,"ppS Music Player",true) 
    music_play = guiCreateLabel(0.3864,0.1098,0.236,0.0445,"Now playing:",true,music) 
    guiSetAlpha(music_play,1) 
    guiLabelSetColor(music_play,255,20,147,255) 
    guiLabelSetHorizontalAlign(music_play,"center",false) 
    guiSetFont(music_play,"default-bold-small") 
    music_name = guiCreateLabel(0.1268,0.1869,0.7611,0.0623,"",true,music) 
    guiLabelSetHorizontalAlign(music_name,"center",false) 
    music_grid = guiCreateGridList(0.0649,0.2997,0.8732,0.6261,true,music) 
    guiGridListSetSelectionMode(music_grid,0) 
  
    local music_grid_column = guiGridListAddColumn(music_grid,"Playlist",0.2) 
  
    guiSetVisible ( music, false ) 
  
        if (music_grid_column) then 
            for name,dir in pairs(musics) do 
              local newRow = guiGridListAddRow ( music_grid ) 
              guiGridListSetItemText( music_grid, newRow, music_grid_column, #musics, false, false ) 
        end 
    end 
end 
  

Why it gives me this error?

Link to comment
function showWindow() 
if (guiGetVisible (music)) then 
    guiSetVisible (music, false) 
    showCursor (false) 
else 
    guiSetVisible(music, true) 
    showCursor (true) 
    end 
end 
bindKey ( "F3", "down", showWindow ) 

Hope it works

OFF: 100 posts :) , PFF i forgot to put [lua] xD

Edited by Guest
Link to comment

I usually do not use a function for this type of script:

Client:

    music = guiCreateWindow(0.2988,0.2317,0.4238,0.5617,"ppS Music Player",true) 
    guiSetVisible ( music, false ) 
    music_play = guiCreateLabel(0.3864,0.1098,0.236,0.0445,"Now playing:",true,music) 
    guiSetAlpha(music_play,1) 
    guiLabelSetColor(music_play,255,20,147,255) 
    guiLabelSetHorizontalAlign(music_play,"center",false) 
    guiSetFont(music_play,"default-bold-small") 
    music_name = guiCreateLabel(0.1268,0.1869,0.7611,0.0623,"",true,music) 
    guiLabelSetHorizontalAlign(music_name,"center",false) 
    music_grid = guiCreateGridList(0.0649,0.2997,0.8732,0.6261,true,music) 
    guiGridListSetSelectionMode(music_grid,0) 
  
    local music_grid_column = guiGridListAddColumn(music_grid,"Playlist",0.2) 
  
    guiSetVisible ( music, false ) 
  
        if (music_grid_column) then 
            for name,dir in pairs(musics) do 
              local newRow = guiGridListAddRow ( music_grid ) 
              guiGridListSetItemText( music_grid, newRow, music_grid_column, #musics, false, false ) 
        end 
    end 

and your bindkey:

function showWindow() 
    if ( guiGetVisible ( music ) == true ) then 
        guiSetVisible ( music, false ) 
        showCursor(false) 
    elseif ( guiGetVisible ( music ) == false ) then 
        guiSetVisible ( music, true ) 
        showCursor(true) 
    end 
end 
bindKey ( "F3", "down", showWindow ) 

Link to comment
  • MTA Team

Try my script, it seems more systematic.

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function() 
        music = guiCreateWindow(0.2988, 0.2317, 0.4238, 0.5617, "ppS Music Player", true) 
        guiSetVisible(music, false) 
         
        music_play = guiCreateLabel(0.3864, 0.1098, 0.236, 0.0445, "Now playing:", true, music) 
        guiLabelSetHorizontalAlign(music_play, "center", false) 
        guiLabelSetColor(music_play, 255, 20, 147, 255) 
        guiSetFont(music_play,"default-bold-small") 
        guiSetAlpha(music_play, 1) 
         
        music_name = guiCreateLabel(0.1268, 0.1869, 0.7611, 0.0623, "", true, music) 
        guiLabelSetHorizontalAlign(music_name, "center", false) 
         
        music_grid = guiCreateGridList(0.0649, 0.2997, 0.8732, 0.6261, true, music) 
        guiGridListSetSelectionMode(music_grid, 0) 
         
        music_grid_column = guiGridListAddColumn(music_grid, "Playlist", 0.2) 
      
        if (music_grid_column) then 
            for name, dir in ipairs(musics) do 
                local newRow = guiGridListAddRow(music_grid) 
                guiGridListSetItemText(music_grid, newRow, music_grid_column, #musics, false, false) 
            end 
        end 
    end 
) 
  
function showWindow() 
    if (guiGetVisible(music) == true) then 
        guiSetVisible(music, false) 
        showCursor(false) 
    else 
        guiSetVisible(music, true) 
        showCursor(true) 
    end 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function() 
        bindKey("F3", "down", showWindow) 
    end 
) 

Edited by Guest
Link to comment

i doubt by adding 'showCursor' will fix his existing problem.

the error msg from debug isnt much use since uve only posted some of ur code, which at a glance looks ok.

make sure u define 'music' when ur resource starts. (run function musicPlayer() when u load the script)

failing that, u can add a check for the variable 'music' although that wont fix ur problem, only stop the error. eg:

function showWindow() 
  if music then 
    if ( guiGetVisible ( music ) == true ) then 
        guiSetVisible ( music, false ) 
    elseif ( guiGetVisible ( music ) == false ) then 
        guiSetVisible ( music, true ) 
    end 
  end 
end 
bindKey ( "F3", "down", showWindow ) 

Link to comment
Scooby, i didnt just do that, pay more attention. I made it so it would work. The variable in my mind wasnt activated. So i fixed it. I removed the function!

since u didnt do that then i guess the msg wasnt for u.... the reply was to GanJaRuleZ first post which hes now edited.

pay more attention.....

Link to comment

Other question, why the text don't appear on the row? ._.

function showMusic () 
    if (music_grid_column) then 
          local row1 = guiGridListAddRow ( music_grid ) 
          guiGridListSetItemText( music_grid, row1, music_grid_column, #musics, false, false ) 
    end 
end 

Music table:

local musics = 
    { 
        [ 'David Guetta - Where Dem Girls At' ] = { 'gfx/music/dg-wdga.mp3' }, 
        [ 'Coldplay - Paradise' ] = { 'gfx/music/cp-pd.mp3' }, 
        [ 'Coldplay - Viva la Vida' ] = { 'gfx/music/cp-vlv.mp3' }, 
        [ 'Ana Malhoa - Danza Kuduro' ] = { 'gfx/music/am-dk.mp3' }, 
        [ 'No Name - Jamming' ] = { 'gfx/music/jm.mp3' }, 
        [ 'Klaas - Make you Feel' ] = { 'gfx/music/ks-myf.mp3' }, 
        [ 'No Name - Vitality' ] = { 'gfx/music/vy.mp3' }, 
        [ 'Basshunter - All I ever wanted' ] = { 'gfx/music/bh-aiew.mp3' }, 
        [ 'Whiz Khalifa - Black and Yellow ( Ft. Snoop Dogg, Juicy J & T-Pain )' ] = { 'gfx/music/wk-bay.mp3' }, 
        [ 'Skrillex - My name is Skrillex ( Remix )' ] = { 'gfx/music/sx-mnis.mp3' }, 
        [ 'Italobrothers - Stamp on the Ground' ] = { 'gfx/music/ib-sotg.mp3' }, 
        [ 'Madcon - Freaky like Me' ] = { 'gfx/music/mc-flm.mp3' }, 
        [ 'Cut the Music - Greatest Deejay' ] = { 'gfx/music/ctm-gd.mp3' }, 
        [ 'No Name - Time`s Vortex' ] = { 'gfx/music/tv.mp3' }, 
        [ 'Manian - Welcome to the Club' ] = { 'gfx/music/wttc.mp3' }, 
        [ 'Bon Jovi - It`s my Life' ] = { 'gfx/music/iml.mp3' }, 
        [ 'Example - Changed the Way you Kissed Me' ] = { 'gfx/music/ctwykm.mp3' }, 
        [ 'Example - Kickstart ( Bar 9 Remix )' ] = { 'gfx/music/e-ksb9rx.mp3' } 
    } 

It don't work with tables? Then, why when I change #musics by 'Music Name 1' it don't appear too? =s

Link to comment
  
  
local musics = 
    { 
        [ 'David Guetta - Where Dem Girls At' ] = { 'gfx/music/dg-wdga.mp3' }, 
        [ 'Coldplay - Paradise' ] = { 'gfx/music/cp-pd.mp3' }, 
        [ 'Coldplay - Viva la Vida' ] = { 'gfx/music/cp-vlv.mp3' }, 
        [ 'Ana Malhoa - Danza Kuduro' ] = { 'gfx/music/am-dk.mp3' }, 
        [ 'No Name - Jamming' ] = { 'gfx/music/jm.mp3' }, 
        [ 'Klaas - Make you Feel' ] = { 'gfx/music/ks-myf.mp3' }, 
        [ 'No Name - Vitality' ] = { 'gfx/music/vy.mp3' }, 
        [ 'Basshunter - All I ever wanted' ] = { 'gfx/music/bh-aiew.mp3' }, 
        [ 'Whiz Khalifa - Black and Yellow ( Ft. Snoop Dogg, Juicy J & T-Pain )' ] = { 'gfx/music/wk-bay.mp3' }, 
        [ 'Skrillex - My name is Skrillex ( Remix )' ] = { 'gfx/music/sx-mnis.mp3' }, 
        [ 'Italobrothers - Stamp on the Ground' ] = { 'gfx/music/ib-sotg.mp3' }, 
        [ 'Madcon - Freaky like Me' ] = { 'gfx/music/mc-flm.mp3' }, 
        [ 'Cut the Music - Greatest Deejay' ] = { 'gfx/music/ctm-gd.mp3' }, 
        [ 'No Name - Time`s Vortex' ] = { 'gfx/music/tv.mp3' }, 
        [ 'Manian - Welcome to the Club' ] = { 'gfx/music/wttc.mp3' }, 
        [ 'Bon Jovi - It`s my Life' ] = { 'gfx/music/iml.mp3' }, 
        [ 'Example - Changed the Way you Kissed Me' ] = { 'gfx/music/ctwykm.mp3' }, 
        [ 'Example - Kickstart ( Bar 9 Remix )' ] = { 'gfx/music/e-ksb9rx.mp3' } 
    } 
  
local theMusicList = unpack(musics) 
function showMusic () 
    if (music_grid_column) then 
          local row1 = guiGridListAddRow ( music_grid ) 
          guiGridListSetItemText( music_grid, row1, music_grid_column, theMusicList, false, false ) 
    end 
end 
  

-- Idk if it will work

Link to comment
local musics = { 
    [ 'David Guetta - Where Dem Girls At' ] = 'gfx/music/dg-wdga.mp3', 
    [ 'Coldplay - Paradise' ] = 'gfx/music/cp-pd.mp3', 
    [ 'Coldplay - Viva la Vida' ] = 'gfx/music/cp-vlv.mp3', 
    [ 'Ana Malhoa - Danza Kuduro' ] = 'gfx/music/am-dk.mp3', 
    [ 'No Name - Jamming' ] = 'gfx/music/jm.mp3', 
    [ 'Klaas - Make you Feel' ] = 'gfx/music/ks-myf.mp3', 
    [ 'No Name - Vitality' ] = 'gfx/music/vy.mp3', 
    [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', 
    [ 'Whiz Khalifa - Black and Yellow ( Ft. Snoop Dogg, Juicy J & T-Pain )' ] = 'gfx/music/wk-bay.mp3', 
    [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', 
    [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', 
    [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', 
    [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', 
    [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', 
    [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', 
    [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', 
    [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', 
    [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3' 
} 
  
function showMusic () 
    if (music_grid_column) then 
        for name, url in pairs(musics) do 
            local row1 = guiGridListAddRow ( music_grid ) 
            guiGridListSetItemText( music_grid, row1, music_grid_column, tostring(name), false, false ) 
        end 
    end 
end 

Link to comment

Dont appear any error msg, only don't appear the items in the gridlist :S

The complete code:

local musics = { 
    [ 'David Guetta - Where Dem Girls At' ] = 'gfx/music/dg-wdga.mp3', 
    [ 'Coldplay - Paradise' ] = 'gfx/music/cp-pd.mp3', 
    [ 'Coldplay - Viva la Vida' ] = 'gfx/music/cp-vlv.mp3', 
    [ 'Ana Malhoa - Danza Kuduro' ] = 'gfx/music/am-dk.mp3', 
    [ 'No Name - Jamming' ] = 'gfx/music/jm.mp3', 
    [ 'Klaas - Make you Feel' ] = 'gfx/music/ks-myf.mp3', 
    [ 'No Name - Vitality' ] = 'gfx/music/vy.mp3', 
    [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', 
    [ 'Whiz Khalifa - Black and Yellow ( Ft. Snoop Dogg, Juicy J & T-Pain )' ] = 'gfx/music/wk-bay.mp3', 
    [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', 
    [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', 
    [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', 
    [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', 
    [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', 
    [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', 
    [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', 
    [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', 
    [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3' 
} 
  
--gui 
  
    music = guiCreateWindow(0.2988,0.2317,0.4238,0.5617,"ppS Music Player",true) 
    music_play = guiCreateLabel(0.3864,0.1098,0.236,0.0445,"Now playing:",true,music) 
    guiSetAlpha(music_play,1) 
    guiLabelSetColor(music_play,255,20,147,255) 
    guiLabelSetHorizontalAlign(music_play,"center",false) 
    guiSetFont(music_play,"default-bold-small") 
    music_name = guiCreateLabel(0.1268,0.1869,0.7611,0.0623,"",true,music) 
    guiLabelSetHorizontalAlign(music_name,"center",false) 
    music_grid = guiCreateGridList(0.0649,0.2997,0.8732,0.6261,true,music) 
    guiGridListSetSelectionMode(music_grid,0) 
  
    local music_grid_column = guiGridListAddColumn(music_grid,"Playlist",0.2) 
  
    guiSetVisible ( music, false ) 
  
function showMusic () 
    if (music_grid_column) then 
        for name, url in pairs(musics) do 
            local row1 = guiGridListAddRow ( music_grid ) 
            guiGridListSetItemText( music_grid, row1, music_grid_column, tostring(name), false, false ) 
        end 
    end 
end 
  
function showWindow() 
    if (guiGetVisible (music)) then 
      guiSetVisible (music, false) 
      showCursor (false) 
    else 
      guiSetVisible(music, true) 
      showCursor (true) 
  end 
end 
bindKey ( "F3", "down", showWindow ) 

Link to comment

Maybe because you never call "showMusic" function?

local musics = { 
    [ 'David Guetta - Where Dem Girls At' ] = 'gfx/music/dg-wdga.mp3', 
    [ 'Coldplay - Paradise' ] = 'gfx/music/cp-pd.mp3', 
    [ 'Coldplay - Viva la Vida' ] = 'gfx/music/cp-vlv.mp3', 
    [ 'Ana Malhoa - Danza Kuduro' ] = 'gfx/music/am-dk.mp3', 
    [ 'No Name - Jamming' ] = 'gfx/music/jm.mp3', 
    [ 'Klaas - Make you Feel' ] = 'gfx/music/ks-myf.mp3', 
    [ 'No Name - Vitality' ] = 'gfx/music/vy.mp3', 
    [ 'Basshunter - All I ever wanted' ] = 'gfx/music/bh-aiew.mp3', 
    [ 'Whiz Khalifa - Black and Yellow ( Ft. Snoop Dogg, Juicy J & T-Pain )' ] = 'gfx/music/wk-bay.mp3', 
    [ 'Skrillex - My name is Skrillex ( Remix )' ] = 'gfx/music/sx-mnis.mp3', 
    [ 'Italobrothers - Stamp on the Ground' ] = 'gfx/music/ib-sotg.mp3', 
    [ 'Madcon - Freaky like Me' ] = 'gfx/music/mc-flm.mp3', 
    [ 'Cut the Music - Greatest Deejay' ] = 'gfx/music/ctm-gd.mp3', 
    [ 'No Name - Time`s Vortex' ] = 'gfx/music/tv.mp3', 
    [ 'Manian - Welcome to the Club' ] = 'gfx/music/wttc.mp3', 
    [ 'Bon Jovi - It`s my Life' ] = 'gfx/music/iml.mp3', 
    [ 'Example - Changed the Way you Kissed Me' ] = 'gfx/music/ctwykm.mp3', 
    [ 'Example - Kickstart ( Bar 9 Remix )' ] = 'gfx/music/e-ksb9rx.mp3' 
} 
  
--gui 
  
music = guiCreateWindow(0.2988,0.2317,0.4238,0.5617,"ppS Music Player",true) 
music_play = guiCreateLabel(0.3864,0.1098,0.236,0.0445,"Now playing:",true,music) 
guiSetAlpha(music_play,1) 
guiLabelSetColor(music_play,255,20,147,255) 
guiLabelSetHorizontalAlign(music_play,"center",false) 
guiSetFont(music_play,"default-bold-small") 
music_name = guiCreateLabel(0.1268,0.1869,0.7611,0.0623,"",true,music) 
guiLabelSetHorizontalAlign(music_name,"center",false) 
music_grid = guiCreateGridList(0.0649,0.2997,0.8732,0.6261,true,music) 
guiGridListSetSelectionMode(music_grid,0) 
  
music_grid_column = guiGridListAddColumn(music_grid,"Playlist",0.2) 
if (music_grid_column) then 
    for name, url in pairs(musics) do 
        local row = guiGridListAddRow ( music_grid ) 
        guiGridListSetItemText( music_grid, row, music_grid_column, tostring(name), false, false ) 
    end 
end  
guiSetVisible ( music, false ) 
     
function showWindow() 
    if (guiGetVisible (music)) then 
      guiSetVisible (music, false) 
      showCursor (false) 
    else 
      guiSetVisible(music, true) 
      showCursor (true) 
  end 
end 
bindKey ( "F3", "down", showWindow ) 

Link to comment

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