Jump to content

help over here.


Sparrow

Recommended Posts

Ah, I understand now, you're using 'ipairs' instead of 'pairs', you can't use 'ipairs' in that kind of table.

local marker = createMarker (1605.600, -1625.300, 12.5, "cylinder", 2, 25, 50, 255, 255 ) 
local cars = { 
    [596] = 'Police LS', 
    [597] = 'Police SF', 
    [598] = 'Police LV', 
    [599] = 'Police Ranger' 
} 
  
window = guiCreateWindow(561,187,260,388,"Spawn Vehicle",false) 
guiWindowSetSizable(window,false) 
spawnButton = guiCreateButton(26,317,96,37,"Spawn",false,window) 
closeButton = guiCreateButton(142,318,96,37,"Close",false,window) 
carGrid = guiCreateGridList(23,34,210,249,false,window) 
guiGridListSetSelectionMode(carGrid,0) 
column = guiGridListAddColumn(carGrid,"Vehicle name",0.85) 
for id,vehName in pairs(cars) do 
    local row = guiGridListAddRow ( carGrid ) 
    guiGridListSetItemText ( carGrid, row, column, tostring(vehName), false, false ) 
    guiGridListSetItemData ( carGrid, row, column, tonumber(id), false, false ) 
end 
  
function showWindow() 
    local playerTeam = getPlayerTeam (localPlayer) 
    local teamName = getTeamName ( playerTeam ) 
    if (teamName == "Police") then 
        guiSetVisible( window, true ) 
        showCursor(true) 
    end 
end 
addEventHandler ("onClientMarkerHit", marker, showWindow) 
  
function spawn() 
    local row,col = guiGridListGetSelectedItem(carGrid) 
    if (row and col and row ~= -1 and col ~= -1) then 
        local model = guiGridListGetItemData(carGrid, row, 1) 
        triggerServerEvent('onGUIClick',localPlayer,tonumber(model)) 
    end 
end 
addEventHandler('onClientGUIClick',spawnButton, spawn, false) 
    
function setVisible() 
    guiSetVisible(window,false) 
    showCursor(false) 
end 
addEvent('setGUIVisible',true) 
 addEventHandler('setGUIVisible',root,setVisible) 
  
function closeWindow() 
    guiSetVisible(window,false) 
    showCursor(false) 
end 
addEventHandler ("onClientGUIClick", closeButton, closeWindow, false) 

Link to comment

pairs:

t = { 
  [1] = 1; 
  ['two'] = 2; 
} 
  
for i,v in pairs( t ) do 
   print( i,v )  
   --[[ 
   1    1 
   two  2 
  ]] 
end 

ipairs:

t = { 
  [1] = 1; 
  ['two'] = 2; 
} 
  
for i,v in ipairs( t ) do 
   print( i,v )  
   --[[ 
   1    1 
  ]] 
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...