First for the display I will let you look into how to make frames... just start with a basic one they tend to be many lines of code so I didnt write one up
but for the python you would use something like this
- Code:
-
def FactionRegionDisplay_Update(eventType,eventArgs):
if eventType == "FACTION_REGION_ENTERED":
FactionRegionDisplayFrame.Show() #Name of the frame in the xml file
elif eventType == "FACTION_REGION_ENTERED":
FactionRegionDisplayFrame.Hide()
ClientAPI.Interface.RegisterEventHandler('UiEvent', FactionRegionDisplay_Update)
Basically this registers a function to handle a UiEvent - pretty much the only event you will be using...there are a few other but they are a lot more complicated
for these just know that if you dispatch and event every function that is registered as an event handler will be called in this case it will only do something if the eventType (ie the first argument in the dispatch event) is equal to FACTION_REGION_ENTERED or FACTION_REGION_ENTERED in which case it will either hide or show the frame FactionRegionDisplayFrame
If I have time later i will make a basic frame for you to look at.
the second part is to handle client side the player entering/leaving the region you would use something like this
- Code:
-
def FactionRegionEntry(message):
if (not message.has_key("FactionRegion")):
return
factionName = message["FactionRegion"]
ClientAPI.Log("FactionRegion = " + str(message)) # I always like to log when players enter regions helps debugging
if message["regionAction"] == "onEnter":
ClientAPI.Interface.DispatchEvent("FACTION_REGION_ENTERED", [factionName])
elif message["regionAction"] == "onLeave":
ClientAPI.Interface.DispatchEvent("FACTION_REGION_LEFT", [factionName])
ClientAPI.Network.RegisterExtensionMessageHandler("mv.RegionEntry", FactionRegionEntry)
This you would make a .py file in the scripts directory (you might need to put import ClientAPI at the top)
Basically here you are registering FactionRegionEntry to be called whenever a message of type mv.RegionEntry is sent from the server
If you use their basic region code it will automatically send whether the player is entering or leaving the region (hence regionAction) technically you can change it so that the elif is an else
but I thought you should know the command in case you only care if they are leaving
The first thing it does is check if the region has a FactionRegion property I use this because I have a lot of different regions doing different things so I always have it check one main identifier
with out that if/return statement anytime a player enters a region the FACTION_REGION_ENTERED event would be dispatched.
below that I have it set the factionName in this case it is not necessary but I thought it would be good for you to know the syntax for it
Finally server side you would have a region with these properties (you can edit the mwc/mvw files in a text editor they are just xml code with a different ending)
- Code:
-
<NameValuePairs>
<NameValuePair Name="onEnter" Value="enterMessage" Type="String" />
<NameValuePair Name="onLeave" Value="leaveMessage" Type="String" />
<NameValuePair Name="messageExtensionType" Value="mv.RegionEntry" Type="String" />
<NameValuePair Name="messageRegionProperties" Value="FactionRegion" Type="String" />
<NameValuePair Name="FactionRegion" Value="Roman" Type="String" />
</NameValuePairs>
here the namevaluepairs are properties you add to the region in the world editor all regions should have similar properties with the exception of the FactionRegion which would be anything you would want to send to the player but it must be listed in the messageRegionProperties in order to be sent.