Hero192 Posted July 22, 2015 Share Posted July 22, 2015 When i selecte item and i press on the button "spawn" it doesn't warps me to the correct location,i hope ,you understand me Thanks in advance. ---Client side: local client = getLocalPlayer() local rootElement = getRootElement() --GUI: local yourX = 1366 local yourY = 768 local sx, sy = guiGetScreenSize() local x, y = sx/yourX, sy/yourY window = guiCreateWindow(493*x,227*y,366*x,294*y,"Bus stations",false) spawn = guiCreateButton(10*x,261*y,146*x,24*y,"Spawn",false,window) reject = guiCreateButton(209*x,261*y,146*x,23*y,"Cancel",false,window) grid = guiCreateGridList(9*x,21*y,348*x,236*y,false,window) guiGridListSetSelectionMode(grid,0) guiGridListAddColumn(grid,"Name:",0.38,window) guiGridListAddColumn(grid,"Location:",0.38,window) guiGridListAddColumn(grid,"Price",0.19,window) guiWindowSetSizable(window,false) guiSetVisible (window,false) Buslocations = { {"Las Venturas Airport","LV","100$",1730.42,1480.3,10.81}, ------- Edit [ X, y, z ] to Las Venturas position {"The Emerald Isle","LS","100$",2220.22,2477.71,10.82},------- Edit [ X, y, z ] to Los Santo position {"Old Venturas Strip","SF","100$",2447.32,2059.2,10.82} ------- Edit [ X, y, z ] to San Fierro position } function locations() for k,v in ipairs (Buslocations) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, 1,v[1], false, false) guiGridListSetItemText(grid, row, 2,v[2], false, false) guiGridListSetItemText(grid, row, 3,v[3], false, false) guiGridListSetItemText(grid, row, 4,v[4], false, false) guiGridListSetItemText(grid, row, 5,v[5], false, false) guiGridListSetItemText(grid, row, 6,v[6], false, false) end end addEvent("bus:showGUI",true) addEventHandler("bus:showGUI",root, function (Buslocations) guiGridListClear(grid) locations() guiSetVisible (window,true) showCursor(true) end) addEventHandler("onClientGUIClick",root, function () if (source == reject) then guiSetVisible(window, false) showCursor(false) elseif (source == spawn) then guiSetVisible(window,false) showCursor(false) local cityname = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 1) local price = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 3) local x = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 4) local y = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 5) local z = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 6) triggerServerEvent("warpplayer",localPlayer, cityname,price,x,y,z) end end) --Server Side: local markers = { {x=1730.42, y=1480.3, z=9.81, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --Spawn1 {x=2220.22, y=2477.71, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --Spawn2 {x=2447.32, y=2059.2, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --spawn3 -- {x=1633.95, y=1831.68, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, } addEventHandler("onResourceStart",resourceRoot, function () for index, pos in pairs(markers) do local marker = createMarker(pos.x, pos.y, pos.z, "cylinder", pos.size, pos.r, pos.g, pos.b, pos.a) setElementInterior (marker, pos.int) setElementDimension(marker, pos.dim) addEventHandler("onMarkerHit",marker,MarkerHit) end end) function MarkerHit(player, dim) if (dim and getElementType(player) == "player") then triggerClientEvent(player,"bus:showGUI",player,Buslocations) end end addEvent ("warpplayer",true) addEventHandler ("warpplayer",getRootElement(), function (cityname,price,x,y,z) if getElementZoneName (source) == cityname then if ( getPlayerMoney ( source ) < 100 ) then outputChatBox("You need 100$ to Travel.", source, 255,0,0) else takePlayerMoney (source,500) setTimer(spawn,4000,1,source) spawn = spawnPlayer(client, x,y,z) fadeCamera ( source, false, 1.0, 0, 0, 0 ) end end end) Link to comment
Rataj Posted July 22, 2015 Share Posted July 22, 2015 Use "setElementPosition" instead of "spawnPlayer". Link to comment
Hero192 Posted July 22, 2015 Author Share Posted July 22, 2015 Doesn't works ,any Idea? Link to comment
GTX Posted July 22, 2015 Share Posted July 22, 2015 You can't trigger a variable via setTimer wtf? local markers = { {x=1730.42, y=1480.3, z=9.81, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --Spawn1 {x=2220.22, y=2477.71, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --Spawn2 {x=2447.32, y=2059.2, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, --spawn3 -- {x=1633.95, y=1831.68, z=9.82, size=1.5, int=0, dim=0, r=190, g=180, b=30, a=180}, } addEventHandler("onResourceStart",resourceRoot, function () for index, pos in pairs(markers) do local marker = createMarker(pos.x, pos.y, pos.z, "cylinder", pos.size, pos.r, pos.g, pos.b, pos.a) setElementInterior (marker, pos.int) setElementDimension(marker, pos.dim) addEventHandler("onMarkerHit",marker,MarkerHit) end end) function MarkerHit(player, dim) if (dim and getElementType(player) == "player") then triggerClientEvent(player,"bus:showGUI",player,Buslocations) end end addEvent ("warpplayer",true) addEventHandler ("warpplayer",getRootElement(), function (cityname,price,x,y,z) if getElementZoneName (source) == cityname then if ( getPlayerMoney ( source ) < 100 ) then outputChatBox("You need 100$ to Travel.", source, 255,0,0) else takePlayerMoney (source,500) setTimer(spawnPlayer,4000,1,source, x, y, z) fadeCamera ( source, false, 1.0, 0, 0, 0 ) end end end) Link to comment
Hero192 Posted July 22, 2015 Author Share Posted July 22, 2015 Still doesn't working, i can't warp ,i thinks there's a problem in client side,because im not good in guigridlist still learning Link to comment
Hero192 Posted July 22, 2015 Author Share Posted July 22, 2015 Please try to give me a hand on that,im sure if it solved i'll learn the gridlist stuffs.. because im stuck on that Link to comment
GTX Posted July 22, 2015 Share Posted July 22, 2015 local client = getLocalPlayer() local rootElement = getRootElement() --GUI: local yourX = 1366 local yourY = 768 local sx, sy = guiGetScreenSize() local x, y = sx/yourX, sy/yourY window = guiCreateWindow(493*x,227*y,366*x,294*y,"Bus stations",false) spawn = guiCreateButton(10*x,261*y,146*x,24*y,"Spawn",false,window) reject = guiCreateButton(209*x,261*y,146*x,23*y,"Cancel",false,window) grid = guiCreateGridList(9*x,21*y,348*x,236*y,false,window) guiGridListSetSelectionMode(grid,0) guiGridListAddColumn(grid,"Name:",0.38,window) guiGridListAddColumn(grid,"Location:",0.38,window) guiGridListAddColumn(grid,"Price",0.19,window) guiWindowSetSizable(window,false) guiSetVisible (window,false) Buslocations = { {"Las Venturas Airport","LV",100,1730.42,1480.3,10.81}, ------- Edit [ X, y, z ] to Las Venturas position {"The Emerald Isle","LS",100,2220.22,2477.71,10.82},------- Edit [ X, y, z ] to Los Santo position {"Old Venturas Strip","SF",100,2447.32,2059.2,10.82} ------- Edit [ X, y, z ] to San Fierro position } function locations() for k,v in ipairs (Buslocations) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, 1,v[1], false, false) guiGridListSetItemText(grid, row, 2,v[2], false, false) guiGridListSetItemText(grid, row, 3,v[3].."$", false, false) guiGridListSetItemText(grid, row, 4,v[4], false, false) guiGridListSetItemText(grid, row, 5,v[5], false, false) guiGridListSetItemText(grid, row, 6,v[6], false, false) end end addEvent("bus:showGUI",true) addEventHandler("bus:showGUI",root, function (Buslocations) guiGridListClear(grid) locations() guiSetVisible (window,true) showCursor(true) end) addEventHandler("onClientGUIClick",root, function () if (source == reject) then guiSetVisible(window, false) showCursor(false) elseif (source == spawn) then guiSetVisible(window,false) showCursor(false) local cityname = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 1) local price = Buslocations[guiGridListGetSelectedItem (grid)][3] local x = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 4) local y = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 5) local z = guiGridListGetItemText (grid, guiGridListGetSelectedItem (grid), 6) triggerServerEvent("warpplayer",localPlayer, cityname,price,x,y,z) end 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