• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] This function just crashes, no error at all.

Status
Not open for further replies.
Kind of wondering if there is any fix for this? Apparently the jass checker dislikes this so much it crashes itself and your editor with it.

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
 
Use JassHelper and pJASS. Never use the default JASS syntax checker. The code above works perfectly fine for me in JNGP.

I think you can also get the host with my SyncInteger library (not thoroughly tested).

JASS:
library GetHost initializer Init requires SyncInteger
   
    globals
        player Host = null
    endglobals
   
    private function FoundHost takes nothing returns boolean
        if (Host == null) then
            set Host = GetSyncedPlayer()
            call BJDebugMsg(GetPlayerName(Host))
        endif
       
        return false
    endfunction
   
    function OnMapStart takes nothing returns nothing
        call SyncInteger(GetPlayerId(GetLocalPlayer()), 1)
    endfunction
   
    function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.00, false, function OnMapStart)
        call OnSyncInteger(function FoundHost)
    endfunction

endlibrary
 
It actually broke on my newgen as well, the fix for it was to re-type the entire thing. Apparently there's an invisible char somewhere in the original post I CnP'd. Thanks, when it worked perfectly for you, got me to realize I must have copy and pasted a hidden char/space. =)

Edit: I don't use vJASS but your system looks interesting. I prefer vanilla editing, easier for myself because I like seeing what the code looks like.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Be aware that the function returns the player with the lowest latency. WC3 has no concept of "host player". When a user hosts a game in WC3 the game starts an internal server which they join in the same way as other clients. As such it is completely possible for different computers to have lower latency, as I experienced once when playing on BattleNet with my brother who is on the same LAN network as me.

As such it is almost always far better to hard-code a player as "host" or to use a vote system for equality purposes.
 
Status
Not open for further replies.
Top