gPlayers = {}

RegisterLocalEventHandler("inventory:Use",function(player,id,_,items,slot)
	-- need at least 4 slots because we need 5 slots but we're removing 1 item
	if id == "sweden_gift" and items == "day1_gift" and dsl.inventory.GetPlayerSpace(player) >= 4 and dsl.inventory.RemoveItemFromPlayer(player,id,1,slot) then
		SendNetworkEvent(player,"gift_items:PlaySound")
		dsl.inventory.GiveItemToPlayer(player,"note_v1rel",1)
		dsl.inventory.GiveItemToPlayer(player,"blue_flowers",1)
		dsl.inventory.GiveItemToPlayer(player,"skateboard",1)
		dsl.inventory.GiveItemToPlayer(player,"blank_paper",20)
		dsl.inventory.RewardPlayerMoney(player,2000)
	elseif id == "america_gift" and items == "yubari_gift" and dsl.inventory.GetPlayerSpace(player) >= 3 and dsl.inventory.RemoveItemFromPlayer(player,id,1,slot) then
		SendNetworkEvent(player,"gift_items:PlaySound")
		dsl.inventory.GiveUniqueItemToPlayer(player,"written_paper","Thank you for playing Bully Online. This note is part of a rare gift you got for being online during a random gift drop. I hope you enjoy it!\n\nIn here you'll find a skateboard, a stack of 20 papers for writing notes, and $50.\n\nP.S. Chat improvements are coming soon - including ways to customize the chat, turn it off entirely, and even proximity chat.\n\n~ Xx_Yubari_xX, Dec 23rd 2025","Xx_Yubari_xX")
		dsl.inventory.GiveItemToPlayer(player,"skateboard",1)
		dsl.inventory.GiveItemToPlayer(player,"blank_paper",20)
		dsl.inventory.RewardPlayerMoney(player,5000)
	end
end)

SetCommand("give_gift",function()
	if not dsl.inventory then
		PrintError("failed to give gift")
		return
	end
	for player in AllPlayers() do
		local account = GetPlayerAccountTable(player,"gift_items")
		if account and not account.gave_yubari_gift then
			account.gave_yubari_gift = true
			if SavePlayerAccountTable(player) then
				dsl.inventory.GiveUniqueItemToPlayer(player,"america_gift","A rare gift from Xx_Yubari_xX.","yubari_gift")
			end
		end
	end
end,false,"Usage: give_gift\nFor Xx_Yubari_xX to give her gifts out.")
