Lucario Posted May 19, 2013 Share Posted May 19, 2013 Hi, im making a full car shop for the community and my server, but i have problems, when i start the resource, the 2 guis appears in 1 time, and have a little bugs with the buttons i think, anyone can help me plz, or fix the start resource bug, code: Server side carShopMarker = createMarker (2133.59,-1149.29, 23.3, "cylinder", 3, 255, 255, 0, 127) carShopMarker2 = createMarker (562, -1270, 16, "cylinder", 2, 255, 255, 0, 127) carShopMarker3 = createMarker (-1954,299,34,"cylinder",2,255,255,0,127) carShopMarker4 = createMarker (-1663,1208,6,"cylinder",2,255,255,0,127) carShopMarker5 = createMarker (1946,2068,10,"cylinder",2,255,255,0,127) createBlipAttachedTo(carShopMarker,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker2,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker3,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker4,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker5,55,2,0,255,0,0,0,200) addEvent ("watchGUI", true) function markerHit (hitPlayer, matchingDimension) if (source == carShopMarker) or (source == carShopMarker2) or (source == carShopMarker3) or (source == carShopMarker4) or (source == carShopMarker5) then triggerClientEvent ("watchGUI", hitPlayer) end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) addEvent ("carShopBuy", true) addEventHandler ("carShopBuy", getRootElement(), function(id, cost, name) if (getPlayerMoney (source) >= tonumber(cost)) then outputChatBox ("Has comprado un " .. name, source, 0, 255, 0, false) outputChatBox ("Precio: " .. cost, source, 0, 255, 0, false) takePlayerMoney (source, tonumber (cost)) setAccountData (getPlayerAccount (source), "funmodev2-car", tonumber(id)) setAccountData (getPlayerAccount (source), "funmodev2-paintjob", 3) setAccountData (getPlayerAccount (source), "funmodev2-carupg", 0) else outputChatBox ("No tienes suficiente dinero para comprar un" .. name, source, 255, 0, 0, false) end end) addEvent ("carTeletransport", true) addEvent ("carSell", true) function carSpawn () if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then if (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) and (getElementType(getElementData (source, "hisCar")) == "vehicle") then setElementVelocity (getElementData (source, "hisCar"), 0,0,0) setElementPosition (getElementData (source, "hisCar"), 1631.3790283203,-1094.9102783203,23.90625) outputChatBox ("El vehiculo ha sido teletransportado con exito.", source, 0, 255, 0) elseif not (getElementData (source, "hisCar")) then local accountData = getAccountData (getPlayerAccount (source), "funmodev2-car") if (accountData) then vehicleID = getAccountData (getPlayerAccount (source), "funmodev2-car") x,y,z = getElementPosition (source) vehicle = createVehicle (carID, x +2, y, z +1) setElementID (vehicle, getAccountName (getPlayerAccount(source))) setElementData (source, "hisCar", vehicle) outputChatBox ("El vehiculo ha sido teletransportado con exito.", source, 255, 0, 0) if (getAccountData (getPlayerAccount(source), "funmodev2-carupg")) then local upgrades = nil local upgrades = {} local upgrades = getAccountData (getPlayerAccount(source), "funmodev2-carupg") for i,v in ipairs (upgrades) do addVehicleUpgrade (vehicle, v) end end if (getAccountData (getPlayerAccount(source), "funmodev2-paintjob")) then local paintjob = getAccountData (getPlayerAccount(source), "funmodev2-paintjob") setVehiclePaintjob (vehicle, paintjob) end if (getAccountData (getPlayerAccount(source), "funmodev2-carcolor1")) and (getAccountData (getPlayerAccount(source), "funmodev2-carcolor2")) then local c1 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor1") local c2 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor2") setVehicleColor (vehicle, c1,c2,0,0) end else outputChatBox ("No tienes ningun vehiculo.", source, 255, 0, 0) end else outputChatBox ("Ya estas en un vehiculo!", source, 255, 0, 0) end end end addEventHandler ("carSpawn", getRootElement(), carSpawn) function carDestroy (cost) if not (isGuestAccount (getPlayerAccount (source))) then if (isPedInVehicle (source)) then if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then local sell = getPlayerAccount (source), "hisCar", tonumber(cost) givePlayerMoney (sell (source, "hisCar")) destroyElement (getPedOccupiedVehicle (source)) removeElementData (source, "hisCar") outputChatBox ("Vehiculo vendido, te han sido devueltos " ..cost, source, 0, 255, 0) else outputChatBox ("Este no es tu vehiculo!", source, 255, 0, 0) end elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then car=getElementData(source, "hisCar") cancelEvent() outputchatbox ("Este carro es gratis y no se puede vender", source, 255, 0, 0) end end end addEventHandler ("carSell", getRootElement(), carDestroy) function lightsSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleOverrideLights(veh) ~= 2) then setVehicleOverrideLights(veh, 2) outputChatBox ("Las luces del vehiculo han sido encendidas.", source, 0, 0, 255) elseif (getVehicleOverrideLights(veh) ~= 1) then setVehicleOverrideLights(veh, 1) outputChatBox ("Las luces del vehiculo han sido apagadas.", source, 0, 0, 255) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lightsCar",true) addEventHandler("lightsCar",getRootElement(),lightsSwitch) function lockSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if not (isVehicleLocked (veh)) then setVehicleLocked (veh, true) setVehicleDoorsUndamageable (veh, true) setVehicleDoorState (veh, 0, 0) setVehicleDoorState (veh, 1, 0) setVehicleDoorState (veh, 2, 0) setVehicleDoorState (veh, 3, 0) outputChatBox ("El vehiculo ha sido cerrado.", source, 255, 0, 0) elseif (isVehicleLocked (veh)) then setVehicleLocked (veh, false) setVehicleDoorsUndamageable (veh, false) outputChatBox ("El vehiculo ha sido abierto.", source, 0, 255, 0) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lockCar",true) addEventHandler("lockCar",getRootElement(),lockSwitch ) addEventHandler ("onVehicleStartEnter", getRootElement(), function(player, seat, jacked, door) if (isVehicleLocked (source) == true) then local mannetjeNaam = getAccountName (getPlayerAccount (player)) local autoNaam = getElementID (source) if (mannetjeNaam == autoNaam) then setVehicleLocked (source, false) outputChatBox ("El vehiculo ha sido abierto!", player, 255, 0, 0, false) end end end) addEventHandler ("onVehicleExplode", getRootElement(), function() local theOwner = getAccountName (getPlayerAccount(getPlayerFromName (getElementID (source)))) if (theOwner) then removeElementData (theOwner, "hisCar") end end) addEventHandler ("onPlayerQuit", getRootElement(), function(quitType, reason, responsibleElement) if (getElementData (source, "hisCar")) then blowVehicle (getElementData (source, "hisCar")) removeElementData (source, "hisCar") end end) addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ), function () for i,v in ipairs (getElementsByType ("player")) do if (getElementData (v, "hisCar")) then setElementHealth (getElementData (v, "hisCar"), 0) removeElementData (v, "hisCar") end end end ) function destroyOnExplode () setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode) Client side: local lp = getLocalPlayer() GUIEditor = { label = {}, button = {}, window = {}, gridlist = {}, memo = {} } shopwindows = guiCreateWindow(352, 156, 510, 519, "Tienda de autos por MultiKiller", false) guiWindowSetMovable(shopwindows, false) guiWindowSetSizable(shopwindows, false) shopgrid = guiCreateGridList(9, 21, 288, 390, false, shopwindows) guiGridListAddColumn(shopgrid, "Autos", 0.4) guiGridListAddColumn(shopgrid, "Precios", 0.4) guiGridListSetItemText(shopgrid, 0, 1, "Virgo", false, false) guiGridListSetItemText(shopgrid, 0, 2, "20000$", false, false) guiGridListSetItemText(shopgrid, 1, 1, "Uranus", false, false) guiGridListSetItemText(shopgrid, 1, 2, "27000$", false, false) guiGridListSetItemText(shopgrid, 2, 1, "Turismo", false, false) guiGridListSetItemText(shopgrid, 2, 2, "25000$", false, false) guiGridListSetItemText(shopgrid, 3, 1, "Super GT", false, false) guiGridListSetItemText(shopgrid, 3, 2, "30000$", false, false) guiGridListSetItemText(shopgrid, 4, 1, "Sultan", false, false) guiGridListSetItemText(shopgrid, 4, 2, "40000$", false, false) guiGridListSetItemText(shopgrid, 5, 1, "Euros", false, false) guiGridListSetItemText(shopgrid, 5, 2, "30000$", false, false) guiGridListSetItemText(shopgrid, 6, 1, "Romero", false, false) guiGridListSetItemText(shopgrid, 6, 2, "30000$", false, false) guiGridListSetItemText(shopgrid, 7, 1, "Regina", false, false) guiGridListSetItemText(shopgrid, 7, 2, "28000$", false, false) guiGridListSetItemText(shopgrid, 8, 1, "Rancher", false, false) guiGridListSetItemText(shopgrid, 8, 2, "20000$", false, false) guiGridListSetItemText(shopgrid, 9, 1, "Primo", false, false) guiGridListSetItemText(shopgrid, 9, 2, "23500$", false, false) guiGridListSetItemText(shopgrid, 10, 1, "Mr.Whooper", false, false) guiGridListSetItemText(shopgrid, 10, 2, "25000$", false, false) guiGridListSetItemText(shopgrid, 11, 1, "Kart", false, false) guiGridListSetItemText(shopgrid, 11, 2, "18000$", false, false) guiGridListSetItemText(shopgrid, 12, 1, "Jester", false, false) guiGridListSetItemText(shopgrid, 12, 2, "24000$", false, false) guiGridListSetItemText(shopgrid, 13, 1, "Infernus", false, false) guiGridListSetItemText(shopgrid, 13, 2, "40000$", false, false) guiGridListSetItemText(shopgrid, 14, 1, "Hotdog", false, false) guiGridListSetItemText(shopgrid, 14, 2, "23000$", false, false) guiGridListSetItemText(shopgrid, 15, 1, "Harvester", false, false) guiGridListSetItemText(shopgrid, 15, 2, "29000$", false, false) guiGridListSetItemText(shopgrid, 16, 1, "Emperor", false, false) guiGridListSetItemText(shopgrid, 16, 2, "24000$", false, false) guiGridListSetItemText(shopgrid, 17, 1, "Elegy", false, false) guiGridListSetItemText(shopgrid, 17, 2, "25000$", false, false) guiGridListSetItemText(shopgrid, 18, 1, "Elegant", false, false) guiGridListSetItemText(shopgrid, 18, 2, "26000$", false, false) guiGridListSetItemText(shopgrid, 19, 1, "Comet", false, false) guiGridListSetItemText(shopgrid, 19, 2, "29000$", false, false) guiGridListSetItemText(shopgrid, 20, 1, "Cheetah", false, false) guiGridListSetItemText(shopgrid, 20, 2, "35000$", false, false) guiGridListSetItemText(shopgrid, 21, 1, "Caddy", false, false) guiGridListSetItemText(shopgrid, 21, 2, "19000$", false, false) guiGridListSetItemText(shopgrid, 22, 1, "Bullet", false, false) guiGridListSetItemText(shopgrid, 22, 2, "42000$", false, false) guiGridListSetItemText(shopgrid, 23, 1, "Buffalo", false, false) guiGridListSetItemText(shopgrid, 23, 2, "37000$", false, false) guiGridListSetItemText(shopgrid, 24, 1, "Bravura", false, false) guiGridListSetItemText(shopgrid, 24, 2, "27500$", false, false) guiGridListSetItemText(shopgrid, 25, 1, "Blade", false, false) guiGridListSetItemText(shopgrid, 25, 2, "28500$", false, false) guiGridListSetItemText(shopgrid, 26, 1, "Banshee", false, false) guiGridListSetItemText(shopgrid, 26, 2, "45000$", false, false) guiGridListSetItemText(shopgrid, 27, 1, "Bandito", false, false) guiGridListSetItemText(shopgrid, 27, 2, "30000$", false, false) guiGridListSetItemText(shopgrid, 28, 1, "Admiral", false, false) guiGridListSetItemText(shopgrid, 28, 2, "23000$", false, false) GUIEditor.memo[1] = guiCreateMemo(0, 390, 40, 47, "", false, shopgrid) GUIEditor.memo[2] = guiCreateMemo(10, 505, 20, 0, "", false, shopwindows) GUIEditor.memo[3] = guiCreateMemo(10, 417, 277, 88, "Sistema de tienda de autos profesional, \nelige el auto comprarlo y apreta F2\npuedes comprar mas de 2 autos\npuedes cerrarlo, teleportarlo al punto de reparo, etc", false, shopwindows) guiMemoSetReadOnly(GUIEditor.memo[3], true) buy = guiCreateButton(326, 28, 153, 90, "Comprar", false, shopwindows) guiSetFont(buy, "sa-header") GUIEditor.label[1] = guiCreateLabel(313, 444, 187, 51, "Por MultiKiller con Ayuda de \nTigreBlanco\nSaludos de Juramento Server", false, shopwindows) guiSetFont(GUIEditor.label[1], "clear-normal") guiLabelSetColor(GUIEditor.label[1], 17, 255, 0) addEvent ("watchGUI", true) function watchGUI () if (getLocalPlayer() == source) then guiSetVisible (shopgrid, true) showCursor (true) end end addEventHandler ("watchGUI", getRootElement(), watchGUI) function onClientClick (button, state, absoluteX, absoluteYe) if (source == buy) then guiSetVisible (shopwindows, false) showCursor (false) if (guiGridListGetSelectedItem (shopwindows)) then local vehicleName = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 1) local vehicleID = getVehicleModelFromName (vehicleName) local vehicleCost = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 2) triggerServerEvent ("carShopBuy", getLocalPlayer(), vehicleID, vehicleCost, vehicleName) end end end addEventHandler ("onClientGUIClick", getRootElement(), onClientClick) carwindows = guiCreateWindow(398, 193, 463, 396, "Panel de Carro Por MultiKiller", false) guiWindowSetSizable(carwindows, false) cargridlist = guiCreateGridList(10, 28, 139, 358, false, carwindows) carcolumn = guiGridListAddColumn(cargridlist, "Autos", 0.9) carrow = guiGridListAddRow(cargridlist) teletransport = guiCreateButton(166, 28, 130, 97, "Teletransportar", false, carwindows) guiSetFont(teletransport, "default-bold-small") guiSetProperty(teletransport, "NormalTextColour", "C8FFFFFF") sell = guiCreateButton(310, 28, 129, 97, "Vender", false, carwindows) guiSetFont(sell, "default-bold-small") guiSetProperty(sell, "NormalTextColour", "C8FFFFFF") lock = guiCreateButton(168, 265, 130, 110, "Cerrar", false, carwindows) guiSetFont(lock, "default-bold-small") guiSetProperty(lock, "NormalTextColour", "C8FFFFFF") lights = guiCreateButton(310, 265, 129, 110, "Luces ON/OFF", false, carwindows) guiSetFont(lights, "default-bold-small") guiSetProperty(lights, "NormalTextColour", "C8FFFFFF") watch = guiCreateButton(168, 140, 128, 105, "Observar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") mark = guiCreateButton(310, 139, 129, 106, "Marcar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") function resourceStart () bindKey ("F2", "down", carPanel) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) function carPanel () panel = guiGetVisible (carwindows) if (panel == true) then guiSetVisible (carwindows, false) showCursor (false) end if (panel == false) then guiSetVisible (carwindows, true) showCursor (true) end end addEvent ("carTeletransport", true) addEvent ("carSell", true) function guiClick (button, state, absoluteX, absoluteY) if (source == teletransport) then triggerServerEvent ("carTeletransport", lp) elseif (source == sell) then triggerServerEvent ("carSell", lp) elseif (source == watch) then triggerServerEvent ("lookCar", lp) elseif (source == lock) then triggerServerEvent ("lockCar", lp) elseif (source == lights) then triggerServerEvent ("lightsCar", lp) end end addEventHandler ("onClientGUIClick", getRootElement(), guiClick) addEventHandler( "onClientGUIClick", getRootElement(), function(vehiclename) if (source == mark) then local v = getElementModel (vehiclename) vehicleBlips[v] = createBlipAttachedTo( v, 27, 1 ) end end ) addEventHandler( "onClientGuiClick", getRootElement(), function(vehiclename) if (source == mark) then local vb = getElementModel (vehiclename) destroyElement( vb[source] ) vb[source] = nil end end ) function vehicleGridlist() if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( cargridlist, guiGridListAddRow ( cargridlist ), carcolumn, getElementModel ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end elseif ( eventName == "onClientGuiClick" ) then triggerServerEvent ("carSell", source) for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end addEventHandler ( "onClientPlayerJoin", root, vehicleGridList ) addEventHandler ( "onClientPlayerQuit", root, vehicleGridList ) end end In the debugscript doesnt output messages Be feel to edit now, when i fix it will be compiled Link to comment
Castillo Posted May 19, 2013 Share Posted May 19, 2013 Just hide the GUI's when the resource starts. Link to comment
Lucario Posted May 19, 2013 Author Share Posted May 19, 2013 Where is this opcions? i have quited onresourcestart, but i tested, it isnt it, can you specifice the part of the code plz? Link to comment
Castillo Posted May 19, 2013 Share Posted May 19, 2013 Just hide the GUI after you create it. Link to comment
Lucario Posted May 19, 2013 Author Share Posted May 19, 2013 function closePanel () guiSetVisible(shopwindows,false) showCursor(false) end addEvent("closePanel",true) addEventHandler("closePanel",getRootElement(),closePanel) addEventHandler("onClientGUIClick",closePanel,false) Something like that? Link to comment
Castillo Posted May 19, 2013 Share Posted May 19, 2013 shopwindows = guiCreateWindow(352, 156, 510, 519, "Tienda de autos por MultiKiller", false) guiWindowSetMovable(shopwindows, false) guiWindowSetSizable(shopwindows, false) guiSetVisible ( shopwindows, false ) -- That's what I meant. Link to comment
Lucario Posted May 19, 2013 Author Share Posted May 19, 2013 thanks castillo but when i entry to the marker on the car shop, to the yellow marker, nothing happens Link to comment
Castillo Posted May 19, 2013 Share Posted May 19, 2013 That's because you are setting visible the gridlist element only, not the whole window "shopwindows". Link to comment
ViRuZGamiing Posted May 19, 2013 Share Posted May 19, 2013 you'll need "onMarkerHit" and "guiSetVisible" (I think) Link to comment
Castillo Posted May 19, 2013 Share Posted May 19, 2013 He already has that, please read the topic before reply Billy. Link to comment
Lucario Posted May 20, 2013 Author Share Posted May 20, 2013 Thanks, but now when i hit the marker, the grid list of the cars doesn't appear Link to comment
Lucario Posted May 20, 2013 Author Share Posted May 20, 2013 Client side: local lp = getLocalPlayer() GUIEditor = { label = {}, button = {}, window = {}, gridlist = {}, memo = {} } shopwindows = guiCreateWindow(352, 156, 510, 519, "Tienda de autos por MultiKiller", false) guiWindowSetMovable(shopwindows, false) guiWindowSetSizable(shopwindows, false) guiSetVisible ( shopwindows, false ) shopgrid = guiCreateGridList(9, 21, 288, 390, false, shopwindows) carcolumn = guiGridListAddColumn(shopgrid, "Autos", 0.4) pricecolumn = guiGridListAddColumn(shopgrid, "Precios", 0.4) guiGridListSetItemText(carcolumn, 0, 1, "Virgo", false, false) guiGridListSetItemText(pricecolumn, 0, 2, "20000$", false, false) guiGridListSetItemText(carcolumn, 1, 1, "Uranus", false, false) guiGridListSetItemText(pricecolumn, 1, 2, "27000$", false, false) guiGridListSetItemText(carcolumn, 2, 1, "Turismo", false, false) guiGridListSetItemText(pricecolumn, 2, 2, "25000$", false, false) guiGridListSetItemText(carcolumn, 3, 1, "Super GT", false, false) guiGridListSetItemText(pricecolumn, 3, 2, "30000$", false, false) guiGridListSetItemText(carcolumn, 4, 1, "Sultan", false, false) guiGridListSetItemText(pricecolumn, 4, 2, "40000$", false, false) guiGridListSetItemText(carcolumn, 5, 1, "Euros", false, false) guiGridListSetItemText(pricecolumn, 5, 2, "30000$", false, false) guiGridListSetItemText(carcolumn, 6, 1, "Romero", false, false) guiGridListSetItemText(pricecolumn, 6, 2, "30000$", false, false) guiGridListSetItemText(carcolumn, 7, 1, "Regina", false, false) guiGridListSetItemText(pricecolumn, 7, 2, "28000$", false, false) guiGridListSetItemText(carcolumn, 8, 1, "Rancher", false, false) guiGridListSetItemText(pricecolumn, 8, 2, "20000$", false, false) guiGridListSetItemText(carcolumn, 9, 1, "Primo", false, false) guiGridListSetItemText(pricecolumn, 9, 2, "23500$", false, false) guiGridListSetItemText(carcolumn, 10, 1, "Mr.Whooper", false, false) guiGridListSetItemText(pricecolumn, 10, 2, "25000$", false, false) guiGridListSetItemText(carcolumn, 11, 1, "Kart", false, false) guiGridListSetItemText(pricecolumn, 11, 2, "18000$", false, false) guiGridListSetItemText(carcolumn, 12, 1, "Jester", false, false) guiGridListSetItemText(pricecolumn, 12, 2, "24000$", false, false) guiGridListSetItemText(carcolumn, 13, 1, "Infernus", false, false) guiGridListSetItemText(pricecolumn, 13, 2, "40000$", false, false) guiGridListSetItemText(carcolumn, 14, 1, "Hotdog", false, false) guiGridListSetItemText(pricecolumn, 14, 2, "23000$", false, false) guiGridListSetItemText(carcolumn, 15, 1, "Harvester", false, false) guiGridListSetItemText(pricecolumn, 15, 2, "29000$", false, false) guiGridListSetItemText(carcolumn, 16, 1, "Emperor", false, false) guiGridListSetItemText(pricecolumn, 16, 2, "24000$", false, false) guiGridListSetItemText(carcolumn, 17, 1, "Elegy", false, false) guiGridListSetItemText(pricecolumn, 17, 2, "25000$", false, false) guiGridListSetItemText(carcolumn, 18, 1, "Elegant", false, false) guiGridListSetItemText(pricecolumn, 18, 2, "26000$", false, false) guiGridListSetItemText(carcolumn, 19, 1, "Comet", false, false) guiGridListSetItemText(pricecolumn, 19, 2, "29000$", false, false) guiGridListSetItemText(carcolumn, 20, 1, "Cheetah", false, false) guiGridListSetItemText(pricecolumn, 20, 2, "35000$", false, false) guiGridListSetItemText(carcolumn, 21, 1, "Caddy", false, false) guiGridListSetItemText(pricecolumn, 21, 2, "19000$", false, false) guiGridListSetItemText(carcolumn, 22, 1, "Bullet", false, false) guiGridListSetItemText(pricecolumn, 22, 2, "42000$", false, false) guiGridListSetItemText(carcolumn, 23, 1, "Buffalo", false, false) guiGridListSetItemText(pricecolumn, 23, 2, "37000$", false, false) guiGridListSetItemText(carcolumn, 24, 1, "Bravura", false, false) guiGridListSetItemText(pricecolumn, 24, 2, "27500$", false, false) guiGridListSetItemText(carcolumn, 25, 1, "Blade", false, false) guiGridListSetItemText(pricecolumn, 25, 2, "28500$", false, false) guiGridListSetItemText(carcolumn, 26, 1, "Banshee", false, false) guiGridListSetItemText(pricecolumn, 26, 2, "45000$", false, false) guiGridListSetItemText(carcolumn, 27, 1, "Bandito", false, false) guiGridListSetItemText(pricecolumn, 27, 2, "30000$", false, false) guiGridListSetItemText(carcolumn, 28, 1, "Admiral", false, false) guiGridListSetItemText(pricecolumn, 28, 2, "23000$", false, false) GUIEditor.memo[1] = guiCreateMemo(0, 390, 40, 47, "", false, shopgrid) GUIEditor.memo[2] = guiCreateMemo(10, 505, 20, 0, "", false, shopwindows) GUIEditor.memo[3] = guiCreateMemo(10, 417, 277, 88, "Sistema de tienda de autos profesional, \nelige el auto comprarlo y apreta F2\npuedes comprar mas de 2 autos\npuedes cerrarlo, teleportarlo al punto de reparo, etc", false, shopwindows) guiMemoSetReadOnly(GUIEditor.memo[3], true) buy = guiCreateButton(326, 28, 153, 90, "Comprar", false, shopwindows) guiSetFont(buy, "sa-header") GUIEditor.label[1] = guiCreateLabel(313, 444, 187, 51, "Por MultiKiller con Ayuda de \nTigreBlanco\nSaludos de Juramento Server", false, shopwindows) guiSetFont(GUIEditor.label[1], "clear-normal") guiLabelSetColor(GUIEditor.label[1], 17, 255, 0) addEvent ("watchGUI", true) function watchGUI () if (getLocalPlayer() == source) then guiSetVisible (shopwindows, true) showCursor (true) end end addEventHandler ("watchGUI", getRootElement(), watchGUI) function onClientClick (button, state, absoluteX, absoluteYe) if (source == buy) then guiSetVisible (shopwindows, false) showCursor (false) if (guiGridListGetSelectedItem (shopwindows)) then local vehicleName = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 1) local vehicleID = getVehicleModelFromName (vehicleName) local vehicleCost = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 2) triggerServerEvent ("carShopBuy", getLocalPlayer(), vehicleID, vehicleCost, vehicleName) end end end addEventHandler ("onClientGUIClick", getRootElement(), onClientClick) carwindows = guiCreateWindow(398, 193, 463, 396, "Panel de Carro Por MultiKiller", false) guiWindowSetSizable(carwindows, false) guiSetVisible ( carwindows, false ) cargridlist = guiCreateGridList(10, 28, 139, 358, false, carwindows) carcolumn = guiGridListAddColumn(cargridlist, "Autos", 0.9) carrow = guiGridListAddRow(cargridlist) teletransport = guiCreateButton(166, 28, 130, 97, "Teletransportar", false, carwindows) guiSetFont(teletransport, "default-bold-small") guiSetProperty(teletransport, "NormalTextColour", "C8FFFFFF") sell = guiCreateButton(310, 28, 129, 97, "Vender", false, carwindows) guiSetFont(sell, "default-bold-small") guiSetProperty(sell, "NormalTextColour", "C8FFFFFF") lock = guiCreateButton(168, 265, 130, 110, "Cerrar", false, carwindows) guiSetFont(lock, "default-bold-small") guiSetProperty(lock, "NormalTextColour", "C8FFFFFF") lights = guiCreateButton(310, 265, 129, 110, "Luces ON/OFF", false, carwindows) guiSetFont(lights, "default-bold-small") guiSetProperty(lights, "NormalTextColour", "C8FFFFFF") watch = guiCreateButton(168, 140, 128, 105, "Observar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") mark = guiCreateButton(310, 139, 129, 106, "Marcar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") function resourceStart () bindKey ("F2", "down", carPanel) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) function carPanel () panel = guiGetVisible (carwindows) if (panel == true) then guiSetVisible (carwindows, false) showCursor (false) end if (panel == false) then guiSetVisible (carwindows, true) showCursor (true) end end addEvent ("carTeletransport", true) addEvent ("carSell", true) function guiClick (button, state, absoluteX, absoluteY) if (source == teletransport) then triggerServerEvent ("carTeletransport", lp) elseif (source == sell) then triggerServerEvent ("carSell", lp) elseif (source == watch) then triggerServerEvent ("lookCar", lp) elseif (source == lock) then triggerServerEvent ("lockCar", lp) elseif (source == lights) then triggerServerEvent ("lightsCar", lp) end end addEventHandler ("onClientGUIClick", getRootElement(), guiClick) addEventHandler( "onClientGUIClick", getRootElement(), function(vehiclename) if (source == mark) then local v = getElementModel (vehiclename) vehicleBlips[v] = createBlipAttachedTo( v, 27, 1 ) end end ) addEventHandler( "onClientGuiClick", getRootElement(), function(vehiclename) if (source == mark) then local vb = getElementModel (vehiclename) destroyElement( vb[source] ) vb[source] = nil end end ) function vehicleGridlist() if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( cargridlist, guiGridListAddRow ( cargridlist ), carcolumn, getElementModel ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end elseif ( eventName == "onClientGuiClick" ) then triggerServerEvent ("carSell", source) for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end addEventHandler ( "onClientPlayerJoin", root, vehicleGridList ) addEventHandler ( "onClientPlayerQuit", root, vehicleGridList ) end end Server side: carShopMarker = createMarker (2133.59,-1149.29, 23.3, "cylinder", 3, 255, 255, 0, 127) carShopMarker2 = createMarker (562, -1270, 16, "cylinder", 2, 255, 255, 0, 127) carShopMarker3 = createMarker (-1954,299,34,"cylinder",2,255,255,0,127) carShopMarker4 = createMarker (-1663,1208,6,"cylinder",2,255,255,0,127) carShopMarker5 = createMarker (1946,2068,10,"cylinder",2,255,255,0,127) createBlipAttachedTo(carShopMarker,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker2,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker3,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker4,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker5,55,2,0,255,0,0,0,200) addEvent ("watchGUI", true) function markerHit (hitPlayer, matchingDimension) if (source == carShopMarker) or (source == carShopMarker2) or (source == carShopMarker3) or (source == carShopMarker4) or (source == carShopMarker5) then triggerClientEvent ("watchGUI", hitPlayer) end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) addEvent ("carShopBuy", true) addEventHandler ("carShopBuy", getRootElement(), function(id, cost, name) if (getPlayerMoney (source) >= tonumber(cost)) then outputChatBox ("Has comprado un " .. name, source, 0, 255, 0, false) outputChatBox ("Precio: " .. cost, source, 0, 255, 0, false) takePlayerMoney (source, tonumber (cost)) setAccountData (getPlayerAccount (source), "funmodev2-car", tonumber(id)) setAccountData (getPlayerAccount (source), "funmodev2-paintjob", 3) setAccountData (getPlayerAccount (source), "funmodev2-carupg", 0) else outputChatBox ("No tienes suficiente dinero para comprar un" .. name, source, 255, 0, 0, false) end end) addEvent ("carTeletransport", true) addEvent ("carSell", true) function carSpawn () if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then if (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) and (getElementType(getElementData (source, "hisCar")) == "vehicle") then setElementVelocity (getElementData (source, "hisCar"), 0,0,0) setElementPosition (getElementData (source, "hisCar"), 1631.3790283203,-1094.9102783203,23.90625) outputChatBox ("El vehiculo ha sido teletransportado con exito.", source, 0, 255, 0) elseif not (getElementData (source, "hisCar")) then local accountData = getAccountData (getPlayerAccount (source), "funmodev2-car") if (accountData) then vehicleID = getAccountData (getPlayerAccount (source), "funmodev2-car") x,y,z = getElementPosition (source) vehicle = createVehicle (carID, x +2, y, z +1) setElementID (vehicle, getAccountName (getPlayerAccount(source))) setElementData (source, "hisCar", vehicle) outputChatBox ("El vehiculo ha sido teletransportado con exito.", source, 255, 0, 0) if (getAccountData (getPlayerAccount(source), "funmodev2-carupg")) then local upgrades = nil local upgrades = {} local upgrades = getAccountData (getPlayerAccount(source), "funmodev2-carupg") for i,v in ipairs (upgrades) do addVehicleUpgrade (vehicle, v) end end if (getAccountData (getPlayerAccount(source), "funmodev2-paintjob")) then local paintjob = getAccountData (getPlayerAccount(source), "funmodev2-paintjob") setVehiclePaintjob (vehicle, paintjob) end if (getAccountData (getPlayerAccount(source), "funmodev2-carcolor1")) and (getAccountData (getPlayerAccount(source), "funmodev2-carcolor2")) then local c1 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor1") local c2 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor2") setVehicleColor (vehicle, c1,c2,0,0) end else outputChatBox ("No tienes ningun vehiculo.", source, 255, 0, 0) end else outputChatBox ("Ya estas en un vehiculo!", source, 255, 0, 0) end end end addEventHandler ("carSpawn", getRootElement(), carSpawn) function carDestroy (cost) if not (isGuestAccount (getPlayerAccount (source))) then if (isPedInVehicle (source)) then if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then local sell = getPlayerAccount (source), "hisCar", tonumber(cost) givePlayerMoney (sell (source, "hisCar")) destroyElement (getPedOccupiedVehicle (source)) removeElementData (source, "hisCar") outputChatBox ("Vehiculo vendido, te han sido devueltos " ..cost, source, 0, 255, 0) else outputChatBox ("Este no es tu vehiculo!", source, 255, 0, 0) end elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then car=getElementData(source, "hisCar") cancelEvent() outputchatbox ("Este carro es gratis y no se puede vender", source, 255, 0, 0) end end end addEventHandler ("carSell", getRootElement(), carDestroy) function lightsSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleOverrideLights(veh) ~= 2) then setVehicleOverrideLights(veh, 2) outputChatBox ("Las luces del vehiculo han sido encendidas.", source, 0, 0, 255) elseif (getVehicleOverrideLights(veh) ~= 1) then setVehicleOverrideLights(veh, 1) outputChatBox ("Las luces del vehiculo han sido apagadas.", source, 0, 0, 255) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lightsCar",true) addEventHandler("lightsCar",getRootElement(),lightsSwitch) function lockSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if not (isVehicleLocked (veh)) then setVehicleLocked (veh, true) setVehicleDoorsUndamageable (veh, true) setVehicleDoorState (veh, 0, 0) setVehicleDoorState (veh, 1, 0) setVehicleDoorState (veh, 2, 0) setVehicleDoorState (veh, 3, 0) outputChatBox ("El vehiculo ha sido cerrado.", source, 255, 0, 0) elseif (isVehicleLocked (veh)) then setVehicleLocked (veh, false) setVehicleDoorsUndamageable (veh, false) outputChatBox ("El vehiculo ha sido abierto.", source, 0, 255, 0) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lockCar",true) addEventHandler("lockCar",getRootElement(),lockSwitch ) addEventHandler ("onVehicleStartEnter", getRootElement(), function(player, seat, jacked, door) if (isVehicleLocked (source) == true) then local mannetjeNaam = getAccountName (getPlayerAccount (player)) local autoNaam = getElementID (source) if (mannetjeNaam == autoNaam) then setVehicleLocked (source, false) outputChatBox ("El vehiculo ha sido abierto!", player, 255, 0, 0, false) end end end) addEventHandler ("onVehicleExplode", getRootElement(), function() local theOwner = getAccountName (getPlayerAccount(getPlayerFromName (getElementID (source)))) if (theOwner) then removeElementData (theOwner, "hisCar") end end) addEventHandler ("onPlayerQuit", getRootElement(), function(quitType, reason, responsibleElement) if (getElementData (source, "hisCar")) then blowVehicle (getElementData (source, "hisCar")) removeElementData (source, "hisCar") end end) addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ), function () for i,v in ipairs (getElementsByType ("player")) do if (getElementData (v, "hisCar")) then setElementHealth (getElementData (v, "hisCar"), 0) removeElementData (v, "hisCar") end end end ) function destroyOnExplode () setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode) I have changed and added pricecolumn and carcolumn, but the shop doesn't have the gridlist Link to comment
Castillo Posted May 20, 2013 Share Posted May 20, 2013 shopgrid = guiCreateGridList(9, 21, 288, 390, false, shopwindows) That grid list is not showing up? because I don't see any problem with it, so it should work, maybe you used wrong position to create it. Link to comment
Lucario Posted May 20, 2013 Author Share Posted May 20, 2013 Sorry e.e the gridlist shows, but the prices and the cars doesnt shows Link to comment
Jacob Lenn Posted May 20, 2013 Share Posted May 20, 2013 U must create row first and after set row's names. You can create them by using loop guiGridListAddRow Link to comment
Lucario Posted May 20, 2013 Author Share Posted May 20, 2013 local lp = getLocalPlayer() GUIEditor = { label = {}, button = {}, window = {}, gridlist = {}, memo = {} } shopwindows = guiCreateWindow(352, 156, 510, 519, "Tienda de autos por MultiKiller", false) guiWindowSetMovable(shopwindows, false) guiWindowSetSizable(shopwindows, false) guiSetVisible ( shopwindows, false ) shopgrid = guiCreateGridList(9, 21, 288, 390, false, shopwindows) carcolumn = guiGridListAddColumn(shopgrid, "Autos", 0.4) carprice = guiGridListAddColumn(shopgrid, "Precios", 0.4) row = guiGridListAddRow (shopgrid) guiGridListSetItemText(shopgrid, row, carcolumn, "Virgo", false, false) guiGridListSetItemText(shopgrid, row, carprice, "20000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Uranus", false, false) guiGridListSetItemText(shopgrid, row, carprice, "27000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Turismo", false, false) guiGridListSetItemText(shopgrid, row, carprice, "25000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Super GT", false, false) guiGridListSetItemText(shopgrid, row, carprice, "30000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Sultan", false, false) guiGridListSetItemText(shopgrid, row, carprice, "40000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Euros", false, false) guiGridListSetItemText(shopgrid, row, carprice, "30000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Romero", false, false) guiGridListSetItemText(shopgrid, row, carprice, "30000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Regina", false, false) guiGridListSetItemText(shopgrid, row, carprice, "28000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Rancher", false, false) guiGridListSetItemText(shopgrid, row, carprice, "20000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Primo", false, false) guiGridListSetItemText(shopgrid, row, carprice, "23500$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Mr.Whooper", false, false) guiGridListSetItemText(shopgrid, row, carprice, "25000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Kart", false, false) guiGridListSetItemText(shopgrid, row, carprice, "18000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Jester", false, false) guiGridListSetItemText(shopgrid, row, carprice, "24000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Infernus", false, false) guiGridListSetItemText(shopgrid, row, carprice, "40000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Hotdog", false, false) guiGridListSetItemText(shopgrid, row, carprice, "23000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Harvester", false, false) guiGridListSetItemText(shopgrid, row, carprice, "29000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Emperor", false, false) guiGridListSetItemText(shopgrid, row, carprice, "24000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Elegy", false, false) guiGridListSetItemText(shopgrid, row, carprice, "25000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Elegant", false, false) guiGridListSetItemText(shopgrid, row, carprice, "26000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Comet", false, false) guiGridListSetItemText(shopgrid, row, carprice, "29000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Cheetah", false, false) guiGridListSetItemText(shopgrid, row, carprice, "35000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Caddy", false, false) guiGridListSetItemText(shopgrid, row, carprice, "19000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Bullet", false, false) guiGridListSetItemText(shopgrid, row, carprice, "42000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Buffalo", false, false) guiGridListSetItemText(shopgrid, row, carprice, "37000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Bravura", false, false) guiGridListSetItemText(shopgrid, row, carprice, "27500$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Blade", false, false) guiGridListSetItemText(shopgrid, row, carprice, "28500$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Banshee", false, false) guiGridListSetItemText(shopgrid, row, carprice, "45000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Bandito", false, false) guiGridListSetItemText(shopgrid, row, carprice, "30000$", false, false) guiGridListSetItemText(shopgrid, row, carcolumn, "Admiral", false, false) guiGridListSetItemText(shopgrid, row, carprice, "23000$", false, false) GUIEditor.memo[1] = guiCreateMemo(0, 390, 40, 47, "", false, shopgrid) GUIEditor.memo[2] = guiCreateMemo(10, 505, 20, 0, "", false, shopwindows) GUIEditor.memo[3] = guiCreateMemo(10, 417, 277, 88, "Sistema de tienda de autos profesional, \nelige el auto comprarlo y apreta F2\npuedes comprar mas de 2 autos\npuedes cerrarlo, teleportarlo al punto de reparo, etc", false, shopwindows) guiMemoSetReadOnly(GUIEditor.memo[3], true) buy = guiCreateButton(326, 28, 153, 90, "Comprar", false, shopwindows) guiSetFont(buy, "sa-header") GUIEditor.label[1] = guiCreateLabel(313, 444, 187, 51, "Por MultiKiller con Ayuda de \nTigreBlanco\nSaludos de Juramento Server", false, shopwindows) guiSetFont(GUIEditor.label[1], "clear-normal") guiLabelSetColor(GUIEditor.label[1], 17, 255, 0) function watchGUI () if (getLocalPlayer() == source) then guiSetVisible (shopwindows, true) showCursor (true) end end addEvent ("watchGUI", true) addEventHandler ("watchGUI", getRootElement(), watchGUI) function onClientClick (button, state, absoluteX, absoluteYe) if (source == buy) then guiSetVisible (shopwindows, false) showCursor (false) if (guiGridListGetSelectedItem (shopwindows)) then local vehicleName = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 1) local vehicleID = getVehicleModelFromName (vehicleName) local vehicleCost = guiGridListGetItemText (shopgrid, guiGridListGetSelectedItem (shopgrid), 2) triggerServerEvent ("carShopBuy", getLocalPlayer(), vehicleID, vehicleCost, vehicleName) end end end addEventHandler ("onClientGUIClick", getRootElement(), onClientClick) carwindows = guiCreateWindow(398, 193, 463, 396, "Panel de Carro Por MultiKiller", false) guiWindowSetSizable(carwindows, false) guiSetVisible ( carwindows, false ) cargridlist = guiCreateGridList(10, 28, 139, 358, false, carwindows) carcolumn = guiGridListAddColumn(cargridlist, "Autos", 0.9) carrow = guiGridListAddRow(cargridlist) teletransport = guiCreateButton(166, 28, 130, 97, "Teletransportar", false, carwindows) guiSetFont(teletransport, "default-bold-small") guiSetProperty(teletransport, "NormalTextColour", "C8FFFFFF") sell = guiCreateButton(310, 28, 129, 97, "Vender", false, carwindows) guiSetFont(sell, "default-bold-small") guiSetProperty(sell, "NormalTextColour", "C8FFFFFF") lock = guiCreateButton(168, 265, 130, 110, "Cerrar", false, carwindows) guiSetFont(lock, "default-bold-small") guiSetProperty(lock, "NormalTextColour", "C8FFFFFF") lights = guiCreateButton(310, 265, 129, 110, "Luces ON/OFF", false, carwindows) guiSetFont(lights, "default-bold-small") guiSetProperty(lights, "NormalTextColour", "C8FFFFFF") watch = guiCreateButton(168, 140, 128, 105, "Observar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") mark = guiCreateButton(310, 139, 129, 106, "Marcar", false, carwindows) guiSetFont(watch, "default-bold-small") guiSetProperty(watch, "NormalTextColour", "C8FFFFFF") function resourceStart () bindKey ("F2", "down", carPanel) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) function carPanel () panel = guiGetVisible (carwindows) if (panel == true) then guiSetVisible (carwindows, false) showCursor (false) end if (panel == false) then guiSetVisible (carwindows, true) showCursor (true) end end addEvent ("carTeletransport", true) addEvent ("carSell", true) function guiClick (button, state, absoluteX, absoluteY) if (source == teletransport) then triggerServerEvent ("carTeletransport", lp) elseif (source == sell) then triggerServerEvent ("carSell", lp) elseif (source == watch) then triggerServerEvent ("lookCar", lp) elseif (source == lock) then triggerServerEvent ("lockCar", lp) elseif (source == lights) then triggerServerEvent ("lightsCar", lp) end end addEventHandler ("onClientGUIClick", getRootElement(), guiClick) addEventHandler( "onClientGUIClick", getRootElement(), function(vehiclename) if (source == mark) then local v = getElementModel (vehiclename) vehicleBlips[v] = createBlipAttachedTo( v, 27, 1 ) end end ) addEventHandler( "onClientGuiClick", getRootElement(), function(vehiclename) if (source == mark) then local vb = getElementModel (vehiclename) destroyElement( vb[source] ) vb[source] = nil end end ) function vehicleGridlist() if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( cargridlist, guiGridListAddRow ( cargridlist ), carcolumn, getElementModel ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end elseif ( eventName == "onClientGuiClick" ) then triggerServerEvent ("carSell", source) for carrow = 0, guiGridListGetRowCount ( cargridlist ) do if ( guiGridListGetItemText ( cargridlist, carrow, carcolumn ) == getElementModel ( source ) ) then guiGridListRemoveRow ( cargridlist, carrow ) end end addEventHandler ( "onClientPlayerJoin", root, vehicleGridList ) addEventHandler ( "onClientPlayerQuit", root, vehicleGridList ) end end Now only can buy the admiral Link to comment
Sasu Posted May 20, 2013 Share Posted May 20, 2013 You must create rows for every one. Link to comment
Jacob Lenn Posted May 20, 2013 Share Posted May 20, 2013 local cars = { {"Name", 1000}, {--again name, --again price } } for k,v in ipairs(cars) do local row = guiAddRow(shopgrid) guiGridListSetItemText(shopgrid, row, carcolumn, v[1], false, false) guiGridListSetItemText(shopgrid, row, carprice, v[2].."$", false, false) end I think sth like dat, but i can be wrong. 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