Jump to content

[HELP ME]Problem in GuiGridList || Transport marker


Hero192

Recommended Posts

Hello guys,im trying to make an transporter system, with guiGridList but im not really good in handling guiGridList.., i tried harder to solve it but the solution is, when i selecte an item and i click on Spawn i do not warp to the right place, i just stay in my place

Please correcte me to understand my fault,here's my code about guiGridList ,Marker stuffs are fine also the Code gives 0 errors

--Client side:

addEvent("showGUI",true) 
addEventHandler("showGUI",root, 
function (Buslocations) 
guiGridListClear(grid) 
  for i, v in pairs(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) 
    end 
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) 
          triggerServerEvent("warpplayer",client) 
     end   
end) 
  
  

--Server Side:

  
        Buslocations = { 
{"Las Venturas","LV","100$"}, 
{"Los Santos","LS","100$"}, 
{"San Fierro","SF","100$"}, 
} 
  
function setPedSpawnCity (player,x,y,z,I,D,R) 
setElementPosition (player,x,y,z) 
setElementInterior (player,I) 
setElementDimension (player,D) 
setPedRotation (player,R) 
end 
function spawn1(player) 
setPedSpawnCity (player,1730.42, 1480.3, 10.81120,0,0,270) 
outputChatBox("Spawned successfully",player, 0, 255, 0) 
fadeCamera (player,true, 1.0, 0, 0, 0 )  
end 
function spawn2(player) 
setPedSpawnCity (player,2220.22, 2477.71, 10.82120,0,0,270) 
outputChatBox("Spawned successfully",player, 0, 255, 0) 
fadeCamera (player,true, 1.0, 0, 0, 0 )  
end 
  
  
addEvent ("warpplayer",true) 
addEventHandler ("warpplayer",getRootElement(), 
function () 
if getElementZoneName (source) == "Las Venturas Airport" then 
if ( getPlayerMoney ( source ) < 100 ) then 
outputChatBox("You need 100$ to Travel.", source, 255,0,0) 
else 
takePlayerMoney (source,500) 
setTimer(spawn1,4000,1,source) 
fadeCamera ( source, false, 1.0, 0, 0, 0 )  
end 
elseif getElementZoneName (source) == "The Emerald Isle" then 
if ( getPlayerMoney ( source ) < 100 ) then 
outputChatBox("You need 100$ to Travel.", source, 255,0,0) 
else 
takePlayerMoney (source,500) 
setTimer(spawn2,4000,1,source) 
fadeCamera ( source, false, 1.0, 0, 0, 0 )  
end 
    end 
end) 

Link to comment

NemoxHero,

The idea of the transport script is store an x,y,z for every position you want to travel like this, :)

client side :

  
        Buslocations = { 
{"Las Venturas","LV","100$",x,y,z}, ------- Edit [ X, y, z ] to Las Venturas position 
{"Los Santos","LS","100$",x,y,z},------- Edit [ X, y, z ] to Los Santo position 
{"San Fierro","SF","100$",x,y,z} ------- Edit [ X, y, z ] to San Fierro position 
} 
--------------------------- 
---- Here put gui elements  
--------------------------- 
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 
  
createMarker = (.......yourcode.....) 
------------------------------------------------------------------------- 
---------- or maybe you can use table to create a markers by one function 
---------- and function for showing element of the gui on marker hit 
------------------------------------------------------------------------- 
  
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 (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 1) 
      local price = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 3)  
      local x = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 4) 
      local y = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 5) 
      local z = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 6) 
  
      triggerServerEvent("warpplayer",localPlayer, cityname,price,x,y,z)  
        end 
end) 
  

* : Note : You need to add new raw's to gridlist to contain the [x,y,z]

server side

  
  
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 
        spawnPlayer(client, x,y,z,46, 250, 0) 
end 
end 
end 
) 
  

:)

Link to comment
Any one can give me good idea or explain to me how to use the guigridlist please

He just mentioned Solution

NemoxHero,

The idea of the transport script is store an x,y,z for every position you want to travel like this, :)

client side :

  
        Buslocations = { 
{"Las Venturas","LV","100$",x,y,z}, ------- Edit [ X, y, z ] to Las Venturas position 
{"Los Santos","LS","100$",x,y,z},------- Edit [ X, y, z ] to Los Santo position 
{"San Fierro","SF","100$",x,y,z} ------- Edit [ X, y, z ] to San Fierro position 
} 
--------------------------- 
---- Here put gui elements  
--------------------------- 
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 
  
createMarker = (.......yourcode.....) 
------------------------------------------------------------------------- 
---------- or maybe you can use table to create a markers by one function 
---------- and function for showing element of the gui on marker hit 
------------------------------------------------------------------------- 
  
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 (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 1) 
      local price = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 3)  
      local x = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 4) 
      local y = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 5) 
      local z = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 6) 
  
      triggerServerEvent("warpplayer",localPlayer, cityname,price,x,y,z)  
        end 
end) 
  

* : Note : You need to add new raw's to gridlist to contain the [x,y,z]

server side

  
  
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 
        spawnPlayer(client, x,y,z,46, 250, 0) 
end 
end 
end 
) 
  

:)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...