Enkanet Posted January 13, 2015 Share Posted January 13, 2015 Hello everyone. I have a gridList. I need to createVehicle and I should create the vehicle on serverside because if I do it on clientside I will not be able to enter to the vehicle. And I have a grid and it has a column called "ID" I need to use that column to create the vehicle. the vehicle ID will be the ID stated in the grid. I am waiting for your helps. Thanks. Link to comment
Mizudori Posted January 13, 2015 Share Posted January 13, 2015 (edited) You want all cars from the game to be in gridList?? local car_c = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local cars = getElementsByType("vehicle") local column = guiGridListAddColumn( car_c, "Cars_id", 0.85 ) for numb, car in iparis(cars) do local id = getElementModel(car) local row = guiGridListAddRow ( car_c ) guiGridListSetItemText ( car_c, row, column, id, false, true ) end Then you just use form from wiki example of gridList to get data from car_id table. You create server event and trigger it when ID is choosen from gridlist + button clicked Edited January 13, 2015 by Guest Link to comment
Mega9 Posted January 13, 2015 Share Posted January 13, 2015 guiGridListGetSelectedItem guiGridListGetItemText triggerServerEvent --Server: addEvent addEventHandler createVehicle Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 guiGridListGetSelectedItem guiGridListGetItemText triggerServerEvent --Server: addEvent addEventHandler createVehicle I have already been using all of them, pff. In my opinion, I am using them wrong. I've created a grid list on client side than a marker on server side. When source hits to the marker it triggers the client event. Right now, I can create a vehicle but if I enter a vehicle ID to it. Example, local testCar = createVehicle(411, -1971.90417, 291.92630, 34.69014,0,0,120) example this one. I don't want to write 411 as vehicle ID. I want grid to write vehicle ID to there from the following column: VehiclesGrid = guiCreateGridList(10, 30, 589, 372, false, VehiclesWindow) Thanks. Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) Sorry, google chrome sent my post twice Edited January 13, 2015 by Guest Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 Post your code On client for the test button side: elseif source == testBtn then triggerServerEvent("TestMyVeh", root) end and Server Side, TestMyVeh function: function TestVehicle(testCar) local testCar = createVehicle(411, -1971.90417, 291.92630, 34.69014,0,0,120) local fucker = getRandomPlayer() if testCar then setElementDimension(testCar, 5) setElementDimension(fucker, 5) warpPedIntoVehicle(fucker, testCar,0) end end addEvent("TestMyVeh", true) addEventHandler("TestMyVeh", getRootElement(), TestVehicle) And also, I don't want to get a random player to warp into vehicle. How can I warp thePlayer into the vehicle? I tried: thePlayer, player, source, localPlayer(client side but I tried ) etc. If you tell that too I'd be very appreciated. Now this function spawns a vehicle with the ID of 411. an infernus. how can I get the id from the gridlist from clientside? Link to comment
-.Paradox.- Posted January 13, 2015 Share Posted January 13, 2015 That's not the full code, at least post gridlist part Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 That's not the full code, at least post gridlist part It's really much, can I learn your skype? Link to comment
-.Paradox.- Posted January 13, 2015 Share Posted January 13, 2015 Oh jesus, here is an introduction: Client: local car_c = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local cars = getElementsByType("vehicle") local column = guiGridListAddColumn( car_c, "Cars_id", 0.85 ) local tstBtn = --Button Here for numb, car in ipairs(cars) do local id = getElementModel(car) local row = guiGridListAddRow ( car_c ) guiGridListSetItemText ( car_c, row, column, id, false, true ) end addEventHandler("onClientGUIClick", guiRoot, function() if source == tstBtn then local row = guiGridListGetSelectedItem( car_c) if row then local ID = guiGridListGetItemText( car_c, row, 1) triggerServerEvent("onVehiclePurchased", localPlayer, ID) end end end) Server addEvent("onVehiclePurchased", true) addEventHandler("onVehiclePurchased", root, function(ID) if ID then local x, y, z = getElementPosition(source) local vehicle = createVehicle (ID, x, y, z, 0, 0) warpPedIntoVehicle(source, vehicle) end end) And i don't give my skype to anyone Link to comment
TheRock254 Posted January 13, 2015 Share Posted January 13, 2015 I want to turn around the 0,0,0 point with setCameraMatrix. Please help Link to comment
-.Paradox.- Posted January 13, 2015 Share Posted January 13, 2015 triggerServerEvent addEvent addEventHandler setCameraMatrix interpolateBetween "onClientPreRender" Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 I want to turn around the 0,0,0 point with setCameraMatrix. Please help Why don't you make another thread instead of asking here? Link to comment
-.Paradox.- Posted January 13, 2015 Share Posted January 13, 2015 Why don't you make another thread instead of asking here? You're rude. Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 Why don't you make another thread instead of asking here? You're rude. And he's a spammer who has a thread but he floods another threads because he's impatient. Sorry for this but, TheRock254 Can you please go to your thread? Link to comment
EL-JoKeR Posted January 13, 2015 Share Posted January 13, 2015 Clinet GUIEditor = { gridlist = {}, window = {}, button = {} } cars = { {554}, {421}, {586}, --{carID}, } local l, w = guiGetScreenSize() GUIEditor.window[1] = guiCreateWindow((l - 250) / 2, (w - 300) / 2, 215, 348, "Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1],false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.gridlist[1] = guiCreateGridList(9, 10, 197, 280, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "#", 0.2) guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.7) GUIEditor.button[1] = guiCreateButton(9, 301, 89, 37, "Select", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") GUIEditor.button[2] = guiCreateButton(118, 301, 88, 37, "Exit!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, i.."-", false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, carName, false, true) end addEvent ("openMean", true) function openMean () if (getLocalPlayer() == source) then guiSetVisible(GUIEditor.window[1],true) showCursor(true) end end addEventHandler ("openMean", getRootElement(), openMean) addEvent ("closeOpenMean", true) function closeOpenMean () if (getLocalPlayer() == source) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("closeOpenMean", getRootElement(), closeOpenMean) addEventHandler ("onClientGUIClick", GUIEditor.button[2], function (button, state, absoluteX, absoluteYe) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end) function trigger () if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then local car = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 2) if car == "" or car == nil then outputChatBox( "* Please Selected Car From List",255,0,0,true ) return end triggerServerEvent ("getCar", getLocalPlayer(), car) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor.button[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) end) addEventHandler ("onClientGUIDoubleClick", GUIEditor.gridlist[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) end) Server markers = { {x , y , z -1}, } for i,v in ipairs (markers) do marker = createMarker(v[1], v[2], v[3], "cylinder", get("markerSize"), get("markerColorR"), get("markerColorG"), get("markerColorB"), get("markerAlpha")) end veh = {} addEvent ("getCar", true) addEventHandler ("getCar", getRootElement(), function(car) if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local carID = getVehicleModelFromName (car) local x,y,z = getElementPosition(source) local carName = getVehicleNameFromModel (carID) veh[source] = createVehicle(carID, x,y,z) setVehicleColor(veh[source], 255, 255, 255) warpPedIntoVehicle(source, veh[source]) end ) addEventHandler ( "onPlayerQuit", getRootElement(), function () if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end end) function markerHit (hitPlayer, matchingDimension) if isPedInVehicle (hitPlayer) then return end if getElementType(hitPlayer) == "player" then triggerClientEvent ("openMean", hitPlayer) end end addEventHandler ("onMarkerHit", resourceRoot, markerHit) function markerLeave (hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then triggerClientEvent ("closeOpenMean", hitPlayer) end end addEventHandler ("onMarkerLeave", resourceRoot, markerLeave) Meta Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 Clinet GUIEditor = { gridlist = {}, window = {}, button = {} } cars = { {554}, {421}, {586}, --{carID}, } local l, w = guiGetScreenSize() GUIEditor.window[1] = guiCreateWindow((l - 250) / 2, (w - 300) / 2, 215, 348, "Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1],false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.gridlist[1] = guiCreateGridList(9, 10, 197, 280, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "#", 0.2) guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.7) GUIEditor.button[1] = guiCreateButton(9, 301, 89, 37, "Select", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") GUIEditor.button[2] = guiCreateButton(118, 301, 88, 37, "Exit!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, i.."-", false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, carName, false, true) end addEvent ("openMean", true) function openMean () if (getLocalPlayer() == source) then guiSetVisible(GUIEditor.window[1],true) showCursor(true) end end addEventHandler ("openMean", getRootElement(), openMean) addEvent ("closeOpenMean", true) function closeOpenMean () if (getLocalPlayer() == source) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("closeOpenMean", getRootElement(), closeOpenMean) addEventHandler ("onClientGUIClick", GUIEditor.button[2], function (button, state, absoluteX, absoluteYe) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end) function trigger () if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then local car = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 2) if car == "" or car == nil then outputChatBox( "* Please Selected Car From List",255,0,0,true ) return end triggerServerEvent ("getCar", getLocalPlayer(), car) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor.button[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) end) addEventHandler ("onClientGUIDoubleClick", GUIEditor.gridlist[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) end) Server markers = { {x , y , z -1}, } for i,v in ipairs (markers) do marker = createMarker(v[1], v[2], v[3], "cylinder", get("markerSize"), get("markerColorR"), get("markerColorG"), get("markerColorB"), get("markerAlpha")) end veh = {} addEvent ("getCar", true) addEventHandler ("getCar", getRootElement(), function(car) if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local carID = getVehicleModelFromName (car) local x,y,z = getElementPosition(source) local carName = getVehicleNameFromModel (carID) veh[source] = createVehicle(carID, x,y,z) setVehicleColor(veh[source], 255, 255, 255) warpPedIntoVehicle(source, veh[source]) end ) addEventHandler ( "onPlayerQuit", getRootElement(), function () if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end end) function markerHit (hitPlayer, matchingDimension) if isPedInVehicle (hitPlayer) then return end if getElementType(hitPlayer) == "player" then triggerClientEvent ("openMean", hitPlayer) end end addEventHandler ("onMarkerHit", resourceRoot, markerHit) function markerLeave (hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then triggerClientEvent ("closeOpenMean", hitPlayer) end end addEventHandler ("onMarkerLeave", resourceRoot, markerLeave) Meta thanks! 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