Jump to content

guiGridListSetItemData Problem


toptional

Recommended Posts

Posted

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?

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

Posted

try:

change:

guiGridListAddColumn(Grid,"Planes",0.9) 

to:

local columnPlanes = guiGridListAddColumn(Grid,"Planes",0.9) 

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

Posted
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

Posted
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 

Posted

You should already know that scripts for if you write them out correctly, your problem might be that you written it out nearly correctly and made like 1mistake.

Posted
The problem is that there's no such "F-22 Raptor" plane. You can "by-pass" that by setting item data to the plane's model and its text to the real name of it and then sending the item data to the server event instead of using getVehicleModelFromName.

How would i send the item data to the server event?

Posted

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 ] ) 

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

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