• 🏆 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!

[Solved] GetLocalPlayer( ) Disconnect

Status
Not open for further replies.
Level 13
Joined
Sep 13, 2010
Messages
550
Well as the title says I have GetLocalPlayer problem. The function which causes problem should be this:
JASS:
function CheckAvailQuests takes nothing returns nothing
local integer pid = GetPlayerId( GetOwningPlayer( GetLevelingUnit( ) ) )
local integer int = 0
local group array SUOT
local unit TU
local integer TT = 0
local integer Amount = 0
if GetLevelingUnit( ) == null then
    set pid = GetPlayerId( LastTrigPlayer )
endif
set SUOT[1] = CreateGroup( )
set SUOT[2] = CreateGroup( )
set SUOT[3] = CreateGroup( )
set SUOT[4] = CreateGroup( )
loop
    if GetLocalPlayer( ) == Player( pid ) then
        call DestroyEffect( LoadEffectHandle( Miscdata , pid , int ) )
    endif
exitwhen LoadInteger( Miscdata , pid , 8191 ) == int
set int = int + 1
endloop
set int = 0
loop
set int = int + 1
    if LoadInteger( udg_QDB , int , 1 ) > 0 and LoadInteger( udg_QDB , int , 25 ) <= GetHeroLevel( udg_PLAYER_Hero[pid] ) and FinishedQuestHandler( pid , int ) == true and ReqTeamHandler( pid , int ) == true then
        if LoadInteger( PlayerTable , pid , int ) != -5 and ( LoadInteger( PlayerTable , pid , int ) != -2 or QSYS_Setup[11] == 1 ) then
            set Amount = Amount + 1
            call SaveInteger( PlayerTable , pid , 2100 + Amount , int )
        endif
        if LoadInteger( PlayerTable , pid , int ) == 0 and ( GetHeroLevel( udg_PLAYER_Hero[pid] ) - QSYS_Setup[7] < LoadInteger( udg_QDB , int , 28 ) or LoadInteger( udg_QDB , int , 28 ) == -1 ) then
            if LoadInteger( udg_QDB , int , 26 ) > 0 then
                call GroupAddGroup( GetUnitsOfTypeIdAll( LoadInteger( udg_QDB , int , 26 ) ) , SUOT[1] )
            else
                call GroupAddUnit( SUOT[1] , LoadUnitHandle( udg_QDB , int , 26 ) )
            endif
        elseif LoadInteger( PlayerTable , pid , int ) == -1 then
            if LoadInteger( udg_QDB , int , 27 ) > 0 then
                call GroupAddGroup( GetUnitsOfTypeIdAll( LoadInteger( udg_QDB , int , 27 ) ) , SUOT[2] )
            else
                call GroupAddUnit( SUOT[2] , LoadUnitHandle( udg_QDB , int , 27 ) )
            endif
        elseif LoadInteger( PlayerTable , pid , int ) == -2 and QSYS_Setup[11] == 1 then
            if LoadInteger( udg_QDB , int , 27 ) > 0 then
                call GroupAddGroup( GetUnitsOfTypeIdAll( LoadInteger( udg_QDB , int , 27 ) ) , SUOT[3] )
            else
                call GroupAddUnit( SUOT[3] , LoadUnitHandle( udg_QDB , int , 27 ) )
            endif
        elseif LoadInteger( PlayerTable , pid , int ) > 0 then
            if LoadInteger( udg_QDB , int , 27 ) > 0 then
                call GroupAddGroup( GetUnitsOfTypeIdAll( LoadInteger( udg_QDB , int , 27 ) ) , SUOT[4] )
            else
                call GroupAddUnit( SUOT[4] , LoadUnitHandle( udg_QDB , int , 27 ) )
            endif
        endif
    endif
exitwhen int == 999
endloop
call SaveInteger( PlayerTable , pid , 2101 + Amount , 0 )
set Amount = 0
loop
exitwhen Amount > 1000 or ( FirstOfGroup( SUOT[1] ) == null and FirstOfGroup( SUOT[2] ) == null and FirstOfGroup( SUOT[3] ) == null and FirstOfGroup( SUOT[4] ) == null ) //Prevent function/trigger crash
    if FirstOfGroup( SUOT[1] ) != null then
        set TU = FirstOfGroup( SUOT[1] )
        set TT = 0
    elseif FirstOfGroup( SUOT[2] ) != null then
        set TU = FirstOfGroup( SUOT[2] )
        set TT = 2
    elseif FirstOfGroup( SUOT[3] ) != null then
        set TU = FirstOfGroup( SUOT[3] )
        set TT = 3
    elseif FirstOfGroup( SUOT[4] ) != null then
        set TU = FirstOfGroup( SUOT[4] )
        set TT = 1
    endif
    set int = S2I( QSYS_Misc[10 + TT] )
    if IsUnitInGroup( TU , SUOT[1] ) and int < S2I( QSYS_Misc[10] ) then
        set int = S2I( QSYS_Misc[10] )
        set TT = 0
    endif
    if IsUnitInGroup( TU , SUOT[2] ) and int < S2I( QSYS_Misc[12] ) then
        set int = S2I( QSYS_Misc[12] )
        set TT = 2
    endif
    if IsUnitInGroup( TU , SUOT[3] ) and int < S2I( QSYS_Misc[13] ) then
        set int = S2I( QSYS_Misc[13] )
        set TT = 3
    endif
    if IsUnitInGroup( TU , SUOT[4] ) and int < S2I( QSYS_Misc[11] ) then
        set int = S2I( QSYS_Misc[11] )
        set TT = 1
    endif
    call GroupRemoveUnit( SUOT[1] , TU )
    call GroupRemoveUnit( SUOT[2] , TU )
    call GroupRemoveUnit( SUOT[3] , TU )
    call GroupRemoveUnit( SUOT[4] , TU )
    if IsUnitEnemy( TU , Player( pid ) ) == false then
        if GetLocalPlayer( ) == Player( pid ) then
            call SaveEffectHandle( Miscdata , pid , Amount , AddSpecialEffectTarget( QSYS_Misc[14 + TT] , TU , "overhead" ) )
        endif
    endif
    set Amount = Amount + 1
endloop
call SaveInteger( Miscdata , pid , 8191 , Amount )
call DestroyGroup( SUOT[1] )
call DestroyGroup( SUOT[2] )
call DestroyGroup( SUOT[3] )
call DestroyGroup( SUOT[4] )
endfunction

If you need the map I will gladly post it for you if you can help ^^
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
It's because you destroy an effect within a local block of code. If you're trying to display an effect for a single player, you do it something like this:

JASS:
local string s = "Abilities\\Weapons\\..."
local player p = Player(1) // just some random player who we want to show an effect to
local effect fx = null

if GetLocalPlayer() != p then
    set s = "" 
endif
set fx = AddSpecialEffect(s, 0, 0)

What I've done here is initialized a string at the beginning for all players. This allows all the players to sync their string tables (which Warcraft uses) so that no desync occurs.

For every other player (not the local player) you want to set that string back to "" so that when you create the effect, only the local player has the string s with the appropriate model-path for the effect. The effects created for the other players will be completely invisible.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I think it would be easier if we had more to work with than one component of a script that happens to destroy an effect at one point within a local block. It seems like the real problem is beyond what you have posted here.
 
Level 13
Joined
Sep 13, 2010
Messages
550
Well this is only code that runs with LocalPlayer. If it not problem I won't post all codes because theres hundreds of lines...

EDIT: I have pointed out an another GLP Disconnect problem at CompletingQ
 

Attachments

  • QuestSystemByGeries.w3x
    887.3 KB · Views: 45
Level 18
Joined
Jan 21, 2006
Messages
2,552
I'm going to post all the occurrences of GetLocalPlayer() blocks in your script.

JASS:
if GetLocalPlayer( ) == Player( pid ) then
    call MultiboardDisplay( Table[pid] , true )
endif

JASS:
loop
    if GetLocalPlayer( ) == Player( pid ) then
        call DestroyEffect( LoadEffectHandle( Miscdata , pid , int ) )
    endif
exitwhen LoadInteger( Miscdata , pid , 8191 ) == int
set int = int + 1
endloop

JASS:
        if GetLocalPlayer( ) == Player( pid ) then
            call SaveEffectHandle( Miscdata , pid , Amount , AddSpecialEffectTarget( QSYS_Misc[14 + TT] , TU , "overhead" ) )
        endif

JASS:
        if GetLocalPlayer( ) == p then
            set TEXT = CreateTextTag( )
            //! runtextmacro XPFtext( "CalcExp" )
        endif

JASS:
        if GetLocalPlayer( ) == p then
            set TEXT = CreateTextTag( )
            //! runtextmacro GoldFtext( "LoadInteger( udg_QDB , QID , 29 )" )
        endif

JASS:
        if GetLocalPlayer( ) == p then
            set TEXT = CreateTextTag( )
            //! runtextmacro LumberFtext( "LoadInteger( udg_QDB , QID , 271 )" )
        endif

JASS:
    if GetLocalPlayer( ) == p then
        call PlaySound( QSYS_Misc[21] )
    endif

JASS:
    if GetLocalPlayer( ) == p then
        call PlaySound( QSYS_Misc[20] )
    endif

JASS:
    if GetLocalPlayer( ) == p then
        call PlaySound( QSYS_Misc[24] )
    endif

JASS:
    if GetLocalPlayer( ) == p then
        call PlaySound( QSYS_Misc[23] )
    endif

There's quite a few places where this could cause a desync. I see you have a couple of text-macros nested in local code. I'm quite certain that much of this is where your problems are coming from.
 
Level 13
Joined
Sep 13, 2010
Messages
550
Thanks guys. All GetLocalPlayer( ) problem fixed... Btw theres one I can't understand why:
JASS:
if GetLocalPlayer( ) == Player( pid ) then
    call MultiboardDisplay( Table[pid] , true )
endif

It seemed working fine with this. Although if I give a quest back all players controll seems paused. If I cast something or move nothing happens. I don't know why. It becomes allright again if I click on a unit. And theres one more thing: If I click on somebody else's unit it immediately selects nothing, except if I quickly click unit double times. Can it be caused by Multiboard?- Nevermind. I got the source of the problem ^^ Thanks to you who tried to help me! :)
 
Last edited:
Status
Not open for further replies.
Top