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) 

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted

Where is gridlist event? Where is the code which spawns the vehicles?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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 

Looking for tutorials or information? check out: www.simpleask.co.uk

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.

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted

No one said it is a typing error.

Show the WHOLE code.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Whatever.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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

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

ahmadsig1.png

Nobody is perfect , I'm nobody.

22771qw7.jpg

Skype : ahmad.nasser37

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