abdalbaset Posted January 4, 2014 Share Posted January 4, 2014 i have this gui panel but how i can make it spawn cars whene i choose car from the panel and preess spawn car GUIEditor = { gridlist = {}, window = {}, button = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(498, 244, 362, 391, "car panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(59, 26, 245, 242, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "cars", 0.9) for i = 1, 4 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Infernus", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "NRG-500", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Sultan", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Super GT", false, false) GUIEditor.button[1] = guiCreateButton(59, 268, 245, 49, "spawn car", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(60, 338, 248, 43, "close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") end ) Link to comment
TAPL Posted January 4, 2014 Share Posted January 4, 2014 -- Client Side -- Event: "onClientGUIClick" addEventHandler guiGridListGetSelectedItem guiGridListGetItemText getVehicleModelFromName triggerServerEvent -- Server Side -- addEvent addEventHandler getElementPosition createVehicle warpPedIntoVehicle Link to comment
Deepu Posted January 4, 2014 Share Posted January 4, 2014 thePlayer = getLocalPlayer () addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(498, 244, 362, 391, "car panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(59, 26, 245, 242, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "cars", 0.9) for i = 1, 4 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Infernus", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "NRG-500", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Sultan", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Super GT", false, false) GUIEditor.button[1] = guiCreateButton(59, 268, 245, 49, "spawn car", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(60, 338, 248, 43, "close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") end function createInfernus() if (source==GUIEditor.button[1]) then infernus = createVehicle(ID, x, y, z) warpPedIntoVehicle(thePlayer, infernus, 0) showCursor(false) guiSetVisible(GUIEditor.window[1], false) end end addEventHandler("onClientGUIClick", root, createInfernus) ) The thing you missed is "onClientGUIClick" event handler Do the same for other cars like createInfernus function Did it So fast so if u have any errors then contact me I can help you And can I script for your server thankyou Link to comment
abdalbaset Posted January 4, 2014 Author Share Posted January 4, 2014 Thank man but I want to make marker when's the player hit it GUI panel open I have to add marker and event under. On player hit? Sort for bad English I am writing from androd Link to comment
Deepu Posted January 5, 2014 Share Posted January 5, 2014 Sure I will make it for you... But learn how I made it ok? There is the script Link to comment
al-Kobra Posted January 5, 2014 Share Posted January 5, 2014 'onClientMarkerHit' guiSetVisible Link to comment
Deepu Posted January 5, 2014 Share Posted January 5, 2014 local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) function carGui (hitPlayer, matchingDimension) mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for i = 1, 2 do guiGridListAddRow(carsG) end guiGridListSetItemText(carsG, 0, 1, "sabre", false, false) guiGridListSetItemText(carsG, 1, 1, "Nrg-500", false, false) spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") showCursor(true) sabre = createVehicle(422, 1541, -1627.4000244141, 12.60000038147) warpPedIntoVehicle(hitPlayer,sabre) -- this function doesn't work in my MTA, so just check it in yours and if it doesn't work put it in server side end addEventHandler("onClientMarkerHit", spawnMarker, carGui) function spawnCar () if (source==spawnButton) then sabre = createVehicle(422, 1541, -1627.4000244141, 12.60000038147) warpPedIntoVehicle(hitPlayer, sabre) end end addEventHandler("onClientGUIClick", root, spawnCar) Hope you understood how u make it also When I tested it [juz tested it once] the car spawns but I can't enter the car I made it so fast cuz i had exams so if any errors contact me Also If you have a RPG server, can I script for that server? possibly giving me admin rights? can you? Link to comment
abdalbaset Posted January 5, 2014 Author Share Posted January 5, 2014 sure but my server is not 24/7 open so connect with my skype abdalbaset.skoot but the script just show the gui panel its didnt spawn any car so i try and make this by my own self local spawnMarker = createMarker(2851.282958,1291.65686,10.7697496, "cylinder", 2, 225, 163, 25, 225) GUIEditor = { gridlist = {}, window = {}, button = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(498, 244, 362, 391, "car panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(59, 26, 245, 242, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "cars", 0.9) for i = 1, 4 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Infernus", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Flash", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Sultan", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Super GT", false, false) GUIEditor.button[1] = guiCreateButton(59, 268, 245, 49, "spawn car", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(60, 338, 248, 43, "close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") end ) function markerHit (hitPlayer, matchingDimension) if isPedInVehicle (hitPlayer) then return end if getElementType(hitPlayer) == "player" then triggerClientEvent ("openMean", hitPlayer) end end addEventHandler ("onMarkerHit",spawnMarker,player) marker made but whene ithe resours start the panel come up so i replace onClientResourceStart with onMarkerHit now its didnt come up (how i can make this panel close?) Link to comment
iPrestege Posted January 6, 2014 Share Posted January 6, 2014 Of course because you're using a server side functions in the client side this is totally wrong. Link to comment
abdalbaset Posted January 6, 2014 Author Share Posted January 6, 2014 And how may I fix it? I know that its kind of missed up I use GUI editor Link to comment
Deepu Posted January 7, 2014 Share Posted January 7, 2014 Friend, I told you * Just put it in the Server sided lua thingy and then use this in client one ======= the server sided one :- name it server.lua function carSpawn () sabre = createVehicle(422, 1541, -1627.4000244141, 12.60000038147) warpPedIntoVehicle(thePlayer, sabre) addEvent("onSpawnVehicle", true) addEventHandler("onSpawnVehicle", getRootElement(), carSpawn) end now this is the client sided one:- client.lua local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) function carGui (hitPlayer, matchingDimension) mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for i = 1, 2 do guiGridListAddRow(carsG) end guiGridListSetItemText(carsG, 0, 1, "sabre", false, false) guiGridListSetItemText(carsG, 1, 1, "Nrg-500", false, false) spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") showCursor(true) sabre = createVehicle(422, 1541, -1627.4000244141, 12.60000038147) warpPedIntoVehicle(hitPlayer,sabre) -- this function doesn't work in my MTA, so just check it in yours and if it doesn't work put it in server side end addEventHandler("onClientMarkerHit", spawnMarker, carGui) function spawnCar () if (source==spawnButton) then triggerServerEvent("onSpawnVehicle", sabre) addEventHandler("onClientGUIClick", root, spawnCar) end end try this if any more errors then call me PS I was Busy so dint come online Link to comment
TAPL Posted January 7, 2014 Share Posted January 7, 2014 @Deepu, All of your codes in this topic is incorrect nor near the correct. So simply, don't try help others when you can't. Link to comment
abdalbaset Posted January 7, 2014 Author Share Posted January 7, 2014 now who can help me!? Link to comment
DNL291 Posted January 7, 2014 Share Posted January 7, 2014 Try this: Client: local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) function carGui () mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) guiSetVisible(mainWindow, false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for i = 1, 2 do guiGridListAddRow(carsG) end guiGridListSetItemText(carsG, 0, 1, "sabre", false, false) guiGridListSetItemText(carsG, 1, 1, "Nrg-500", false, false) spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") end addEventHandler("onClientResourceStart", resourceRoot, carGui) addEventHandler("onClientGUIClick", root, function () if (source == spawnButton) then local row,col = guiGridListGetSelectedItem(carsG) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(carsG, row, 1) if vehicleName == "sabre" then triggerServerEvent("onSpawnVehicle", localPlayer, 475) showWindow(false) elseif vehicleName == "Nrg-500" then triggerServerEvent("onSpawnVehicle", localPlayer, 522) showWindow(false) end else outputChatBox("Select a vehicle from the list.") end elseif (source == cancelButton) then showWindow(false) end end) addEventHandler("onClientMarkerHit", spawnMarker, function (hitPlayer) if (hitPlayer == localPlayer) then showWindow(true) end end) function showWindow(bool) guiSetVisible(mainWindow, bool) showCursor(bool) end Server: local vehicles = { } addEvent("onSpawnVehicle", true) addEventHandler("onSpawnVehicle", root, function (vehID) if ( isElement(vehicles[source]) ) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(vehID, getElementPosition(source)) warpPedIntoVehicle(source, vehicles[source]) end) I haven't tested it. Link to comment
abdalbaset Posted January 8, 2014 Author Share Posted January 8, 2014 thanx much man but one more thing how i can my this marker spawn hust for one team? Link to comment
DNL291 Posted January 8, 2014 Share Posted January 8, 2014 local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) function carGui () mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) guiSetVisible(mainWindow, false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for i = 1, 2 do guiGridListAddRow(carsG) end guiGridListSetItemText(carsG, 0, 1, "sabre", false, false) guiGridListSetItemText(carsG, 1, 1, "Nrg-500", false, false) spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") end addEventHandler("onClientResourceStart", resourceRoot, carGui) addEventHandler("onClientGUIClick", root, function () if (source == spawnButton) then if (not getTeamName(getPlayerTeam(localPlayer)) == "teamName") then return end local row,col = guiGridListGetSelectedItem(carsG) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(carsG, row, 1) if vehicleName == "sabre" then triggerServerEvent("onSpawnVehicle", localPlayer, 475) showWindow(false) elseif vehicleName == "Nrg-500" then triggerServerEvent("onSpawnVehicle", localPlayer, 522) showWindow(false) end else outputChatBox("Select a vehicle from the list.") end elseif (source == cancelButton) then showWindow(false) end end) addEventHandler("onClientMarkerHit", spawnMarker, function (hitPlayer) if (hitPlayer == localPlayer) then showWindow(true) end end) function showWindow(bool) guiSetVisible(mainWindow, bool) showCursor(bool) end Link to comment
abdalbaset Posted January 8, 2014 Author Share Posted January 8, 2014 this not working:( whene i but it i cant see the marker Link to comment
DNL291 Posted January 8, 2014 Share Posted January 8, 2014 local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) function carGui () mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) guiSetVisible(mainWindow, false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for i = 1, 2 do guiGridListAddRow(carsG) end guiGridListSetItemText(carsG, 0, 1, "sabre", false, false) guiGridListSetItemText(carsG, 1, 1, "Nrg-500", false, false) spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") end addEventHandler("onClientResourceStart", resourceRoot, carGui) addEventHandler("onClientGUIClick", root, function () if (source == spawnButton) then if not (getTeamName(getPlayerTeam(localPlayer)) == "teamName") then return end local row,col = guiGridListGetSelectedItem(carsG) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(carsG, row, 1) if vehicleName == "sabre" then triggerServerEvent("onSpawnVehicle", localPlayer, 475) showWindow(false) elseif vehicleName == "Nrg-500" then triggerServerEvent("onSpawnVehicle", localPlayer, 522) showWindow(false) end else outputChatBox("Select a vehicle from the list.") end elseif (source == cancelButton) then showWindow(false) end end) addEventHandler("onClientMarkerHit", spawnMarker, function (hitPlayer, dim) if (hitPlayer == localPlayer) and dim then showWindow(true) end end) function showWindow(bool) guiSetVisible(mainWindow, bool) showCursor(bool) end I tested and it works fine for me. Link to comment
abdalbaset Posted January 8, 2014 Author Share Posted January 8, 2014 DNL sory if i annoying you but last thing how i can add cars to this panel!? Link to comment
DNL291 Posted January 9, 2014 Share Posted January 9, 2014 Add the vehicle name and the ID of that vehicle in vehicles table (line 3). local spawnMarker = createMarker(1541, -1627.4000244141, 12.60000038147, "cylinder", 2, 225, 163, 25, 225) local vehicles = { ["sabre"] = 475, ["Nrg-500"] = 522, ["carName"] = ID } function carGui () mainWindow = guiCreateWindow(266, 103, 277, 374, "Spawn Window for u", false) guiSetVisible(mainWindow, false) carsG = guiCreateGridList(9, 28, 258, 284, false, mainWindow) guiGridListAddColumn(carsG, "cars", 0.9) for k,_ in pairs(vehicles) do guiGridListAddRow(carsG) guiGridListSetItemText(carsG, guiGridListGetRowCount(carsG)-1, 1, k, false, false) end spawnButton = guiCreateButton(9, 320, 128, 44, "spawn", false, mainWindow) guiSetFont(spawnButton, "sa-header") cancelButton = guiCreateButton(144, 322, 123, 42, "cancel", false, mainWindow) guiSetFont(cancelButton, "sa-header") end addEventHandler("onClientResourceStart", resourceRoot, carGui) addEventHandler("onClientGUIClick", root, function () if (source == spawnButton) then if not (getTeamName(getPlayerTeam(localPlayer)) == "teamName") then return end local row,col = guiGridListGetSelectedItem(carsG) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(carsG, row, 1) if triggerServerEvent("onSpawnVehicle", localPlayer, vehicles[vehicleName]) then showWindow(false) end else outputChatBox("Select a vehicle from the list.") end elseif (source == cancelButton) then showWindow(false) end end) addEventHandler("onClientMarkerHit", spawnMarker, function (hitPlayer) if (hitPlayer == localPlayer) then showWindow(true) end end) function showWindow(bool) guiSetVisible(mainWindow, bool) showCursor(bool) end 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