-- client side:
local items =
{
[ "Melee" ] = { {1,0,1},{5,0,1},{6,0,1},{8,0,1} },
[ "Handguns" ] = { {23,300,100},{22,400,100},{24,500,100} },
[ "Shotguns" ] = { {25,1000,100},{26,1500,100},{27,1700,100} },
[ "Sub-Machine" ] = { {28,2000,100},{32,2100,100},{29,2200,100} },
[ "Machine Guns" ] = { {30,2500,100},{31,3000,100} },
[ "Rifles" ] = { {33,3500,100},{34,5500,100} },
[ "Projectiles" ] = { {16,15000,15},{39,500,1},{46,0,1} },
[ "Skills" ] = { {"Colt-45 Skill",250,1,69},{"Silenced-Pistol Skill",250,1,70},{"Desert-Eagle Skill",250,1,71},{"Shotgun Skill",1000,1,72},{"Sawed-off Skill",1500,1,73},{"Spaz-12 Skill",1500,1,74},{"Uzi Skill",1500,1,75},{"MP5 Skill",1500,1,76},{"AK-47 Skill",1750,1,77},{"M4 Skill",2000,1,78},{"Sniper Skill",2000,1,79} },
[ "Health" ] = { }
}
shopWindow = guiCreateWindow(470, 206, 449, 326,"Shop Panel",false)
guiSetVisible (shopWindow, false)
guiSetAlpha(shopWindow,0.65)
guiWindowSetSizable(shopWindow,false)
itemsGrid = guiCreateGridList(134, 25, 305, 171,false,shopWindow)
guiGridListSetSelectionMode(itemsGrid,0)
guiGridListAddColumn(itemsGrid,"Name",0.4)
guiGridListAddColumn(itemsGrid,"Price $",0.3)
guiGridListAddColumn(itemsGrid,"Amount",0.2)
gridCho = guiCreateGridList(12, 25, 116, 264, false, shopWindow)
gridchoColumn = guiGridListAddColumn(gridCho,"Chose",0.85)
guiGridListSetSelectionMode ( gridCho, 0 )
AboutMemo = guiCreateMemo(136, 204, 303, 85, "", false, shopWindow)
guiSetAlpha(itemsGrid,1)
buyItem = guiCreateButton(280, 297, 100, 20, "Buy Item",false,shopWindow)
closeButton = guiCreateButton(400, 297, 37, 18, "X",false, shopWindow)
for cat, data in pairs ( items ) do
local row = guiGridListAddRow ( gridCho )
guiGridListSetItemText ( gridCho, row, 1, tostring ( cat ), false, true )
end
addEventHandler ( "onClientGUIClick", guiRoot,
function ( )
if ( source == closeButton ) then
guiSetVisible ( shopWindow, false )
showCursor ( false )
elseif ( source == gridCho ) then
local row, col = guiGridListGetSelectedItem ( source )
if ( row and col and row ~= -1 and col ~= -1 ) then
local category = guiGridListGetItemText ( source, row, 1 )
guiGridListClear ( itemsGrid )
if ( items [ category ] ) then
for _, item in ipairs ( items [ category ] ) do
local row = guiGridListAddRow ( itemsGrid )
local name = ( category == "Skills" and item [ 1 ] or category == "Health" and item [ 1 ] or getWeaponNameFromID ( item [ 1 ] ) )
guiGridListSetItemText ( itemsGrid, row, 1, tostring ( name ), false, false )
guiGridListSetItemText ( itemsGrid, row, 2, tostring ( item [ 2 ] ), false, false )
guiGridListSetItemText ( itemsGrid, row, 3, tostring ( item [ 3 ] ), false, false )
guiGridListSetItemData ( itemsGrid, row, 1, item [ 4 ] )
guiGridListSetItemData ( itemsGrid, row, 2, category )
end
end
end
elseif ( source == buyItem ) then
local row, col = guiGridListGetSelectedItem ( itemsGrid )
if ( row and col and row ~= -1 and col ~= -1 ) then
local category = guiGridListGetItemData ( itemsGrid, row, 2 )
local name = guiGridListGetItemText ( itemsGrid, row, 1 )
local price = guiGridListGetItemText ( itemsGrid, row, 2 )
local amount = guiGridListGetItemText ( itemsGrid, row, 3 )
if ( category == "Skills" ) then
local id = guiGridListGetItemData ( itemsGrid, row, 1 )
triggerServerEvent ( "skillBuy", localPlayer, name, id, tonumber ( price ) )
elseif ( category == "Health" ) then
-- TODO
else
triggerServerEvent ( "weapBuy", localPlayer, name, price, amount )
end
end
end
end
)
function viewGUI ( )
if ( localPlayer == source ) then
guiSetVisible ( shopWindow, true )
showCursor ( true )
end
end
addEvent ( "viewGUI", true )
addEventHandler ( "viewGUI", getRootElement(), viewGUI )
-- server side:
function showGui (hitPlayer, matchingDimension)
triggerClientEvent ( hitPlayer, "viewGUI", hitPlayer)
end
---------------------- Area 51
addEventHandler("onMarkerHit",createMarker(209.81819152832, 1859.4178466797, 12,"cylinder",2,187,5,175,170),showGui)
local blip = createBlip(209.81819152832, 1859.4178466797, 150, 6, 0, 0, 0, 0, 0, 0, 1000)
---------------------- Sillent Killers
addEventHandler("onMarkerHit",createMarker(-1379.8349609375, 493.78100585938, 20.200000762939,"cylinder",2,187,5,175,170),showGui)
local blip = createBlip(-1379.8349609375, 493.78100585938, 20.200000762939, 6, 0, 0, 0, 0, 0, 0, 1000)
---------------------- Ghost Town
addEventHandler("onMarkerHit",createMarker(3986.9541015625, -2089.8010253906, 34.1,"cylinder",2,187,5,175,170),showGui)
local blip = createBlip(3986.9541015625, -2089.8010253906, 34.1, 6, 0, 0, 0, 0, 0, 0, 1000)
---------------------- Vertigo
addEventHandler("onMarkerHit",createMarker(1618.8389892578, 995.63299560547, 11.5,"cylinder",2,187,5,175,170),showGui)
local blip = createBlip(1618.8389892578, 995.63299560547, 11.5, 6, 0, 0, 0, 0, 0, 0, 1000)
---------------------- Zombie Base
addEventHandler("onMarkerHit",createMarker(1726.7969970703, -3491.5029296875, 20.170000076294,"cylinder",2,187,5,175,170),showGui)
local blip = createBlip(1726.7969970703, -3491.5029296875, 20.170000076294, 6, 0, 0, 0, 0, 0, 0, 1000)
addEvent ( "weapBuy", true )
addEventHandler ( "weapBuy", getRootElement(),
function ( name, price, ammo )
local price = tonumber ( price )
if ( getPlayerMoney ( client ) >= price ) then
outputChatBox ( "You bought: ".. name .." for $".. price .."!", client, 0, 255, 0 )
takePlayerMoney ( client, price )
giveWeapon ( client, getWeaponIDFromName ( name ), tonumber ( ammo ), true )
else
outputChatBox ( "You don't have enough money!", client, 255, 0, 0 )
end
end
)
function skillBuyPlayer ( name, id, price )
if ( getPlayerMoney ( client ) >= price ) then
takePlayerMoney ( client, price )
setPedStat ( client, id, 999 )
outputChatBox ( "You bought: ".. name .." for $".. price .."!", client, 0, 255, 0 )
else
outputChatBox ( "You don't have enough money!", client, 255, 0, 0 )
end
end
addEvent ( "skillBuy", true )
addEventHandler ( "skillBuy", getRootElement(), skillBuyPlayer )
I made it for you this time, but don't expect me to do it again with anything else.