toptional Posted December 8, 2012 Share Posted December 8, 2012 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
manve1 Posted December 8, 2012 Share Posted December 8, 2012 (edited) EDIT: Mind posting more information? like: Row name, Column Name? Edited December 8, 2012 by Guest Link to comment
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 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
manve1 Posted December 8, 2012 Share Posted December 8, 2012 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) Link to comment
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 Nope nothing, It dont spawn the vehicle no debug error Link to comment
Anderl Posted December 8, 2012 Share Posted December 8, 2012 Where is gridlist event? Where is the code which spawns the vehicles? Link to comment
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 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
manve1 Posted December 8, 2012 Share Posted December 8, 2012 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
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 Im sorry what did you just say??? How is it my problem? I dont get what you mean by that? And u said i should use getitemdata thing, ill try Link to comment
manve1 Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 What? No there is no typing error Link to comment
Anderl Posted December 8, 2012 Share Posted December 8, 2012 No one said it is a typing error. Show the WHOLE code. Link to comment
manve1 Posted December 8, 2012 Share Posted December 8, 2012 Well, 2 main reasons: 1. Typing mistake OR 2. Missing part of a script. Link to comment
toptional Posted December 8, 2012 Author Share Posted December 8, 2012 I dont like sharing all my code on the forum ill send it via PM k? Link to comment
Anderl Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment
toptional Posted December 9, 2012 Author Share Posted December 9, 2012 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? Link to comment
Castillo Posted December 9, 2012 Share Posted December 9, 2012 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
toptional Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) Thanks Castillo, EDIT - Problem fixed (mis-placed brackets) Edited December 10, 2012 by Guest Link to comment
AhmadQTR Posted December 10, 2012 Share Posted December 10, 2012 --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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now