here is the full client script
Weapons = {
"Shotgun",
"Sawn-Off",
"SPAZ-12" }
Price = {
"$2400",
"$4800",
"$6600"
}
function createWindow ( )
local sWidth, sHeight = guiGetScreenSize ( )
local Width, Height = 400, 325
local X = (sWidth/2) - (Width/2)
local Y = (sHeight/2) - (Height/2)
buyWindow = guiCreateWindow ( X, Y, Width, Height, "Shop", false )
buyButton = guiCreateButton ( 0, 275, 175, 100, "Buy", false, buyWindow )
buyButton1 = guiCreateButton ( 215, 275, 175, 100, "Close", false, buyWindow )
buyGridlist = guiCreateGridList ( 0, 20, 575, 250, false, buyWindow )
guiGridListAddColumn ( buyGridlist, "Weapons", 0.5 )
guiGridListAddColumn ( buyGridlist, "Price", 0.45 )
for key, itemName in pairs ( Weapons ) do
local row = guiGridListAddRow ( buyGridlist )
guiGridListSetItemText ( buyGridlist, row, 1, itemName, false, false )
end
row = 0
for key, itemName in pairs ( Price ) do
guiGridListSetItemText ( buyGridlist, row, 2, itemName, false, false )
row = row + 1
guiSetVisible ( buyWindow, false )
end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement (), createWindow )
function buttonClicks ( button, state )
if button == "left" and state == "up" then
if getElementType ( source ) == "gui-button" then
triggerEvent ("onWindowButtonClicked", source, getElementData ( buyWindow, "itemID" ) )
end
end
end
addEventHandler ( "onClientGUIClick", getRootElement ( ), buttonClicks, true )
addCommandHandler ("shop", function ()
guiSetVisible ( buyWindow, true )
showCursor ( true,true )
end)
function buyWindowFunctions ( )
if ( source == buyButton1 ) then
guiSetVisible ( buyWindow, false )
showCursor ( false,false )
elseif ( source == buyButton ) then
triggerServerEvent ("giveWeaponToPlayer", localPlayer, 30, 30 )
triggerServerEvent ("takePlayerMoney", localPlayer, 2400 )
end
end
addEventHandler ("onClientGUIClick", root, buyWindowFunctions )