mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	More refactoring. Adding to bazaar now works for selling and seeking by gil.
This commit is contained in:
		| @@ -10,13 +10,44 @@ All bazaar args have a Reward (The item the person who fufills the request gets) | ||||
|  | ||||
| function onEventStarted(player, actor, triggerName, rewardItem, seekItem, bazaarMode, arg1, bazaarActor, rewardAmount, seekAmount, arg2, arg3, type9ItemIds) | ||||
|  | ||||
| 	--Get reward reference or itemId | ||||
| 	local originalReward = nil; | ||||
| 	local originalSeek = nil;	 | ||||
|  | ||||
| 	--Handle Reward | ||||
| 	if (type(rewardItem) == "number") then | ||||
| 		rewardItem = GetWorldManager():CreateItem(rewardItem, rewardAmount); | ||||
| 	else | ||||
| 		rewardItem = player:GetItem(rewardItem); | ||||
| 		originalReward = rewardItem; | ||||
| 		if (bazaarMode ~= 11) then | ||||
| 			rewardItem = GetWorldManager():CreateItem(rewardItem.itemId, rewardAmount, rewardItem.quality); | ||||
| 		end | ||||
| 	end | ||||
| 	 | ||||
| 	--Get seek reference or itemid | ||||
| 	--Handle Seek | ||||
| 	if (type(seekItem) == "number") then | ||||
| 		seekItem = GetWorldManager():CreateItem(seekItem, rewardAmount); | ||||
| 	else | ||||
| 		seekItem = player:GetItem(seekItem); | ||||
| 		originalSeek = seekItem; | ||||
| 		if (bazaarMode ~= 11) then | ||||
| 			seekItem = GetWorldManager():CreateItem(seekItem.itemId, seekAmount, seekItem.quality); | ||||
| 		end | ||||
| 	end | ||||
| 	 | ||||
| 	--Tell worldmaster to add bazaar entry with reward, seek, rewardAmount, seekAmount, and bazaarMode | ||||
| 	--If not selling, remove the seek item | ||||
| 	if (bazaarMode ~= 11 and bazaarMode ~= 12 and bazaarMode ~= 13) then | ||||
| 		if (originalSeek ~= nil) then | ||||
| 			player:RemoveItem(originalSeek, seekAmount); | ||||
| 		end | ||||
| 	end | ||||
| 	 | ||||
| 	--Remove reward items from inventory | ||||
| 	--Remove the reward item | ||||
| 	if (originalReward ~= nil) then | ||||
| 		player:RemoveItem(originalReward, rewardAmount); | ||||
| 	end | ||||
| 	 | ||||
| 	GetWorldManager():AddToBazaar(player, rewardItem, seekItem, rewardAmount, seekAmount, bazaarMode); | ||||
| 	 | ||||
| 	player:EndEvent(); | ||||
| 	 | ||||
|   | ||||
| @@ -27,7 +27,7 @@ function onTrigger(player, argc, qty, name, lastName) | ||||
|         qty = tonumber(qty) or 1; | ||||
|         location = INVENTORY_CURRENCY; | ||||
|          | ||||
|         local added = player:GetInventory(location):AddItem(currency, qty, 1); | ||||
|         local added = player:GetItemPackage(location):AddItem(currency, qty, 1); | ||||
|         local messageID = MESSAGE_TYPE_SYSTEM_ERROR; | ||||
|         local message = "unable to add gil"; | ||||
|          | ||||
|   | ||||
| @@ -40,7 +40,7 @@ function onTrigger(player, argc, item, qty, location, name, lastName) | ||||
|             location = INVENTORY_NORMAL; | ||||
|         end; | ||||
|          | ||||
|         local added = player:getInventory(location):addItem(item, qty, 1); | ||||
|         local added = player:getItemPackage(location):addItem(item, qty, 1); | ||||
|          | ||||
|         if added then | ||||
|             message = string.format("Added item %u of kind %u to %s", item, location, player:GetName()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user