• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Why does this piece of code cause desynch?

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Update: Sorry guys, I have found the problem which is unrelated to the codes posted. Please close this thread. Im sorry.

Hi guys, why does the following code cause desynch? I use it to pan a certain player's camera to a certain area of the map and show destructables to that player. But after running the map for a minute or so (I used two players for testing), player 2 disconnects. I cant fix it. Thanks for the help.
JASS:
function Trig_InitActions takes nothing returns nothing
        local player p = GetTriggerPlayer()
        if p == GetLocalPlayer() then
            if not InitB[GetPlayerId(p) + 1] then
                set InitB[GetPlayerId(p) + 1] = true 
                set title3 = CreateTextTag()
                set strstr[2] = "|c00fffc01????: |r"+I2S(TalentPoint[GetPlayerId(p) + 1])
                call SetTextTagPos(title3,-2341,5720,0)
                call SetTextTagText(title3, strstr[2],.025)
                call SetTextTagVisibility(title3,true)
                call SetTextTagPermanent(title3,true)
                set CamDis[GetPlayerId(p) + 1] = GetCameraField(CAMERA_FIELD_TARGET_DISTANCE)
                call CameraSetupApply(gg_cam_TalentTree, true, true)
                call CF_LockCam(p, gg_cam_TalentTree)
                call CreateFogModifierRectBJ( true, p, FOG_OF_WAR_VISIBLE, gg_rct_TalentTree )
                call FogModifierStart( bj_lastCreatedFogModifier )
                call EnumDestructablesInRect(gg_rct_TalentTree, null, function ShowDest)
                if FirstTime == false then
                    set FirstTime = true
                    set DEF = CreateImageEx("war3mapImported\\testtest.blp",850,622,-2843,5754,0,true)
                else
                    call ShowImage(DEF, true)
                endif
                call SetTextTagVisibility(title1,true)
                call SetTextTagVisibility(title2,true)
                call SetTextTagVisibility(title4,true)
                call SetTextTagVisibility(title5,true)
            else
                set InitB[GetPlayerId(p) + 1] = false 
                call EnumDestructablesInRect(gg_rct_TalentTree, null, function HideDest)
                call SetTextTagVisibility(title1,false)
                call SetTextTagVisibility(title2,false)
                call SetTextTagVisibility(title3,false)
                call DestroyTextTag(title3)
                call SetTextTagVisibility(title4,false)
                call SetTextTagVisibility(title5,false)
                call ShowImage(DEF, false)
                call CF_Release(p)
                if (p == GetLocalPlayer()) then
                    call ResetToGameCamera(0)
                    call PanCameraToTimed(GetUnitX(udg_Hero[GetPlayerId(p) + 1]), GetUnitY(udg_Hero[GetPlayerId(p) + 1]), 0)
                    call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE,CamDis[GetPlayerId(p) + 1],0)
                endif
            endif   
        endif
    endfunction

function InitTrig_Init takes nothing returns nothing
        local integer i = 0
        set gg_trg_Init = CreateTrigger()
        call DisableTrigger(gg_trg_Init)
        loop
            exitwhen i > 7
            call TriggerRegisterPlayerEvent(gg_trg_Init, Player(i), EVENT_PLAYER_END_CINEMATIC)
            set i = i + 1
        endloop
        call TriggerAddAction(gg_trg_Init, function Trig_InitActions)
    endfunction

Edit:
The following code also causes player 2 to disconnect...... :(
JASS:
function TalentPointsAction takes nothing returns boolean
    local unit tri = GetTriggerUnit()
    local player p = GetOwningPlayer(tri)
    if GetLocalPlayer() == p and p != Player(9) and p != Player(11) and p != Player(10) then
        if not LoadBoolean(kafei,GetPlayerId(p)+1, 0) and GetHeroLevel(tri) >= 10 and GetHeroLevel(tri) < 20 then
            call SaveBoolean(kafei, GetPlayerId(p) + 1, 0, true)
            set TalentPoint[GetPlayerId(p)+1] = 1 - TPUsed[GetPlayerId(p) + 1]
        elseif not LoadBoolean(kafei,GetPlayerId(p)+1, 1) and GetHeroLevel( tri) >= 20 and GetHeroLevel( tri) < 30 then
            call SaveBoolean(kafei, GetPlayerId(p) + 1, 1, true)
            set TalentPoint[GetPlayerId(p)+1] = 2- TPUsed[GetPlayerId(p) + 1]
        endif
    endif
    set tri = null
    call BJDebugMsg(I2S(TalentPoint[GetPlayerId(p)+1]))
    return false 
endfunction

//===========================================================================
function InitTrig_TalentPoints takes nothing returns nothing
    set gg_trg_TalentPoints = CreateTrigger()
    call DisableTrigger(gg_trg_TalentPoints)
    call TriggerRegisterAnyUnitEventBJ( gg_trg_TalentPoints, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddCondition(gg_trg_TalentPoints, Condition(function TalentPointsAction))
endfunction
 
Last edited by a moderator:
Status
Not open for further replies.
Top