Jump to content

[HELP] Vehicle Shop System


India

Recommended Posts

I have a item shop system, weapons,stuff,vehicles etc..

I want the car to appear when i click on the any car. Please help me i rly need it   

Picture:

Spoiler

mta-screen-2021-02-18-16-17-07.png

client.lua

local screenW, screenH = guiGetScreenSize()
local timer
local tables = {gridlist = {},window = {},button = {},label = {},column = {}}
local category = {
	{"Birincil Silahlar"},
	{"İkincil Silahlar"},
	{"Özel Eşya"},
	{"Mermiler"},
	{"Yiyecek/İçecek"},
	{"Diğerleri"},
	{"Araçlar"},
}

local items = {
	["Araçlar"] = {
		{vehicleName = "Infernus",vehicleID = 411,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 5000},
		{vehicleName = "Turismo",vehicleID = 451,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 4500},
		{vehicleName = "Elegy",vehicleID = 562,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 4000},		
		{vehicleName = "Cadrona",vehicleID = 527,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3200},
	    {vehicleName = "Huntley",vehicleID = 579,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3100},
		{vehicleName = "Mesa",vehicleID = 500,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3070},
		{vehicleName = "Bullet",vehicleID = 541,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3000},
		{vehicleName = "Greenwood",vehicleID = 492,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2900},
		{vehicleName = "Slamvan",vehicleID = 535,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2880},
		{vehicleName = "Burrito",vehicleID = 482,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2500},
		{vehicleName = "Phoenix",vehicleID = 603,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2600},
		{vehicleName = "Sultan",vehicleID = 560,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3500},
		{vehicleName = "Flash",vehicleID = 565,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3610},
		{vehicleName = "Banshee",vehicleID = 429,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3450},
		{vehicleName = "Admiral",vehicleID = 445,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3000},
		{vehicleName = "Esperanto",vehicleID = 419,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3116},
		{vehicleName = "Super-GT",vehicleID = 506,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3310},
		{vehicleName = "Elegant",vehicleID = 507,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3350},	
		{vehicleName = "Oceanic",vehicleID = 467,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2700},
		{vehicleName = "Premier",vehicleID = 426,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2450},		
		{vehicleName = "Towtruck",vehicleID = 525,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 4000},		
		{vehicleName = "Clover",vehicleID = 542,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2320},
        {vehicleName = "Huntley",vehicleID = 579,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3200},
		{vehicleName = "Cheetah",vehicleID = 415,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3600},
		{vehicleName = "Bloodring",vehicleID = 504,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2855},
		{vehicleName = "Landstalker",vehicleID = 400,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2740},	
		{vehicleName = "Yosemite",vehicleID = 554,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2402},
		{vehicleName = "Sabre",vehicleID = 475,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2390},	
		{vehicleName = "Savanna",vehicleID = 567,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 2350},
		{vehicleName = "Bobcat",vehicleID = 422,engine = 1,tires = 4,parts = 1,slots = 1,price_buy = 2500},
		{vehicleName = "Police LS",vehicleID = 596,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3600},		
		{vehicleName = "FBI Rancher",vehicleID = 490,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3800},		
		{vehicleName = "Patriot",vehicleID = 470,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3300},
		{vehicleName = "Barracks",vehicleID = 433,engine = 1,tires = 6,parts = 1,slots=40,price_buy = 3485},
		{vehicleName = "Enforcer",vehicleID = 427,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3450},
		{vehicleName = "SWAT",vehicleID = 601,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 4000},		
		{vehicleName = "Coach",vehicleID = 437,engine = 1,tires = 6,parts = 1,slots=40,price_buy = 3200},		
        {vehicleName = "Tractor",vehicleID = 531,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 1500},			
        {vehicleName = "Ambulance",vehicleID = 416,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3260},
		{vehicleName = "NRG-500",vehicleID = 522,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 4300},
		{vehicleName = "PCJ-600",vehicleID = 461,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 4000},
		{vehicleName = "Freeway",vehicleID = 463,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3500},		
		{vehicleName = "Sanchez",vehicleID = 468,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 2600},
		{vehicleName = "ATV",vehicleID = 471,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 3000},		

--		{vehicleName = "Maverick",vehicleID = 587,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 400},
--		{vehicleName = "Dodo",vehicleID = 593,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 400},
--		{vehicleName = "Police Maverick",vehicleID = 497,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 400},
--		{vehicleName = "Reefer",vehicleID = 453,engine = 1,tires = 2,parts = 1,slots=40,price_buy = 400},
--		{vehicleName = "Coast",vehicleID = 472,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 400},
--		{vehicleName = "",vehicleID = ,engine = 1,tires = 4,parts = 1,slots=40,price_buy = 400},	
		
	},
	["Birincil Silahlar"] = {
		{itemName = "M4A1 CCO", slots = 3,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "HK G36", slots = 3,price_buy = 800,price_sell = 400,number = 1},
		{itemName = "RPK-74", slots = 3,price_buy = 820,price_sell = 410,number = 1},
		{itemName = "АК-74М", slots = 3,price_buy = 950,price_sell = 475,number = 1},
		{itemName = "AS50", slots = 3,price_buy = 960,price_sell = 480,number = 1},
		{itemName = "M2000 CheyTac", slots = 3,price_buy = 970,price_sell = 485,number = 1},
		{itemName = "Milkor MGL", slots = 3,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "DMR", slots = 3,price_buy = 950,price_sell = 475,number = 1},
		{itemName = "PPSh-41", slots = 3,price_buy = 950,price_sell = 475,number = 1},
		{itemName = "MG36", slots = 3,price_buy = 910,price_sell = 455,number = 1},
		{itemName = "AKS Gold", slots = 3,price_buy = 1500,price_sell = 750,number = 1},
		{itemName = "VSS", slots = 3,price_buy = 930,price_sell = 465,number = 1},
		{itemName = "M107", slots = 3,price_buy = 970,price_sell = 485,number = 1},
		{itemName = "VSSK", slots = 3,price_buy = 750,price_sell = 375,number = 1},
		{itemName = "M249 SAW", slots = 3,price_buy = 785,price_sell = 392,number = 1},
		{itemName = "MK48", slots = 3,price_buy = 790,price_sell = 395,number = 1},
		{itemName = "AKM", slots = 3,price_buy = 740,price_sell = 370,number = 1},
		{itemName = "M240", slots = 3,price_buy = 792,price_sell = 396,number = 1},
		{itemName = "PKM", slots = 3,price_buy = 690,price_sell = 345,number = 1},
		{itemName = "AS Val", slots = 3,price_buy = 600,price_sell = 300,number = 1},
		{itemName = "AK-12", slots = 3,price_buy = 610,price_sell = 305,number = 1},
		{itemName = "AUG", slots = 3,price_buy = 782,price_sell = 391,number = 1},
		{itemName = "FN-SCARL", slots = 3,price_buy = 800,price_sell = 400,number = 1},
		{itemName = "FN-SCARL SD", slots = 3,price_buy = 850,price_sell = 425,number = 1},
		{itemName = "AK-74Y (PBC-5)", slots = 3,price_buy = 860,price_sell = 430,number = 1},
--		{itemName = "M4A1 HWS M203", slots = 3,price_buy = 12700,price_sell = 0,number = 1},
		{itemName = "AK 74 GP-25", slots = 3,price_buy = 890,price_sell = 445,number = 1},
	},
	["İkincil Silahlar"] = {
		{itemName = "Revolver",slots = 2,price_buy = 500,price_sell = 250,number = 1},
		{itemName = "Makarov PM",slots = 2,price_buy = 500,price_sell = 250,number = 1},
	},
	["Özel Eşya"] = {
		{itemName = "El Bombası",slots = 2,price_buy = 800,price_sell = 400,number = 1},
	},
	["Mermiler"] = {
		{itemName = "12,7х108 мм.M107",slots = 0.020,price_buy = 700,price_sell = 350,number = 7},
		{itemName = "AUG Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 35},
		{itemName = "M2000 Mermisi",slots = 0.020,price_buy = 700,price_sell = 350,number = 17},
		{itemName = "PPSh-41 Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 70},
		{itemName = "MG36 Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 200},
		{itemName = "FN Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 20},
		{itemName = "AK Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 30},
		{itemName = "M4 Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 30},
		{itemName = "VSSK Mermisi",slots = 0.020,price_buy = 700,price_sell = 350,number = 15},
		{itemName = "G36 Mermisi",slots = 0.010,price_buy = 600,price_sell = 300,number = 30},
		{itemName = "AKM Mermisi",slots = 0.010,price_buy = 650,price_sell = 325,number = 35},
		{itemName = "M249 SAW Mermisi",slots = 0.010,price_buy = 770,price_sell = 385,number = 150},
		{itemName = "MK48 Mermisi",slots = 0.010,price_buy = 800,price_sell = 400,number = 100},
		{itemName = "AS50 Mermisi",slots = 0.020,price_buy = 700,price_sell = 350,number = 7},
		{itemName = "DMR Mermisi",slots = 0.010,price_buy = 700,price_sell = 350,number = 20},
		{itemName = "VSS Mermisi",slots = 0.010,price_buy = 700,price_sell = 350,number = 20},
		{itemName = "7,62mm NATO.M240",slots = 0.010,price_buy = 600,price_sell = 300,number = 100},
		{itemName = "7,62×39 мм.PKM",slots = 0.010,price_buy = 600,price_sell = 300,number = 200},
		{itemName = "Revolver Mermisi",slots = 0.010,price_buy = 400,price_sell = 200,number = 17},
		{itemName = "Makarov Mermisi",slots = 0.010,price_buy = 400,price_sell = 200,number = 8},
	},
	["Yiyecek/İçecek"] = {
		{itemName = "Su Matarası",slots = 1,price_buy = 100,price_sell = 50,number = 1},
		{itemName = "Spagetti Konservesi (Kapalı)",slots = 1,price_buy = 210,price_sell = 105,number = 1},
		{itemName = "Sardalya Konservesi (Kapalı)",slots = 1,price_buy = 210,price_sell = 105,number = 1},
		{itemName = "Fasulye Konservesi (Kapalı)",slots = 1,price_buy = 210,price_sell = 105,number = 1},
		{itemName = "Spagetti Konservesi (Açık)",slots = 1,price_buy = 320,price_sell = 160,number = 1},
		{itemName = "Fasulye Konservesi (Açık)",slots = 1,price_buy = 320,price_sell = 160,number = 1},
		{itemName = "Sardalya Konservesi (Açık)",slots = 1,price_buy = 320,price_sell = 160,number = 1},
		{itemName = "Muz",slots = 1,price_buy = 250,price_sell = 125,number = 1},
		{itemName = "Salatalık",slots = 1,price_buy = 200,price_sell = 100,number = 1},
		{itemName = "Elma",slots = 1,price_buy = 200,price_sell = 100,number = 1},
		{itemName = "İçecek: Pepsi",slots = 1,price_buy = 250,price_sell = 125,number = 1},
		{itemName = "İçecek: Coca-Cola",slots = 1,price_buy = 250,price_sell = 125,number = 1},
		-- {itemName = "İçecek: Mountain Dew",slots = 1,price_buy = 250,price_sell = 0,number = 1},
		{itemName = "Kızarmış Et",slots = 2,price_buy = 320,price_sell = 160,number = 1},
	},
	["Diğerleri"] = {
		{itemName = "C.E.L.L Skini",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "^Merle Dixon Skin",slots = 1,price_buy = 600,price_sell = 300,number = 1},
		{itemName = "Haydut Skin",slots = 1,price_buy = 700,price_sell = 350,number = 1},
		{itemName = "^Darly Dixon Skin",slots = 1,price_buy = 600,price_sell = 300,number = 1},
		{itemName = "Bayan Skini",slots = 1,price_buy = 730,price_sell = 365,number = 1},
		{itemName = "Bayan Skini 2",slots = 1,price_buy = 730,price_sell = 365,number = 1},
		{itemName = "Asker Skini",slots = 1,price_buy = 750,price_sell = 375,number = 1},
		{itemName = "Keskin Nişancı Skini",slots = 1,price_buy = 800,price_sell = 400,number = 1},
		{itemName = "Sivil Skini",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Ghost Skini",slots = 1,price_buy = 745,price_sell = 373,number = 1},
		{itemName = "Ghost Skini 2",slots = 1,price_buy = 745,price_sell = 373,number = 1},
		{itemName = "Bayan Kamuflajlı Keskin N. Skini",slots = 1,price_buy = 800,price_sell = 400,number = 1},
		{itemName = "Kamuflajlı Suikastçı Skini",slots = 1,price_buy = 820,price_sell = 410,number = 1},
		{itemName = "Kar Maskeli Avcı Skini",slots = 1,price_buy = 850,price_sell = 425,number = 1},
		{itemName = "Çöl Kamuflajlı Keskin N. Skini",slots = 1,price_buy = 870,price_sell = 435,number = 1},
		{itemName = "Özel Kuvvetler Skini",slots = 1,price_buy = 890,price_sell = 445,number = 1},
		{itemName = "Eğitimli Suikastçı Skini",slots = 1,price_buy = 920,price_sell = 460,number = 1},
		
		{itemName = "Motorsiklet Kaskı [97 Zırh]",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Kamuflajlı Kask [97 Zırh]",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Kask: Koyu Yeşil [70 Zırh]",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Kask: C.E.L.L [90 Zırh]",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Şapka: Çim Kamuflajlı [0 Zırh]",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Yelek: Orman Kamuflajı [0 Zırh]",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Bere: Siyah Komando [0 Zırh]",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Bere: Kırmızı Komando [0 Zırh]",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Şapka: Asker [0 Zırh]",slots = 1,price_buy = 320,price_sell = 160,number = 1},
		{itemName = "Yelek: Kurşun Geçirmez [30 Zırh]",slots = 1,price_buy = 500,price_sell = 250,number = 1},
		{itemName = "Yelek: Balistik [60 Zırh]",slots = 1,price_buy = 550,price_sell = 275,number = 1},
		{itemName = "Yelek: Orman Kamuflajlı [50 Zırh]",slots = 1,price_buy = 520,price_sell = 260,number = 1},
		{itemName = "Yelek: KK-912 [80 Zırh]",slots = 1,price_buy = 900,price_sell = 450,number = 1},
		
		{itemName = "Bandaj",slots = 1,price_buy = 200,price_sell = 100,number = 1},
		{itemName = "İlk Yardım Çantası",slots = 2,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Isı Dengeleyici",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Ağrı Kesici",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Morfin",slots = 1,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Antibiyotik",slots = 1,price_buy = 310,price_sell = 155,number = 1},
		{itemName = "Odun",slots = 3,price_buy = 280,price_sell = 140,number = 1},
		{itemName = "İşaret Işığı",slots = 1,price_buy = 400,price_sell = 200,number = 1},
		{itemName = "Boş Benzin Bidonu",slots = 2,price_buy = 500,price_sell = 250,number = 1},
		{itemName = "Dolu Benzin Bidonu (20LT)",slots = 2,price_buy = 700,price_sell = 350,number = 1},
		{itemName = "Dikenli Tel",slots = 2,price_buy = 1000,price_sell = 500,number = 1},
		{itemName = "Çadır",slots = 2,price_buy = 1000,price_sell = 500,number = 1},
		{itemName = "Büyük Çadır",slots = 2,price_buy = 1000,price_sell = 500,number = 1},
		{itemName = "Konseve Açacağı",slots = 1,price_buy = 500,price_sell = 250,number = 1},
		
		{itemName = "Çoçuk Çantası [16]",slots = 0.5,price_buy = 100,price_sell = 50,number = 1},
		{itemName = "Küçük Çanta [20]",slots = 0.5,price_buy = 150,price_sell = 75,number = 1},
		{itemName = "Kamuflajlı Çanta [22]",slots = 0.5,price_buy = 200,price_sell = 100,number = 1},
		{itemName = "Ev Yapımı Çanta [30]",slots = 0.5,price_buy = 230,price_sell = 115,number = 1},
		{itemName = "Ortaboy Çanta [38]",slots = 0.5,price_buy = 260,price_sell = 130,number = 1},
		{itemName = "Kamp Çantası [50]",slots = 0.5,price_buy = 280,price_sell = 140,number = 1},
		{itemName = "Kamp Çantası [50] (Bataklık)",slots = 0.5,price_buy = 320,price_sell = 160,number = 1},
		{itemName = "Kum Desenli Çanta [60]",slots = 0.5,price_buy = 360,price_sell = 180,number = 1},
		{itemName = "Büyükboy Gezi Çantası [75]",slots = 0.5,price_buy = 420,price_sell = 210,number = 1},
		{itemName = "Sivil Askeri Çanta [90]",slots = 0.5,price_buy = 500,price_sell = 250,number = 1},
		{itemName = "Büyükboy Askeri Çanta [130]",slots = 0.5,price_buy = 700,price_sell = 350,number = 1},
		
        {itemName = "Motor",slots = 5,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Benzin Tankı",slots = 3,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Tekerlek",slots = 4,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Gece Görüş Gözlüğü",slots = 0.5,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Isı Görüş Gözlüğü",slots = 0.5,price_buy = 900,price_sell = 450,number = 1},
		{itemName = "Harita",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Çakmak",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Saat",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "GPS",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
		{itemName = "Pusula",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},		
		{itemName = "Alet Çantası",slots = 0.5,price_buy = 600,price_sell = 300,number = 1},
	},
}

addEventHandler("onClientResourceStart",resourceRoot,
function()
	tables.window[1] = guiCreateWindow((screenW - 726) / 2, (screenH - 440) / 2, 726, 440, "", false)
	guiWindowSetSizable(tables.window[1], false)

	tables.gridlist[1] = guiCreateGridList(9, 28, 177, 222, false, tables.window[1])
	tables.column[1] = guiGridListAddColumn(tables.gridlist[1], "Kategori", 0.9)
	tables.gridlist[2] = guiCreateGridList(196, 28, 520, 402, false, tables.window[1])
	guiGridListSetSortingEnabled(tables.gridlist[1],false)
	guiGridListSetSortingEnabled(tables.gridlist[2],false)
	tables.column[2] = guiGridListAddColumn(tables.gridlist[2], "İsim", 0.5)
	tables.column[3] = guiGridListAddColumn(tables.gridlist[2], "Satın Alma Ücreti", 0.1)
	tables.column[4] = guiGridListAddColumn(tables.gridlist[2], "Satma Ücreti", 0.1)
	tables.column[5] = guiGridListAddColumn(tables.gridlist[2], "Adet", 0.1)
	tables.button[1] = guiCreateButton(10, 350, 176, 25, "Satın Al", false, tables.window[1])
	tables.button[2] = guiCreateButton(10, 315, 176, 25, "Sat", false, tables.window[1])
	tables.label[1] = guiCreateLabel(10, 260, 176, 45, "Mevcut Paran: 0$\nPara mağazası: 0$", false, tables.window[1])
	tables.button[3] = guiCreateButton(10, 385, 176, 25, "Kapat", false, tables.window[1])
	for i, data in ipairs(category) do
		local row = guiGridListAddRow(tables.gridlist[1])
		guiGridListSetItemText(tables.gridlist[1],row,tables.column[1],tostring(data[1]),false,false)
	end
	addEventHandler("onClientGUIClick",tables.gridlist[1],
	function()
		if timer and isTimer(timer) then
			outputChatBox("Acele Etme!",255,0,0)
			return
		else
			timer=setTimer(function() timer=nil end,0,1)       --Listede geçiş yapma süresi
		end
		if getPlayerPing(getLocalPlayer())>=150 or getNetworkStats()["packetlossLastSecond"]>=1 then 
			outputChatBox("İnternet Bağlantını Kontrol Et!",255,0,0)
			return
		end
		columnName = guiGridListGetItemText(tables.gridlist[1],guiGridListGetSelectedItem(tables.gridlist[1]),1)
		if columnName then
			guiGridListClear(tables.gridlist[2])
			if columnName ~= "Araçlar" then
				if items[columnName] then
					for i, data in ipairs(items[columnName]) do
						local row = guiGridListAddRow(tables.gridlist[2])
						guiGridListSetItemText(tables.gridlist[2],row,tables.column[2],tostring(data.itemName),false,false)
						guiGridListSetItemText(tables.gridlist[2],row,tables.column[3],tostring(data.price_buy),false,false)
						guiGridListSetItemText(tables.gridlist[2],row,tables.column[4],tostring(data.price_sell),false,false)
						guiGridListSetItemText(tables.gridlist[2],row,tables.column[5],tostring(data.number),false,false)
					end
					guiSetEnabled(tables.button[2],true)
				else
					--outputDebugString("Bu bölümdekiler Satılamaz "Sat" butonu devre dışı.")
				end	
			else
				for i, data in ipairs(items["Araçlar"]) do
					local row = guiGridListAddRow(tables.gridlist[2])
					guiGridListSetItemText(tables.gridlist[2],row,tables.column[2],tostring(data.vehicleName),false,false)
					guiGridListSetItemText(tables.gridlist[2],row,tables.column[3],tostring(data.price_buy),false,false)
					guiGridListSetItemText(tables.gridlist[2],row,tables.column[4],"-",false,false)
					guiGridListSetItemText(tables.gridlist[2],row,tables.column[5],"-",false,false)
				end
				guiSetEnabled(tables.button[2],false)
			end
		end	
	end,false)
	addEventHandler("onClientGUIClick",tables.button[3],function()
		guiSetVisible(tables.window[1],false)
		showCursor(false)
		setElementData(localPlayer,"currentShop",nil)
	end,false)
	addEventHandler("onClientGUIClick",tables.button[1],
	function()
		if timer and isTimer(timer) then
			outputChatBox("Acele Etme!",255,0,0)
			return
		else
			timer=setTimer(function() timer=nil end,1500,1)            --Satın alma butonu süresi
		end
		if getPlayerPing(getLocalPlayer())>=150 or getNetworkStats()["packetlossLastSecond"]>=1 then 
			outputChatBox("İnternet Bağlantını Kontrol Et!",255,0,0)
			return
		end
		local itemName = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1)
		local buyPrice = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),2)
		if buyPrice then
			if delayButtonsInventory then return end	
			if (getElementData(localPlayer,"Para") or 0) - tonumber(buyPrice) >= 0 then
				for _, vehicle in ipairs(items["Araçlar"]) do
					if itemName == vehicle.vehicleName then
						if getElementData(resourceRoot,"serv:time") <= (getElementData(localPlayer,"tick.vehicle") or 0) then
							outputChatBox("10 dakikada bir araç satın alabilirsin!",231,217,176,true)
							return
						end
						triggerServerEvent("shop:spawnVehicle",localPlayer,vehicle.vehicleID,vehicle.engine,vehicle.tires,vehicle.parts,vehicle.slots)
						setElementData(localPlayer,"Para",(getElementData(localPlayer,"Para") or 0) - tonumber(buyPrice))
						setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") + tonumber(buyPrice))
						guiSetText(tables.label[1],"Mevcut Paran: "..tostring(getElementData(localPlayer,"Para") or 0).."$\nMağazanın Parası: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
						return 
					end
				end
				--if getItemSlotsPlus(itemName) then outputChatBox("Envanterin dolu!") return end
				setElementData(localPlayer,"Para",(getElementData(localPlayer,"Para") or 0) - tonumber(buyPrice))
				setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") + tonumber(buyPrice))
				guiSetText(tables.label[1],"Mevcut Paran: "..tostring(getElementData(localPlayer,"Para") or 0).."$\nMağazanın Parası: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
				setElementData(localPlayer,itemName,getElementData(localPlayer,itemName) + returnItemNumber())
				outputChatBox("Eşyayı başarıyla satın aldın!")
				--refreshInventory()
				delayButtonsInventory = true
				setTimer(function() delayButtonsInventory = false end,500,1)
			else
				outputChatBox("Üzgünüm, paran yetmiyor!")
			end
		end	
	end,false)
	addEventHandler("onClientGUIClick",tables.button[2],
	function()
		if timer and isTimer(timer) then
			outputChatBox("Acele Etme!",255,0,0)
			return
		else
			timer=setTimer(function() timer=nil end,1500,1)  --Sat butonu süresi
		end
		if getPlayerPing(getLocalPlayer())>=150 or getNetworkStats()["packetlossLastSecond"]>=1 then 
			outputChatBox("İnternet Bağlantını Kontrol Et!",255,0,0)
			return
		end
		local itemName = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1)
		local sellPrice = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),3)
			for i, data in ipairs(items[columnName]) do
			--if sellPrice then
				if itemName == tostring(data.itemName) then 
					if delayButtonsInventory then return end
					if getElementData(getElementData(localPlayer,"currentShop"),"shop:money") - tonumber(data.price_sell) >= 0 then
						if getElementData(localPlayer,itemName) < returnItemNumber() then outputChatBox("Bu eşyaya sahip değilsin veya sende yeteri kadar bu eşyadan yok!") return end
						setElementData(localPlayer,"Para",(getElementData(localPlayer,"Para") or 0) + tonumber(data.price_sell))
						setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") - tonumber(data.price_sell))
						guiSetText(tables.label[1],"Mevcut Paran: "..tostring(getElementData(localPlayer,"Para") or 0).."$\nMağazanın Parası: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
						setElementData(localPlayer,itemName,getElementData(localPlayer,itemName) - returnItemNumber())
						outputChatBox("Eşyayı sattın!")
						--refreshInventory()
						delayButtonsInventory = false
						setTimer(function() 
							delayButtonsInventory = false 
						end,500,1)
						--if weaponDelete[itemName] then
							if getElementData(getLocalPlayer(),itemName) <= 1 then
								triggerServerEvent("removeBackWeaponOnDrop",localPlayer)
							end	
						end
					else
						--outputChatBox("Maalesef mağazanın satın alacak kadar parası yok!")
					--end
				end
			--end	
			end
	end,false)
	guiSetVisible(tables.window[1],false)
end)

function onClientMarkerHit(elementHit,matchingDimension)
	if getElementType(elementHit) == "player" and elementHit == localPlayer and getElementData(source,"shop:ID") then
		setElementData(elementHit,"currentShop",source)
		guiSetVisible(tables.window[1],not guiGetVisible(tables.window[1]))
		guiSetText(tables.label[1],"Mevcut Paran: "..tostring(getElementData(localPlayer,"Para") or 0).."$\nMağazanın Parası: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
		showCursor(guiGetVisible(tables.window[1]))
	end
end
addEventHandler("onClientMarkerHit",getRootElement(),onClientMarkerHit)

function onClientMarkerLeave(elementHit,matchingDimension)
	if getElementType(elementHit) == "player" and elementHit == localPlayer and getElementData(source,"shop:ID") then
		guiSetVisible(tables.window[1],false)
		showCursor(false)
		setElementData(elementHit,"currentShop",nil)
	end
end
addEventHandler("onClientMarkerLeave",getRootElement(),onClientMarkerLeave)

--function getItemSlotsPlus(selectItem)
--	for i, column in ipairs(category) do
--		for i, data in ipairs(items[column[1]]) do
--			if selectItem == data.itemName then
--				local currentSlots = getPlayerCurrentSlots() + data.slots * returnItemNumber() 
--				if currentSlots <= getElementData(localPlayer,"MAX_Slots") then
--					return false	
--				end
--			end
--		end
--	end	
--	return true
--end

local startCount

addEventHandler("onClientRender",root,function()
	if getElementData(localPlayer,"logedin")or false then
		local pls=getElementsByType("player")
		local gang=getElementData(localPlayer,"gang")or "None"
		local px,py,pz=getElementPosition(localPlayer)
		if gang~="None" and gang then
			for i,pl in ipairs(pls) do
				local plGang=getElementData(pl,"gang")or "None"
				if plGang==gang and pl~=localPlayer then
					local x,y,z=getElementPosition(pl)
					local dist=getDistanceBetweenPoints3D(px,py,pz,x,y,z)
					local x,y=getScreenFromWorldPosition(x,y,z)
					local oyuncuad = getPlayerName(pl)
					if x and y then
						dxDrawText("•"..math.floor(dist).."M", x+1, y+8,_,_, tocolor(100, 255, 100, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
						dxDrawText("•"..oyuncuad.."", x+1, y-8,_,_, tocolor(100, 255, 100, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
					end
				end
			end
		end
		local isLeave=getElementData(localPlayer,"leave")or false
		if isLeave then
			if not startCount then startCount=getTickCount() end
			local totalTimer=10-math.floor((getTickCount()-startCount)/920)
			if totalTimer<0 then triggerServerEvent("unbugZZ",localPlayer) return end
			dxDrawText("Spawn Koruma: "..totalTimer, screenW * 0.3916, screenH * 0.8294, screenW * 0.5879, screenH * 0.8971, tocolor(255, 0, 0, 255), 3.00, "default-bold", "center", "center", false, false, false, false, false)
		else
			if startCount then
				startCount=nil
			end
		end
	end
end)

function returnItemNumber()
	for i, column in ipairs(category) do
		for i, data in ipairs(items[column[1]]) do
			if guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1) == data.itemName then
				return data.number
			end
		end
	end	
end

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...