Jump to content

Big noob problem ._.


drk

Recommended Posts

Posted

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?

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted (edited)
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

My Projects!

No one.

Posted

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 ) 

Posted (edited)

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

If I helped you, please click the like button on the right ;) Thanks!

Posted

I still don't like that you're making it like that, of course we all have our own systems, however I prefer my one, it uses everything it should use. I am not leaving anything alone there.

If I helped you, please click the like button on the right ;) Thanks!

Posted

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 ) 

ScoobySig.gif

[UVA]Scooby

Founder Of UVA - Ultimate Vice Assassins

http://www.uvaclan.com/

Posted

csmit195 way worked... thanks for helping too myonlake and scooby, anyone lock this noob topic xD

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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

ScoobySig.gif

[UVA]Scooby

Founder Of UVA - Ultimate Vice Assassins

http://www.uvaclan.com/

Posted

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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted
  
  
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

My Projects!

No one.

Posted
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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Scooby dude, the topic is over, stop replying lol.

seems u were wrong again.......

If its still not working apple, explain whats not working or post the error msgs.

ScoobySig.gif

[UVA]Scooby

Founder Of UVA - Ultimate Vice Assassins

http://www.uvaclan.com/

Posted

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 ) 

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome ;).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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