Xeno Posted July 25, 2011 Share Posted July 25, 2011 I'm scripting a a GUIGridList at the moment, and I'v become stuck. This is a bit confusing but I dont know any simply way too say it - I need it like, you select what you want on the table, and then you click the button once your item is selected and it spawns it for you. vehList = guiCreateGridList ( 0.05, 0.10, 0.90, 0.77, true, window ) vehCol = guiGridListAddColumn ( vehList, "Vehicle", 0.60 ) bullet = guiGridListAddRow ( vehList ) guiGridListSetItemText ( vehList, bullet, vehCol, "Bullet ", false, false ) takebutton = guiCreateButton(0.25,0.90,0.20,0.10,"Buy Car",true,window) Sorry if this is confusing. I'd really appreciated it if you gave me so help Link to comment
Jaysds1 Posted July 26, 2011 Share Posted July 26, 2011 so when someone clicks on a vehicle then clicks on the button and it spawns the vehicle and closes the window? I suggest using the onClientGUIDoubleClick . Link to comment
Castillo Posted July 26, 2011 Share Posted July 26, 2011 -- client side vehList = guiCreateGridList ( 0.05, 0.10, 0.90, 0.77, true, window ) vehCol = guiGridListAddColumn ( vehList, "Vehicle", 0.60 ) bullet = guiGridListAddRow ( vehList ) guiGridListSetItemText ( vehList, bullet, vehCol, "Bullet", false, false ) takebutton = guiCreateButton(0.25,0.90,0.20,0.10,"Buy Car",true,window) function spawnTheCar() local row,col = guiGridListGetSelectedItem(vehList) if row and col and row ~= -1 and col ~= -1 then local vehicleName = guiGridListGetItemText(vehList, row, col) triggerServerEvent("vehicle_spawn",getLocalPlayer(),getVehicleModelFromName(vehicleName)) end end addEventHandler("onClientGUIClick",takeButton,spawnTheCar,false) -- server side addEvent("vehicle_spawn",true) addEventHandler("vehicle_spawn",root, function (model) local x, y, z = getElementPosition(source) local theVehicle = createVehicle(tonumber(model), x, y, z) end) Try with that. Link to comment
Jaysds1 Posted July 26, 2011 Share Posted July 26, 2011 Hey, I was looking for the gui stuff in client events on Wiki. Link to comment
Xeno Posted July 26, 2011 Author Share Posted July 26, 2011 -- client side vehList = guiCreateGridList ( 0.05, 0.10, 0.90, 0.77, true, window ) vehCol = guiGridListAddColumn ( vehList, "Vehicle", 0.60 ) bullet = guiGridListAddRow ( vehList ) guiGridListSetItemText ( vehList, bullet, vehCol, "Bullet", false, false ) takebutton = guiCreateButton(0.25,0.90,0.20,0.10,"Buy Car",true,window) function spawnTheCar() local row,col = guiGridListGetSelectedItem(vehList) if row and col and row ~= -1 and col ~= -1 then local vehicleName = guiGridListGetItemText(vehList, row, col) triggerServerEvent("vehicle_spawn",getLocalPlayer(),getVehicleModelFromName(vehicleName)) end end addEventHandler("onClientGUIClick",takeButton,spawnTheCar,false) -- server side addEvent("vehicle_spawn",true) addEventHandler("vehicle_spawn",root, function (model) local x, y, z = getElementPosition(source) local theVehicle = createVehicle(tonumber(model), x, y, z) end) Try with that. addEventHandler("onClientGUIClick",takeButton,spawnTheCar,false) I get a bad argument at the onClientGUIClick. Sorry, I didn't mention , the GUI is in a function, does that matter? Link to comment
Castillo Posted July 26, 2011 Share Posted July 26, 2011 Yes, it does, do this, move the event handler down the button, into the function. Link to comment
Jaysds1 Posted July 26, 2011 Share Posted July 26, 2011 I'm not sure, but it might work: addEventHandler("onClientGUIClick",takeButton,spawnTheCar,false) function spawnTheCar() local row,col = guiGridListGetSelectedItem(vehList) if row and col and row ~= -1 and col ~= -1 then local vehicleName = guiGridListGetItemText(vehList, row, col) triggerServerEvent("vehicle_spawn",getLocalPlayer(),getVehicleModelFromName(vehicleName)) end end Link to comment
Castillo Posted July 26, 2011 Share Posted July 26, 2011 Jaysd1, if you want to increase your post count, please don't do it here, you are confusing him, that's the same as I'd but moved the event handler before the function, which won't work. Link to comment
Xeno Posted July 26, 2011 Author Share Posted July 26, 2011 Jaysd1, if you want to increase your post count, please don't do it here, you are confusing him, that's the same as I'd but moved the event handler before the function, which won't work. Umm... I get no errors and the GUI works perfectly, everything looks normal. But the car isn't spawned when the Bullet Row is selected and the button is press :l Shall I post my hole client side script? EDIT: Never mind! I did it! There was a problem with the createVehicle so I made it like this : theVehicle = createVehicle ( 432, -706.60431, 965.87689, 12.39362 ) And it worked! Thank you very much Castillo :3 And thanks for putting input in Jay lawl. <3 EDIT2: Fixed 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