DRW Posted July 16, 2015 Share Posted July 16, 2015 Hello, I've got a weapon shop script and it's pretty awesome, because it makes a gridlist where you can select the weapons you want. But I want to change a gridlist row name to another, but since this script uses guiGridListGetItemText to retrieve the weapon selected, changing the rows' names makes the script to not work properly because it can't retrieve a weapon from the name "Sub machine gun" for example. How can I make it work without breaking the script when changing the rows' names? Clientside guns = { {22, 7}, {24, 30}, {28, 14}, {29, 17}, {32, 11}, {25, 40}, {26, 50}, {27, 65}, {30, 22}, {31, 27}, {33, 73}, {34, 60}, {23, 80}, {44, 500}, {45, 500}, {46, 500}, {8, 200000}, } addEventHandler( "onClientResourceStart", getRootElement( ), function ( startedRes ) if startedRes == getThisResource() then createGunMenu() end end ); m = { } local rootNode = xmlLoadFile( "shops.xml" ) local markNodes = xmlNodeGetChildren(rootNode) for i,node in ipairs(markNodes) do local attr = xmlNodeGetAttributes( node ) local theMarker = createMarker(attr["posX"],attr["posY"],attr["posZ"],"corona",2,255,0,0,255) setElementInterior(theMarker,attr["interior"]) if attr["pedSkinID"] then thePed = createPed( attr["pedSkinID"], attr["pedX"],attr["pedY"],attr["pedZ"] ) setElementInterior(thePed,attr["interior"]) setElementRotation(thePed,0,0,attr["pedR"]) end m[i] = { theMarker, thePed } end function showGunMenu(hitPlayer) if hitPlayer == localPlayer then for i,v in ipairs(m) do if source == v[1] then g_px, g_py, g_pz = getElementPosition(v[2]) playSFX3D ( "spc_fa", 13, math.random(60,72), g_px, g_py, g_pz ) end end guiSetVisible(guiWdw, true) triggerServerEvent ("span",localPlayer) showCursor(true) end end for i,v in ipairs(m) do addEventHandler("onClientMarkerHit",v[1],showGunMenu) end function createGunMenu() guiWdw = guiCreateWindow ( 379, 208, 602, 370, "Buhonero", false ) gunList = guiCreateGridList ( 0.05, 0.05, 0.3, 0.9, true, guiWdw ) colGun = guiGridListAddColumn( gunList, "Gun", 0.5 ) colCost = guiGridListAddColumn( gunList, "Costbullet", 0.5 ) btnDiscard = guiCreateButton(0.4, 0.8, 0.15, 0.15, "Descartar", true, guiWdw) btnClose = guiCreateButton(0.6, 0.8, 0.15, 0.15, "Cerrar", true, guiWdw) btnBuy = guiCreateButton(0.8, 0.8, 0.15, 0.15, "Comprar/Buy.", true, guiWdw) btnAdd = guiCreateButton(0.8, 0.1, 0.15, 0.1, "Añadir/Add", true, guiWdw) editAmount = guiCreateEdit (0.4, 0.1, 0.35, 0.1, "Ammo", true, guiWdw) guiWindowSetSizable( guiWdw, false) guiSetVisible(guiWdw, false) addEventHandler("onClientGUIClick", btnClose, clientSubmitClose, false) addEventHandler("onClientGUIClick", btnDiscard, clientSubmitDiscard, false) addEventHandler("onClientGUIClick", btnBuy, clientSubmitBuy, false) addEventHandler("onClientGUIClick", btnAdd, clientSubmitCart, false) for p,v in ipairs(guns) do row = guiGridListAddRow ( gunList ) guiGridListSetItemText ( gunList, row, colGun, getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( gunList, row, colCost, v[2], false, false ) end cart = guiCreateGridList ( 0.4, 0.25, 0.55, 0.5, true, guiWdw ) colOrdGun = guiGridListAddColumn( cart, "Arma pedida", 0.33 ) colOrdAmmo = guiGridListAddColumn( cart, "Ammo", 0.33 ) colOrdCost = guiGridListAddColumn( cart, "Coste", 0.33 ) end addEvent ("guichanger",true) addEventHandler ("guichanger", getRootElement(), function() guiSetText (guiWdw,"Weapons Dealer") guiSetText (btnDiscard,"Discard") guiSetText (btnClose,"Close") guiSetText (btnAdd,"Add") guiSetText (btnBuy,"Buy") guiSetText (colOrdGun,"Weapon") guiSetText (colOrdAmmo,"Ammo") guiSetText (colOrdCost,"Cost") end) addEvent ("guichanger2",true) addEventHandler ("guichanger2", getRootElement(), function() guiSetText (guiWdw,"Vendedor de armas") guiSetText (btnDiscard,"Descartar") guiSetText (btnClose,"Cerrar") guiSetText (btnAdd,"Añadir") guiSetText (btnBuy,"Comprar") guiSetText (colOrdGun,"Arma") guiSetText (colOrdAmmo,"Munición") guiSetText (colOrdCost,"Coste") end) function clientSubmitBuy(button,state) if button == "left" and state == "up" then local rowCount = guiGridListGetRowCount ( cart ) local ordCost = 0 for i=0,rowCount-1,1 do ordCost = ordCost + guiGridListGetItemText ( cart, i, 3 ) end local playerMoney = getPlayerMoney() if playerMoney < ordCost then outputChatBox( "No te lo puedes permitir, necesitas $" .. ordCost .. "!" ) else guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) for i=0,rowCount-1 do local ordGunName = guiGridListGetItemText ( cart, 0, 1 ) local ordGunAmmo = guiGridListGetItemText ( cart, 0, 2 ) local ordGunCost = guiGridListGetItemText ( cart, 0, 3 ) triggerServerEvent( "onClientGiveWeapon", getLocalPlayer(), ordGunName, ordGunAmmo, ordGunCost ) guiGridListRemoveRow(cart,0) end if rowCount > 0 then playSFX3D ( "spc_fa", 13, math.random(8,17), g_px, g_py, g_pz ) end end end end function clientSubmitCart(button,state) if button == "left" and state == "up" then local gunName = guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 1 ) local ammo = guiGetText(editAmount) local cost = ammo * guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 2 ) guiSetText ( editAmount, "" ) local row = guiGridListAddRow ( cart ) guiGridListSetItemText ( cart, row, colOrdGun, gunName, false, false ) guiGridListSetItemText ( cart, row, colOrdAmmo, ammo, false, false ) guiGridListSetItemText ( cart, row, colOrdCost, cost, false, false ) end end function clientSubmitClose(button,state) if button == "left" and state == "up" then guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) local rowCount = guiGridListGetRowCount(cart) if rowCount > 0 then for i=0,rowCount-1 do guiGridListRemoveRow(cart,0) end end end end function clientSubmitDiscard(button,state) if button == "left" and state == "up" then local ar,ac = guiGridListGetSelectedItem(cart) guiGridListRemoveRow ( cart, ar ) end end Link to comment
GTX Posted July 16, 2015 Share Posted July 16, 2015 Check overrideName table. Put real gun names in first index, in the second, your desired name. guns = { {22, 7}, {24, 30}, {28, 14}, {29, 17}, {32, 11}, {25, 40}, {26, 50}, {27, 65}, {30, 22}, {31, 27}, {33, 73}, {34, 60}, {23, 80}, {44, 500}, {45, 500}, {46, 500}, {8, 200000}, } overrideName = { {"Sub machine gun", "Your name"} } addEventHandler( "onClientResourceStart", getRootElement( ), function ( startedRes ) if startedRes == getThisResource() then createGunMenu() end end ); m = { } local rootNode = xmlLoadFile( "shops.xml" ) local markNodes = xmlNodeGetChildren(rootNode) for i,node in ipairs(markNodes) do local attr = xmlNodeGetAttributes( node ) local theMarker = createMarker(attr["posX"],attr["posY"],attr["posZ"],"corona",2,255,0,0,255) setElementInterior(theMarker,attr["interior"]) if attr["pedSkinID"] then thePed = createPed( attr["pedSkinID"], attr["pedX"],attr["pedY"],attr["pedZ"] ) setElementInterior(thePed,attr["interior"]) setElementRotation(thePed,0,0,attr["pedR"]) end m[i] = { theMarker, thePed } end function showGunMenu(hitPlayer) if hitPlayer == localPlayer then for i,v in ipairs(m) do if source == v[1] then g_px, g_py, g_pz = getElementPosition(v[2]) playSFX3D ( "spc_fa", 13, math.random(60,72), g_px, g_py, g_pz ) end end guiSetVisible(guiWdw, true) triggerServerEvent ("span",localPlayer) showCursor(true) end end for i,v in ipairs(m) do addEventHandler("onClientMarkerHit",v[1],showGunMenu) end function createGunMenu() guiWdw = guiCreateWindow ( 379, 208, 602, 370, "Buhonero", false ) gunList = guiCreateGridList ( 0.05, 0.05, 0.3, 0.9, true, guiWdw ) colGun = guiGridListAddColumn( gunList, "Gun", 0.5 ) colCost = guiGridListAddColumn( gunList, "Costbullet", 0.5 ) btnDiscard = guiCreateButton(0.4, 0.8, 0.15, 0.15, "Descartar", true, guiWdw) btnClose = guiCreateButton(0.6, 0.8, 0.15, 0.15, "Cerrar", true, guiWdw) btnBuy = guiCreateButton(0.8, 0.8, 0.15, 0.15, "Comprar/Buy.", true, guiWdw) btnAdd = guiCreateButton(0.8, 0.1, 0.15, 0.1, "Añadir/Add", true, guiWdw) editAmount = guiCreateEdit (0.4, 0.1, 0.35, 0.1, "Ammo", true, guiWdw) guiWindowSetSizable( guiWdw, false) guiSetVisible(guiWdw, false) addEventHandler("onClientGUIClick", btnClose, clientSubmitClose, false) addEventHandler("onClientGUIClick", btnDiscard, clientSubmitDiscard, false) addEventHandler("onClientGUIClick", btnBuy, clientSubmitBuy, false) addEventHandler("onClientGUIClick", btnAdd, clientSubmitCart, false) for p,v in ipairs(guns) do row = guiGridListAddRow ( gunList ) for i=1, #overrideName do if getWeaponNameFromID(v[1]) == overrideName[i][1] then guiGridListSetItemText ( gunList, row, colGun, overrideName[i][2], false, false ) else guiGridListSetItemText ( gunList, row, colGun, getWeaponNameFromID(v[1]), false, false ) end end guiGridListSetItemText ( gunList, row, colCost, v[2], false, false ) end cart = guiCreateGridList ( 0.4, 0.25, 0.55, 0.5, true, guiWdw ) colOrdGun = guiGridListAddColumn( cart, "Arma pedida", 0.33 ) colOrdAmmo = guiGridListAddColumn( cart, "Ammo", 0.33 ) colOrdCost = guiGridListAddColumn( cart, "Coste", 0.33 ) end addEvent ("guichanger",true) addEventHandler ("guichanger", getRootElement(), function() guiSetText (guiWdw,"Weapons Dealer") guiSetText (btnDiscard,"Discard") guiSetText (btnClose,"Close") guiSetText (btnAdd,"Add") guiSetText (btnBuy,"Buy") guiSetText (colOrdGun,"Weapon") guiSetText (colOrdAmmo,"Ammo") guiSetText (colOrdCost,"Cost") end) addEvent ("guichanger2",true) addEventHandler ("guichanger2", getRootElement(), function() guiSetText (guiWdw,"Vendedor de armas") guiSetText (btnDiscard,"Descartar") guiSetText (btnClose,"Cerrar") guiSetText (btnAdd,"Añadir") guiSetText (btnBuy,"Comprar") guiSetText (colOrdGun,"Arma") guiSetText (colOrdAmmo,"Munición") guiSetText (colOrdCost,"Coste") end) function clientSubmitBuy(button,state) if button == "left" and state == "up" then local rowCount = guiGridListGetRowCount ( cart ) local ordCost = 0 for i=0,rowCount-1,1 do ordCost = ordCost + guiGridListGetItemText ( cart, i, 3 ) end local playerMoney = getPlayerMoney() if playerMoney < ordCost then outputChatBox( "No te lo puedes permitir, necesitas $" .. ordCost .. "!" ) else guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) for i=0,rowCount-1 do local ordGunName = guiGridListGetItemText ( cart, 0, 1 ) local ordGunAmmo = guiGridListGetItemText ( cart, 0, 2 ) local ordGunCost = guiGridListGetItemText ( cart, 0, 3 ) triggerServerEvent( "onClientGiveWeapon", getLocalPlayer(), ordGunName, ordGunAmmo, ordGunCost ) guiGridListRemoveRow(cart,0) end if rowCount > 0 then playSFX3D ( "spc_fa", 13, math.random(8,17), g_px, g_py, g_pz ) end end end end function clientSubmitCart(button,state) if button == "left" and state == "up" then local gunName = guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 1 ) local ammo = guiGetText(editAmount) local cost = ammo * guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 2 ) guiSetText ( editAmount, "" ) local row = guiGridListAddRow ( cart ) guiGridListSetItemText ( cart, row, colOrdGun, gunName, false, false ) guiGridListSetItemText ( cart, row, colOrdAmmo, ammo, false, false ) guiGridListSetItemText ( cart, row, colOrdCost, cost, false, false ) end end function clientSubmitClose(button,state) if button == "left" and state == "up" then guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) local rowCount = guiGridListGetRowCount(cart) if rowCount > 0 then for i=0,rowCount-1 do guiGridListRemoveRow(cart,0) end end end end function clientSubmitDiscard(button,state) if button == "left" and state == "up" then local ar,ac = guiGridListGetSelectedItem(cart) guiGridListRemoveRow ( cart, ar ) end end Link to comment
DRW Posted July 16, 2015 Author Share Posted July 16, 2015 Check overrideName table. Put real gun names in first index, in the second, your desired name. Gives error at the line 5 of the serverside part, also, it only changes the last name I put on the overrideName index overrideName = { {"Colt 45","Colt"}, {"Deagle","Desert Eagle"}, {"Uzi","Micro UZI"}, {"MP5","SMG"}, --It only changes this one, no matter what weapon is, if it's the last it will be the only on that changes its name, and it also makes the same effect as changing the names with guiGridListSetItemText } Serverside g_Root = getRootElement() resourceRoot = getResourceRootElement(getThisResource()) function giveClientWeapon(weapon, ammo, cost) giveWeapon(client, getWeaponIDFromName(weapon), ammo ) takePlayerMoney( client, cost ) end addEvent( "onClientGiveWeapon", true ) addEventHandler("onClientGiveWeapon", g_Root, giveClientWeapon) addEvent ("span", true) addEventHandler ("span", getRootElement(), function() if getAccountData (getPlayerAccount(source),"englishidioma","true") then triggerClientEvent (source, "guichanger", source) else triggerClientEvent (source, "guichanger2", source) end end ) Link to comment
GTX Posted July 16, 2015 Share Posted July 16, 2015 (edited) guns = { {22, 7}, {24, 30}, {28, 14}, {29, 17}, {32, 11}, {25, 40}, {26, 50}, {27, 65}, {30, 22}, {31, 27}, {33, 73}, {34, 60}, {23, 80}, {44, 500}, {45, 500}, {46, 500}, {8, 200000}, } overrideName = { {"Sub machine gun", "Your name"} } addEventHandler( "onClientResourceStart", getRootElement( ), function ( startedRes ) if startedRes == getThisResource() then createGunMenu() end end ); m = { } local rootNode = xmlLoadFile( "shops.xml" ) local markNodes = xmlNodeGetChildren(rootNode) for i,node in ipairs(markNodes) do local attr = xmlNodeGetAttributes( node ) local theMarker = createMarker(attr["posX"],attr["posY"],attr["posZ"],"corona",2,255,0,0,255) setElementInterior(theMarker,attr["interior"]) if attr["pedSkinID"] then thePed = createPed( attr["pedSkinID"], attr["pedX"],attr["pedY"],attr["pedZ"] ) setElementInterior(thePed,attr["interior"]) setElementRotation(thePed,0,0,attr["pedR"]) end m[i] = { theMarker, thePed } end function showGunMenu(hitPlayer) if hitPlayer == localPlayer then for i,v in ipairs(m) do if source == v[1] then g_px, g_py, g_pz = getElementPosition(v[2]) playSFX3D ( "spc_fa", 13, math.random(60,72), g_px, g_py, g_pz ) end end guiSetVisible(guiWdw, true) triggerServerEvent ("span",localPlayer) showCursor(true) end end for i,v in ipairs(m) do addEventHandler("onClientMarkerHit",v[1],showGunMenu) end function createGunMenu() guiWdw = guiCreateWindow ( 379, 208, 602, 370, "Buhonero", false ) gunList = guiCreateGridList ( 0.05, 0.05, 0.3, 0.9, true, guiWdw ) colGun = guiGridListAddColumn( gunList, "Gun", 0.5 ) colCost = guiGridListAddColumn( gunList, "Costbullet", 0.5 ) btnDiscard = guiCreateButton(0.4, 0.8, 0.15, 0.15, "Descartar", true, guiWdw) btnClose = guiCreateButton(0.6, 0.8, 0.15, 0.15, "Cerrar", true, guiWdw) btnBuy = guiCreateButton(0.8, 0.8, 0.15, 0.15, "Comprar/Buy.", true, guiWdw) btnAdd = guiCreateButton(0.8, 0.1, 0.15, 0.1, "Añadir/Add", true, guiWdw) editAmount = guiCreateEdit (0.4, 0.1, 0.35, 0.1, "Ammo", true, guiWdw) guiWindowSetSizable( guiWdw, false) guiSetVisible(guiWdw, false) addEventHandler("onClientGUIClick", btnClose, clientSubmitClose, false) addEventHandler("onClientGUIClick", btnDiscard, clientSubmitDiscard, false) addEventHandler("onClientGUIClick", btnBuy, clientSubmitBuy, false) addEventHandler("onClientGUIClick", btnAdd, clientSubmitCart, false) for p,v in ipairs(guns) do row = guiGridListAddRow ( gunList ) for i=1, #overrideName do if getWeaponNameFromID(v[1]) == overrideName[i][1] then guiGridListSetItemText ( gunList, row, colGun, overrideName[i][2], false, false ) break else guiGridListSetItemText ( gunList, row, colGun, getWeaponNameFromID(v[1]), false, false ) end end guiGridListSetItemText ( gunList, row, colCost, v[2], false, false ) end cart = guiCreateGridList ( 0.4, 0.25, 0.55, 0.5, true, guiWdw ) colOrdGun = guiGridListAddColumn( cart, "Arma pedida", 0.33 ) colOrdAmmo = guiGridListAddColumn( cart, "Ammo", 0.33 ) colOrdCost = guiGridListAddColumn( cart, "Coste", 0.33 ) end addEvent ("guichanger",true) addEventHandler ("guichanger", getRootElement(), function() guiSetText (guiWdw,"Weapons Dealer") guiSetText (btnDiscard,"Discard") guiSetText (btnClose,"Close") guiSetText (btnAdd,"Add") guiSetText (btnBuy,"Buy") guiSetText (colOrdGun,"Weapon") guiSetText (colOrdAmmo,"Ammo") guiSetText (colOrdCost,"Cost") end) addEvent ("guichanger2",true) addEventHandler ("guichanger2", getRootElement(), function() guiSetText (guiWdw,"Vendedor de armas") guiSetText (btnDiscard,"Descartar") guiSetText (btnClose,"Cerrar") guiSetText (btnAdd,"Añadir") guiSetText (btnBuy,"Comprar") guiSetText (colOrdGun,"Arma") guiSetText (colOrdAmmo,"Munición") guiSetText (colOrdCost,"Coste") end) function clientSubmitBuy(button,state) if button == "left" and state == "up" then local rowCount = guiGridListGetRowCount ( cart ) local ordCost = 0 for i=0,rowCount-1,1 do ordCost = ordCost + guiGridListGetItemText ( cart, i, 3 ) end local playerMoney = getPlayerMoney() if playerMoney < ordCost then outputChatBox( "No te lo puedes permitir, necesitas $" .. ordCost .. "!" ) else guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) for i=0,rowCount-1 do local ordGunName = guiGridListGetItemText ( cart, 0, 1 ) local ordGunAmmo = guiGridListGetItemText ( cart, 0, 2 ) local ordGunCost = guiGridListGetItemText ( cart, 0, 3 ) for i=1, #overrideName do if overrideName[i][2] == ordGunName then ordGunName = overrideName[i][1] break end end triggerServerEvent( "onClientGiveWeapon", getLocalPlayer(), ordGunName, ordGunAmmo, ordGunCost ) guiGridListRemoveRow(cart,0) end if rowCount > 0 then playSFX3D ( "spc_fa", 13, math.random(8,17), g_px, g_py, g_pz ) end end end end function clientSubmitCart(button,state) if button == "left" and state == "up" then local gunName = guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 1 ) local ammo = guiGetText(editAmount) local cost = ammo * guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 2 ) guiSetText ( editAmount, "" ) local row = guiGridListAddRow ( cart ) guiGridListSetItemText ( cart, row, colOrdGun, gunName, false, false ) guiGridListSetItemText ( cart, row, colOrdAmmo, ammo, false, false ) guiGridListSetItemText ( cart, row, colOrdCost, cost, false, false ) end end function clientSubmitClose(button,state) if button == "left" and state == "up" then guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) local rowCount = guiGridListGetRowCount(cart) if rowCount > 0 then for i=0,rowCount-1 do guiGridListRemoveRow(cart,0) end end end end function clientSubmitDiscard(button,state) if button == "left" and state == "up" then local ar,ac = guiGridListGetSelectedItem(cart) guiGridListRemoveRow ( cart, ar ) end end Edited July 16, 2015 by Guest Link to comment
DRW Posted July 16, 2015 Author Share Posted July 16, 2015 guns = { {22, 7}, {24, 30}, {28, 14}, {29, 17}, {32, 11}, {25, 40}, {26, 50}, {27, 65}, {30, 22}, {31, 27}, {33, 73}, {34, 60}, {23, 80}, {44, 500}, {45, 500}, {46, 500}, {8, 200000}, } overrideName = { {"Sub machine gun", "Your name"} } addEventHandler( "onClientResourceStart", getRootElement( ), function ( startedRes ) if startedRes == getThisResource() then createGunMenu() end end ); m = { } local rootNode = xmlLoadFile( "shops.xml" ) local markNodes = xmlNodeGetChildren(rootNode) for i,node in ipairs(markNodes) do local attr = xmlNodeGetAttributes( node ) local theMarker = createMarker(attr["posX"],attr["posY"],attr["posZ"],"corona",2,255,0,0,255) setElementInterior(theMarker,attr["interior"]) if attr["pedSkinID"] then thePed = createPed( attr["pedSkinID"], attr["pedX"],attr["pedY"],attr["pedZ"] ) setElementInterior(thePed,attr["interior"]) setElementRotation(thePed,0,0,attr["pedR"]) end m[i] = { theMarker, thePed } end function showGunMenu(hitPlayer) if hitPlayer == localPlayer then for i,v in ipairs(m) do if source == v[1] then g_px, g_py, g_pz = getElementPosition(v[2]) playSFX3D ( "spc_fa", 13, math.random(60,72), g_px, g_py, g_pz ) end end guiSetVisible(guiWdw, true) triggerServerEvent ("span",localPlayer) showCursor(true) end end for i,v in ipairs(m) do addEventHandler("onClientMarkerHit",v[1],showGunMenu) end function createGunMenu() guiWdw = guiCreateWindow ( 379, 208, 602, 370, "Buhonero", false ) gunList = guiCreateGridList ( 0.05, 0.05, 0.3, 0.9, true, guiWdw ) colGun = guiGridListAddColumn( gunList, "Gun", 0.5 ) colCost = guiGridListAddColumn( gunList, "Costbullet", 0.5 ) btnDiscard = guiCreateButton(0.4, 0.8, 0.15, 0.15, "Descartar", true, guiWdw) btnClose = guiCreateButton(0.6, 0.8, 0.15, 0.15, "Cerrar", true, guiWdw) btnBuy = guiCreateButton(0.8, 0.8, 0.15, 0.15, "Comprar/Buy.", true, guiWdw) btnAdd = guiCreateButton(0.8, 0.1, 0.15, 0.1, "Añadir/Add", true, guiWdw) editAmount = guiCreateEdit (0.4, 0.1, 0.35, 0.1, "Ammo", true, guiWdw) guiWindowSetSizable( guiWdw, false) guiSetVisible(guiWdw, false) addEventHandler("onClientGUIClick", btnClose, clientSubmitClose, false) addEventHandler("onClientGUIClick", btnDiscard, clientSubmitDiscard, false) addEventHandler("onClientGUIClick", btnBuy, clientSubmitBuy, false) addEventHandler("onClientGUIClick", btnAdd, clientSubmitCart, false) for p,v in ipairs(guns) do row = guiGridListAddRow ( gunList ) for i=1, #overrideName do if getWeaponNameFromID(v[1]) == overrideName[i][1] then guiGridListSetItemText ( gunList, row, colGun, overrideName[i][2], false, false ) break else guiGridListSetItemText ( gunList, row, colGun, getWeaponNameFromID(v[1]), false, false ) end end guiGridListSetItemText ( gunList, row, colCost, v[2], false, false ) end cart = guiCreateGridList ( 0.4, 0.25, 0.55, 0.5, true, guiWdw ) colOrdGun = guiGridListAddColumn( cart, "Arma pedida", 0.33 ) colOrdAmmo = guiGridListAddColumn( cart, "Ammo", 0.33 ) colOrdCost = guiGridListAddColumn( cart, "Coste", 0.33 ) end addEvent ("guichanger",true) addEventHandler ("guichanger", getRootElement(), function() guiSetText (guiWdw,"Weapons Dealer") guiSetText (btnDiscard,"Discard") guiSetText (btnClose,"Close") guiSetText (btnAdd,"Add") guiSetText (btnBuy,"Buy") guiSetText (colOrdGun,"Weapon") guiSetText (colOrdAmmo,"Ammo") guiSetText (colOrdCost,"Cost") end) addEvent ("guichanger2",true) addEventHandler ("guichanger2", getRootElement(), function() guiSetText (guiWdw,"Vendedor de armas") guiSetText (btnDiscard,"Descartar") guiSetText (btnClose,"Cerrar") guiSetText (btnAdd,"Añadir") guiSetText (btnBuy,"Comprar") guiSetText (colOrdGun,"Arma") guiSetText (colOrdAmmo,"Munición") guiSetText (colOrdCost,"Coste") end) function clientSubmitBuy(button,state) if button == "left" and state == "up" then local rowCount = guiGridListGetRowCount ( cart ) local ordCost = 0 for i=0,rowCount-1,1 do ordCost = ordCost + guiGridListGetItemText ( cart, i, 3 ) end local playerMoney = getPlayerMoney() if playerMoney < ordCost then outputChatBox( "No te lo puedes permitir, necesitas $" .. ordCost .. "!" ) else guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) for i=0,rowCount-1 do local ordGunName = guiGridListGetItemText ( cart, 0, 1 ) local ordGunAmmo = guiGridListGetItemText ( cart, 0, 2 ) local ordGunCost = guiGridListGetItemText ( cart, 0, 3 ) for i=1, #overrideName do if overrideName[i][2] == ordGunName then ordGunName = [i][1] break end end triggerServerEvent( "onClientGiveWeapon", getLocalPlayer(), ordGunName, ordGunAmmo, ordGunCost ) guiGridListRemoveRow(cart,0) end if rowCount > 0 then playSFX3D ( "spc_fa", 13, math.random(8,17), g_px, g_py, g_pz ) end end end end function clientSubmitCart(button,state) if button == "left" and state == "up" then local gunName = guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 1 ) local ammo = guiGetText(editAmount) local cost = ammo * guiGridListGetItemText ( gunList, guiGridListGetSelectedItem(gunList), 2 ) guiSetText ( editAmount, "" ) local row = guiGridListAddRow ( cart ) guiGridListSetItemText ( cart, row, colOrdGun, gunName, false, false ) guiGridListSetItemText ( cart, row, colOrdAmmo, ammo, false, false ) guiGridListSetItemText ( cart, row, colOrdCost, cost, false, false ) end end function clientSubmitClose(button,state) if button == "left" and state == "up" then guiSetText ( editAmount, "" ) guiSetInputEnabled(false) guiSetVisible(guiWdw, false) showCursor(false) local rowCount = guiGridListGetRowCount(cart) if rowCount > 0 then for i=0,rowCount-1 do guiGridListRemoveRow(cart,0) end end end end function clientSubmitDiscard(button,state) if button == "left" and state == "up" then local ar,ac = guiGridListGetSelectedItem(cart) guiGridListRemoveRow ( cart, ar ) end end Error at line 147, unexpected symbol near [ Tried to solve it but it gives me other errors, so I don't know Link to comment
GTX Posted July 16, 2015 Share Posted July 16, 2015 I'm sorry for that. I edited my previous post. 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