HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Dialogs, GetLocalPlayer() and Observers

04-21-2007, 08:42 PM#1
Sagan
Something useful I just noticed:

You can use DialogDisplay inside GetLocalPlayer-blocks, and the clicked dialog button will be registered by all players.

Why is that useful? Because with this something local can trigger something for all players.

I use this for menus for observers. Because almost no events register what an observer is doing, I simply tell them to move their camera to one of the four corners of the map to trigger a menu.

This is an example for the kick menu, which will display when the admin-player moves his camera to the bottom left corner of the map, and waits there for 10 seconds.

Trigger:
Kick ausloeser
Collapse Events
Time - Every 10.00 seconds of game time
Conditions
Collapse Actions
Dialog - Clear KickMenu
Dialog - Change the title of KickMenu to Kick who?
Dialog - Create a dialog button for KickMenu labelled Nobody
Set KickButtons[0] = (Last created dialog Button)
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Custom script: set udg_TempString = GetPlayerNameColored(Player(GetForLoopIndexA() - 1))
Dialog - Create a dialog button for KickMenu labelled TempString
Set KickButtons[(Integer A)] = (Last created dialog Button)
Else - Actions
Custom script: call RemoveLocation(udg_TempPoint)
Set TempPoint = (Target of current camera view)
Custom script: call RemoveLocation(udg_TempPoint2)
Set TempPoint2 = (Point((Min X of (Current camera bounds)), (Min Y of (Current camera bounds))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Distance between TempPoint and TempPoint2) Less than or equal to 100.00
Collapse Then - Actions
-------- THIS IS A GETLOCALPLAYER BLOCK --------
-------- NO CODE THAT AFFECTS ANYTHING IN THIS --------
Dialog - Show KickMenu for Admin
-------- This will only show if GetLocalPlayer() == udg_Admin --------
Else - Actions
Trigger:
Kick klick
Collapse Events
Dialog - A dialog button is clicked for KickMenu
Collapse Conditions
(Clicked dialog button) Not equal to KickButtons[0]
Collapse Actions
-------- Yes, this causes no desyncs. Even if the KickMenu dialog was shown in a GetLocalPlayer() block --------
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to KickButtons[(Integer A)]
Collapse Then - Actions
Game - Defeat (Player((Integer A))) with the message: You got kicked.
Else - Actions


Before I had this, I was using a simple "-kick x" system. And that would not work if the admin-player was an observer. This does :).

I have only tested this on LAN with 2 players, but I don't see any reason, why this wouldn't work over Battle.net, or with more players.

Maybe someone else can find some other uses for this. Maybe to sync some information. (I can't think of a way to do this, but maybe it's possible) I just wanted to share this.