Jump to content

guiGridListSetItemData Problem


toptional

Recommended Posts

I have a script which spawns vehicles and gets the vehicle ID from the name, You Double Click on the GridList that says "Hydra" and then it spawns a hydra.

How ever i want it a different name which is F22 Raptor so i tried adding this

guiGridListSetItemData(Grid,1,1,"Hydra") 
guiGridListSetItemText(Grid,1,1,"F22 Raptor",false,false) 

but it wont work, Clicking on it doesnt spawn the vehicle meaning its not getting the ID from the F22 Raptor Whats wrong with it?

Link to comment
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
     Window = guiCreateWindow(322,193,361,409,"Car Spawner",false) 
     guiSetVisible (Window, false) 
     Label = guiCreateLabel(102,115,117,123,"",false,Window) 
     Grid = guiCreateGridList(42,54,277,216,false,Window) 
     guiGridListAddColumn(Grid,"Planes",0.9) 
  
        for i = 1, 3 do 
            guiGridListAddRow(Grid) 
        end 
  
        guiGridListSetItemData(Grid,1,1,"Hydra") 
        guiGridListSetItemText(Grid,0,1,"Shamal",false,false) 
        guiGridListSetItemText(Grid,1,1,"F22 Raptor",false,false) 
        guiGridListSetItemText(Grid,2,1,"Rustler",false,false) 
        Button = guiCreateButton(40,307,296,80,"Close",false,Window) 
        addEventHandler ( 'onClientGUIClick', Button, onButtonClick, false ) 
        addEventHandler( "onClientGUIDoubleClick", Grid, doubleClicked, false ) 
    end 
) 
  

Link to comment
Where is gridlist event? Where is the code which spawns the vehicles?

Its in the part of the script, Dude the thing is it works for the other planes so there is no point of me giving the resource that spawns the planes its clearly a problem with the guiGridListSetItemData

Link to comment
Where is gridlist event? Where is the code which spawns the vehicles?

Its in the part of the script, Dude the thing is it works for the other planes so there is no point of me giving the resource that spawns the planes its clearly a problem with the guiGridListSetItemData

Not always its function problem (( nearly never )), but sometimes it might be ur problem.

After all u need to use this too

guiGridListGetItemData 

Link to comment

You can also make a table which will contain the real names, like this:

realNames = 
    { 
        [ "Ford GT" ] = "Bullet" 
    } 

Then when you are about to create the vehicle, you do this:

vehicleModel = getVehicleModelFromName ( realNames [ nameReceived ] ) 

Link to comment
--client 
function doubleClicked ( ) 
    local row, col = guiGridListGetSelectedItem ( source ) 
    if ( row and col and row ~= -2 and col ~= -2 ) then 
        local PlaneNameSF = guiGridListGetItemText ( source, row, 2 ) 
        -- make this the data some how local vehicleName = guiGridListGetItemText ( 
            triggerServerEvent ( "spawnSFPlane", getLocalPlayer() ) 
        guiSetVisible ( Window, false) 
        showCursor ( false ) 
    end 
end 
addEventHandler( "onClientGUIDoubleClick", Grid, doubleClicked, false ) 

Maybe like this i didn't test it

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