wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > Trigger (GUI)/ AI editor Tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 08-08-2006, 04:23 PM   #1
ragingspeedhorn
I MUST BREAK YOU
 
ragingspeedhorn's Avatar


Official Map Reviewer
 
Join Date: May 2005
Posts: 1,237

Submissions (10)

ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)

Approved Map: Dodge The Wisp Wheels

Send a message via MSN to ragingspeedhorn
Default How to find out who is the host

How to find out who is the host

A tutorial by: ragingspeedhorn

Note: I did not discover this code, the original author is "Tennis" from www.wc3jass.com, I just made this tutorial so people who isent that familiar with jass (like myself) still can implement this (thanks to Zoxc for helping with this)


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.

Zoom (requires log in)


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):

Collapse 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.

Zoom (requires log in)

Final note: This is not 100% stable, the GetHost() can fail sometimes and select another player, however that is quite rare.
Attached Images
File Type: png gethost4il.png (4.2 KB, 1358 views)
File Type: png variable5xf.png (6.0 KB, 1274 views)

Last edited by ragingspeedhorn : 08-08-2006 at 04:27 PM.
ragingspeedhorn is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-08-2006, 08:21 PM   #2
The)TideHunter(
SpeakerGames.com
 
The)TideHunter('s Avatar
 
Join Date: Mar 2006
Posts: 1,328

Submissions (1)

The)TideHunter( is a jewel in the rough (160)The)TideHunter( is a jewel in the rough (160)

Send a message via MSN to The)TideHunter(
Default

Nice tut, it can really help alot of people who are unawair.
The only thing i can add, just a feature, is running the GetHost functions 5-10 times, and get the average, to make sure it dosent return the non-host ID, thats not needed though.
__________________
Big plans...
The)TideHunter( is offline   Reply With Quote
Old 08-08-2006, 08:28 PM   #3
ragingspeedhorn
I MUST BREAK YOU
 
ragingspeedhorn's Avatar


Official Map Reviewer
 
Join Date: May 2005
Posts: 1,237

Submissions (10)

ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)

Approved Map: Dodge The Wisp Wheels

Send a message via MSN to ragingspeedhorn
Default

Well that could be implemented yeah but personaly I have never had any failure with the script picking a fake host in a map that I played maybe 70-100 times

EDIT: Thanks for the positive review btw

Last edited by ragingspeedhorn : 08-08-2006 at 09:27 PM.
ragingspeedhorn is offline   Reply With Quote
Old 08-08-2006, 09:31 PM   #4
SFilip
reenignE
 
SFilip's Avatar
 
Join Date: Mar 2006
Posts: 321

SFilip has a spectacular aura about (111)SFilip has a spectacular aura about (111)SFilip has a spectacular aura about (111)SFilip has a spectacular aura about (111)

Send a message via MSN to SFilip
Default

people with slow connection (such as myself) might encounter problems since at the very beginning someone might be faster and get the host status.
anyway average host script won't change your tutorial much (just the command you call and the map header part).
here's the code:
http://www.thehelper.net/forums/show...76&postcount=8
SFilip is offline   Reply With Quote
Old 08-08-2006, 09:41 PM   #5
ragingspeedhorn
I MUST BREAK YOU
 
ragingspeedhorn's Avatar


Official Map Reviewer
 
Join Date: May 2005
Posts: 1,237

Submissions (10)

ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)

Approved Map: Dodge The Wisp Wheels

Send a message via MSN to ragingspeedhorn
Default

Quote:
Originally Posted by SFilip
people with slow connection (such as myself) might encounter problems since at the very beginning someone might be faster and get the host status.
anyway average host script won't change your tutorial much (just the command you call and the map header part).
here's the code:
http://www.thehelper.net/forums/show...76&postcount=8

The guy mentions the script he shows being untested, are you 100% sure it works? Because I wouldn't like to update the tutorial and then get something out of it that does not work
ragingspeedhorn is offline   Reply With Quote
Old 08-09-2006, 08:57 AM   #6
The)TideHunter(
SpeakerGames.com
 
The)TideHunter('s Avatar
 
Join Date: Mar 2006
Posts: 1,328

Submissions (1)

The)TideHunter( is a jewel in the rough (160)The)TideHunter( is a jewel in the rough (160)

Send a message via MSN to The)TideHunter(
Default

Also, the guy in the script uses it a few times in a loop, which i think is bad.
The GetHost function is slow, cause is syncs, using it in a loop is just asking for lag.
I'v never experienced any problems either with GetHost, its a risk, but very small.
__________________
Big plans...
The)TideHunter( is offline   Reply With Quote
Old 08-09-2006, 11:47 PM   #7
Orc_Tamer
Do I really need this? <-
 
Orc_Tamer's Avatar
 
Join Date: Feb 2006
Posts: 43

Submissions (4)

Orc_Tamer will become famous soon enough (68)Orc_Tamer will become famous soon enough (68)Orc_Tamer will become famous soon enough (68)

Default

Great Job on the tutorial. I like this since I don't like being a red for host.
__________________
Son of a gun ̿̿ ̿̿̿̿̿'̿̿̿̿̿'\̵͇̿̿\

Orc_Tamer is offline   Reply With Quote
Old 08-15-2006, 08:17 AM   #8
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default

Looks good. I'll fix a typo and approve this.
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Old 08-15-2006, 12:01 PM   #9
ragingspeedhorn
I MUST BREAK YOU
 
ragingspeedhorn's Avatar


Official Map Reviewer
 
Join Date: May 2005
Posts: 1,237

Submissions (10)

ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)ragingspeedhorn is a jewel in the rough (211)

Approved Map: Dodge The Wisp Wheels

Send a message via MSN to ragingspeedhorn
Default

Quote:
Originally Posted by PitzerMike
Looks good. I'll fix a typo and approve this.

Thanks for the approval Mike
ragingspeedhorn is offline   Reply With Quote
Old 07-10-2007, 07:46 PM   #10
marshall
User
 
Join Date: Aug 2003
Posts: 104

marshall has little to show at this moment (1)

Default

Just a word of warning to anyone reading this tut.
I tried this on a LAN with two computers and it *always* selected the non-host as the host. Even with an average check. The non-host comp was slightly faster than the host comp.
GetHost relies on the comps being similar and there being sufficient network lag.
marshall is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 03:23 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services