Whatever i do, giving does not work


#1

Hello there, Im facing hilarious amount of bugs.

function loadLoadout() 
	if (st == true) then
	RemoveAllPedWeapons(GetPlayerPed())
	loadData('Pistol')
	if (storageItem == 'true') then
		loadData('Pistol_ammo')
		local ammo = tonumber(storageItem)
		GiveWeaponToPed(GetPlayerPed(),	0x99AEEB3B,10,false,true)
		Wait(10)
		SetPedAmmo(GetPlayerPed(),0x99AEEB3B,10)
		loadData('Pistol_attachment_silencer')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x99AEEB3B,	0xA73D4664)
		end
		
		loadData('Pistol_attachment_mag')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x99AEEB3B,	0xD9D3AC92)
		end
		
		loadData('Pistol_attachment_flash')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x99AEEB3B,	0x359B7AAE)
		end
	end
	
	loadData('SMG')
	if (storageItem == 'true') then
		loadData('SMG_ammo')
		local ammo = tonumber(storageItem)
		RemoveWeaponFromPed(GetPlayerPed(),0x2BE6766B)
		Wait(10)
		GiveWeaponToPed(GetPlayerPed(),	0x2BE6766B,ammo,false,true)
		Wait(10)
		SetPedAmmo(GetPlayerPed(),0x2BE6766B,ammo)
		loadData('SMG_attachment_silencer')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x2BE6766B,	0xC304849A)
		end
		
		loadData('SMG_attachment_mag')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x2BE6766B, 0x350966FB)
		end
		
		loadData('SMG_attachment_flash')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x2BE6766B,	0x7BC4CDDC)
		end
	end
	
	loadData('SMG2')
	if (storageItem == 'true') then
		loadData('SMG2_ammo')
		local ammo = tonumber(storageItem)
		RemoveWeaponFromPed(GetPlayerPed(),0xEFE7E2DF)
		Wait(10)
		GiveWeaponToPed(GetPlayerPed(),	0xEFE7E2DF,ammo,false,true)
		Wait(10)
		SetPedAmmo(GetPlayerPed(),0xEFE7E2DF,ammo)
		loadData('SMG2_attachment_silencer')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xEFE7E2DF,	0xA73D4664)
		end
		
		loadData('SMG2_attachment_mag')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xEFE7E2DF, 0xBB46E417)
		end
		
		loadData('SMG2_attachment_flash')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xEFE7E2DF,	0x7BC4CDDC)
		end
	end
	
	loadData('Carbine')
	if (storageItem == 'true') then
		loadData('Carbine_ammo')
		local ammo = tonumber(storageItem)
		RemoveWeaponFromPed(GetPlayerPed(),0x83BF0278)
		Wait(10)
		GiveWeaponToPed(GetPlayerPed(),	0x83BF0278,ammo,false,true)
		Wait(10)
		SetPedAmmo(GetPlayerPed(),0x83BF0278,ammo)
		loadData('Carbine_attachment_silencer')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x83BF0278,	0x837445AA)
		end
		
		loadData('Carbine_attachment_mag')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x83BF0278, 0x91109691)
		end
		
		loadData('Carbine_attachment_flash')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0x83BF0278,	0x7BC4CDDC)
		end
	end
	
	loadData('AK')
	if (storageItem == 'true') then
		loadData('AK_ammo')
		local ammo = tonumber(storageItem)
		RemoveWeaponFromPed(GetPlayerPed(),	0xBFEFFF6D)
		Wait(10)
		GiveWeaponToPed(GetPlayerPed(),	0xBFEFFF6D,ammo,false,true)
		Wait(10)
		SetPedAmmo(GetPlayerPed(),0xBFEFFF6D,ammo)
		loadData('AK_attachment_silencer')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xBFEFFF6D,0xA73D4664)
		end
		
		loadData('AK_attachment_mag')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xBFEFFF6D,0xB1214F9B)
		end
		
		loadData('AK_attachment_flash')
		if (storageItem == 'true') then
			GiveWeaponComponentToPed(GetPlayerPed(),0xBFEFFF6D,0x7BC4CDDC)
		end
	end
	print ('loaded')
	end

end

This thing here, although it prints ‘loaded’, it does not give me guns even if variables are correct (becuse i use them in shop, and it’s passing them fine). Again, in shop IT DOES not give me weapons, ammo, attachments. Anything i tried… It just does not do what it should. It worked before some hours, but now it won’t and i have no clue why.

Is there something i missed? Do I have to clear cache or something?


#2

This seems to be solver. Now problem is, that client threads are stopping. I have function for saving car, but it executes 5-6 times and it stops itself from executing. Any ideas why?