[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > WarCraft III Tutorials > General Mapping Tutorials


General Mapping Tutorials This board contains tutorials that provide generic mapping information.
Read the Rules before posting.

Closed Thread
 
Thread Tools
Old 06-11-2006, 01:14 AM   #1 (permalink)
Registered User ragingspeedhorn
Unpopular by popular vote
 
ragingspeedhorn's Avatar
 
Join Date: Apr 2005
Posts: 6,536
ragingspeedhorn is a splendid one to behold (947)ragingspeedhorn is a splendid one to behold (947)ragingspeedhorn is a splendid one to behold (947)ragingspeedhorn is a splendid one to behold (947)
PayPal Donor: This user has donated to The Hive. Former Staff Member: This user used to be on the Hive Workshop staff. Paired Mapping Contest #4 - Winner: Fallen Angel - Lucifer's Keep Paired Mapping Contest #3 - Winner: Warcraft Arena Paired Mapping Contest #2 - Winner: Hell Scream's Party Cinematic Mini-Contest #1 - Winner: The Escape & The Premonition Mini-Game Contest #1 - Winner: Pirate Tag! 
How to make the game check who is the host

How to make the game check who is the host.

A tutorial by: ragingspeedhorn

Note: I did not discover this code, the original author is "Tennis" from www.wc3jass.com.

Many maps uses the "player1 (red) = guy who decides everything", that is annoying because the host might not want to play as red but still wants to control the stuff which the host sometimes can do (as an example, difficulty settings, player 1 (red) is in a large number of maps able to set the difficulty of the game through a dialog or something similar).

But what most people probably didn't knew is that with just a very small amount of custom scripts (Jass) and 1 variable you can detect who is the host.

So here it goes, the 3 easy steps on how to create the variable and make the custom scripts.


Step 1: The Variable.

Create a new variable, name it "Host", set the variable type to "Player (player)", do not check out the Aray box and leave the initial value at none like I have done in the picture below.




Step 2: Custom Script Header.

Right, you have your variable now it is time to get the hardest part done. In the Trigger Editor you click at the top at the maps name like if it was any other trigger, in there you paste these lines of code (Make sure you paste it at the top):

Jass:
function GetHost takes nothing returns nothing
    local gamecache g = InitGameCache("Map.w3v")
    call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ())+1)
    call TriggerSyncStart ()
    call SyncStoredInteger ( g, "Map", "Host" )
    call TriggerSyncReady ()
    set udg_Host = Player( GetStoredInteger ( g, "Map", "Host" )-1)
    call FlushGameCache( g )
    set g = null
endfunction

Step 3: Getting The Host.

Now that you have the most of the work done you just need to make a last simple trigger where you set the event to Map initialization, conditions you leave untouched and in the actions you make a custom script like this: "Custom script: call GetHost()". Now it has checked who is the host and stored it in the variable, for further use you just need to address everything to the "Host" variable like you would usually do to Player 1 (red), it is as simple as that.

Start of the map
Events
Game - Elapsed game time is 0.02 seconds
Conditions
Actions
Custom script: call GetHost()

Final note: This is not 100% stable, the gethost() can fail sometimes and select another player, however that is quite rare.
Attached Thumbnails
variable5xf.jpg  

Last edited by Pyritie; 05-27-2009 at 11:30 AM. Reason: Changing the trigger to use "Elapsed game time" instead of "Map initialization".
ragingspeedhorn is offline  
Closed Thread

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i make a host detection trigger? neogaidenx World Editor Help Zone 1 03-01-2008 12:49 AM
[Trigger] Is there a GUI Host Check? mammoth28 Triggers & Scripts 2 10-23-2007 10:10 AM
Make the game check the date/time (possible?) BOESERTEDDY World Editor Help Zone 8 04-06-2007 09:43 AM
How to pick game creater(Host) Player. lordzeus Site Discussion 1 07-16-2006 07:28 PM
[JASS] Name Check At Map Start of Game Computer[Sheep] Triggers & Scripts 1 04-03-2005 08:30 PM

All times are GMT. The time now is 08:28 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle