HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Private Shop System Problem

01-06-2011, 01:17 PM#1
Dau
Zup,

I'm trying to make a shop that only allows certain player(s) to shop there.

I tried removing all "Select Hero" and "Shop Sharing" abilities because I didn't find a way to make these player specific. But if you remove these abilities, when you buy an item the "Item sold"-event does not trigger. The event that does trigger is the "No Target Order"-event with orderID being the itemID of the purchased item. The item bought is placed beside the shop and I have yet to find a way to access this item without using regions.

Does anyone have an idea of how to accomplish this?

Thanks
01-06-2011, 06:20 PM#2
Ignitedstar
I do know of a way to get this to work. I've tried and tested this, so you should be able to use any set of conditions to make the proper shop pop up so long as you set it up properly.

Have one specific spot (or however many you need) and upon map start up, create every single building you need plus a "dummy" building with nothing to sell in that spot and hide them all except the dummy building. Warcraft will have no problem putting the buildings in the same spot because buildings are still units (it's just a different type of unit).

You're going to need two variables to keep track of: a unit variable to keep track of the current building that is being shown and a unit array for all of the buildings in the same spot. The first step is to make sure the unit variable is set to the dummy building (the only building showing). So I can keep referencing it and not confuse you, I'll just call the unit variable ShopDummy (when you're triggering this, you can name it whatever you want so you don't confuse yourself).

Since you need the shop to change so it only allows certain players to shop from it, you can use a condition like 'player X clicks on ShopDummy' or 'unit owned by player X gets within Y range of ShopDummy', whatever works for you.

Whenever the condition is fulfilled, all you have to do is make if/then/else statements. If the player that clicked on the ShopDummy is Player X, hide the current ShopDummy and show the appropriate shop from the unit array variable of buildings that you made earlier. Make sure you set ShopDummy to the building that "replaced" the old ShopDummy, otherwise this is only going to work once because you can't click on the old ShopDummy that the trigger just hid.

I hope this helps. If you need further explanation or have questions, don't be afraid to ask.
01-06-2011, 06:58 PM#3
tooltiperror
Or why not local code?
01-07-2011, 03:13 AM#4
Ignitedstar
I think you wouldn't be using local variables because they can only be referenced in the same trigger that called them at that specific instance. In my case, the two variables need to be there around the clock.
01-07-2011, 02:18 PM#5
Dau
That solves the problem at one point, but wouldn't it cause problems if several players had units at the same shop?

I'm trying to solve this by having a shop with inventory and a very short range of the "Select Unit"-ability and forcing it to select itself. I have yet to succed in this though
01-07-2011, 02:40 PM#6
Dau
Think I solved it by setting activation radius to 0 and ordering the unit to "neutralinteract" with itself. And instead of using the "Items sold"-list I use the "Items made"-list.

If anyone's interested they should try this out and see if it works

EDIT:
Though this doesn't really makes the shop private -_-
01-07-2011, 06:42 PM#7
Ignitedstar
Quote:
Originally Posted by Dau
That solves the problem at one point, but wouldn't it cause problems if several players had units at the same shop?
Yes, but I figured you had something in mind to work around this. There are a bunch of ways to solve that issue, too.
01-07-2011, 07:16 PM#8
Tot
use
Collapse JASS:
function CreateShops takes integer unitid, real x, real y, real facing integer playerid returns unit
local unit shop = CreateUnit(playerid,unitid,x,y,facing)
//prevent desyncs
call UnitRemoveAbility(shop,'Amov')
call UnitRemoveAbility(shop,'Aatk')
//disable useless shops by adding locust-ability
if GetPlayerId(GetLocalPlayer())!=playerid then
call UnitAddAbility(shop,'Aloc')
endif
return shop
endfunction