-stolka- Posted September 12, 2014 Share Posted September 12, 2014 the debug report error line 7 of server but the clien doesn't even dispay the name of the weapon ( for now there is only one weapon ) server local ammuMarker1 = createMarker(295.30, -38.15, 1000.51, "cylinder", 2,180, 180, 180, 180 ) setElementInterior( ammuMarker1, 1 ) local vehicles = {} function spawnVeh(id, price) if ( getPlayerMoney( source ) >= tonumber( price ) ) then outputChatBox( tostring( id ), source ) takePlayerMoney( source, tonumber( price ) ) giveWeapon(source, id, 90 ) end end addEvent("buyGunForPlayer",true) addEventHandler("buyGunForPlayer", root, spawnVeh) function showAmmuGui(hitPlayer) if hitPlayer and getElementType(hitPlayer) == "player" then triggerClientEvent (hitPlayer,"showAmmuGUI",getRootElement(),hitPlayer) end end addEventHandler("onMarkerHit",ammuMarker1,showAmmuGui) client guiWindowSetSizable( wndAmmu, false ) guiWindowSetMovable( wndAmmu, false ) guns = { {"m4", 500}, } gridAmmu = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, wndAmmu) guiGridListAddColumn(gridAmmu, "Guns", 0.85) guiGridListAddColumn(gridAmmu, "Price", 0.85) for i,gun in ipairs(guns) do row = guiGridListAddRow(gridAmmu) -- guiGridListSetItemText(gridAmmu, row, 1, tostring(guns[1]), false, false) guiGridListSetItemData(gridAmmu, row, 1, tostring(guns[2])) end function buyGun() local row, col = guiGridListGetSelectedItem(gridAmmu) if (row and col and row ~= -1 and col ~= -1) then local gun = tostring(guiGridListGetItemData(gridAmmu, row, 0)) local price = tonumber(guiGridListGetItemData(gridAmmu, row, 1)) if (( price ~= "" ) and ( gun ~= "" )) then triggerServerEvent("buyGunForPlayer", localPlayer, gun, price) end end end addEventHandler("onClientGUIClick", buyGunBtn, buyGun, false) function closeAmmuGui() if (source == cancelGunBtn) then guiSetVisible(wndAmmu,false) showCursor(false) end end addEventHandler("onClientGUIClick", cancelGunBtn, closeAmmuGui) function showGUIp() guiSetVisible(wndAmmu,true) showCursor(true) end addEvent("showAmmuGUI",true) addEventHandler("showAmmuGUI", getRootElement(), showGUIp) Link to comment
TAPL Posted September 12, 2014 Share Posted September 12, 2014 guiWindowSetSizable( wndAmmu, false ) guiWindowSetMovable( wndAmmu, false ) guns = { {"m4", 500}, } gridAmmu = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, wndAmmu) guiGridListAddColumn(gridAmmu, "Guns", 0.85) guiGridListAddColumn(gridAmmu, "Price", 0.85) for i,gun in ipairs(guns) do row = guiGridListAddRow(gridAmmu) -- guiGridListSetItemText(gridAmmu, row, 1, tostring(gun[1]), false, false) -- It's gun not guns. -- guiGridListSetItemData(gridAmmu, row, 1, tostring(gun[2])) -- It's gun not guns and data not needed since you already have Price column. guiGridListSetItemText(gridAmmu, row, 2, tostring(gun[2]), false, false) end function buyGun() local row, col = guiGridListGetSelectedItem(gridAmmu) if (row and col and row ~= -1 and col ~= -1) then -- local gun = tostring(guiGridListGetItemData(gridAmmu, row, 0)) -- Wrong column ID and you need text not data. -- local price = tonumber(guiGridListGetItemData(gridAmmu, row, 1)) -- Wrong column ID and you need text not data. local gun = tostring(guiGridListGetItemText(gridAmmu, row, 1)) local price = tonumber(guiGridListGetItemText(gridAmmu, row, 2)) if (( price ~= "" ) and ( gun ~= "" )) then triggerServerEvent("buyGunForPlayer", localPlayer, getWeaponIDFromName(gun), price) -- You need to get the weapon ID from the weapon name. end end end addEventHandler("onClientGUIClick", buyGunBtn, buyGun, false) function closeAmmuGui() if (source == cancelGunBtn) then guiSetVisible(wndAmmu,false) showCursor(false) end end addEventHandler("onClientGUIClick", cancelGunBtn, closeAmmuGui) function showGUIp() guiSetVisible(wndAmmu,true) showCursor(true) end addEvent("showAmmuGUI",true) addEventHandler("showAmmuGUI", getRootElement(), showGUIp) 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