Please help about LocalPlayer Problem

Bankde

Member
Reaction score
20
I've create system to give hero exp and gold when killing unit.

Everything (Gold, Exp, Gem (It's variable)) works very well except for the floating text which I used GetLocalPlayer(). The floating text isn't appear at all.
When I remove GetLocalPlayer(), the floating text appears for all players. But I want only specific player to see it. So I've to use GetLocalPlayer().
I've tried to used a BJ function for floating text visibility but it's still have problem.
Doesn't GetLocalPlayer() work in map-specific custom script (Code above all trigger) ??

Code:
/////////////////////////////////////////////////////////////////////////////////
//////////////Below are the system of Experience + Gold + Gem////////////////////
/////////////////////////////////////////////////////////////////////////////////

[COLOR="red"]function EXPCalculator takes integer Low, integer High returns integer
    local real TempInt1 = (((High + 1) - Low) / 3)
    local integer TempInt2
    local integer TempInt3
    if (GetRandomInt(1,5) == 1) then
    return GetRandomInt(Low,High)
    else
    set TempInt2 = ( Low + R2I(TempInt1) )
    set TempInt3 = ( High + R2I(TempInt1) )
    return GetRandomInt(TempInt2, TempInt3)
    endif
    return 0
endfunction
You don't have to care about mathematics[/COLOR]

function EXP takes integer GdLow, integer GdHigh, integer ExpLow, integer ExpHigh, integer Gem, location DiePoint returns nothing
    local location TempLoc
    local integer Gold = EXPCalculator(GdLow, GdHigh)
    local integer Experience = EXPCalculator(ExpLow, ExpHigh)
    local string TempString = null
    local integer Index = 0
    local force TempPlayerGroup
    if (Gold > 0) then
        set TempString = "|c00666600" + TempString + "+ " + I2S(Gold) + " Gold|r\n"
    endif
    if (Gem > 0) then
        set TempString = "|c0000ff66" + TempString + "+ " + I2S(Gem) + " Gem|r\n"
    endif
    if (Experience > 0) then
        set TempString = "|c00660099" + TempString + "+ " + I2S(Experience) + " Exp|r"
    endif
    loop
        exitwhen Index > 11
        set TempLoc = GetUnitLoc(udg_Hero_of_Player[Index])
        if ( DistanceBetweenPoints(TempLoc, DiePoint) <= 1000  ) then
            call AddHeroXPSwapped( Experience, udg_Hero_of_Player[Index], false )
            call AdjustPlayerStateBJ( Gold, ConvertedPlayer(Index), PLAYER_STATE_RESOURCE_GOLD )
            set udg_Hero_Resource_Gem[Index] = ( udg_Hero_Resource_Gem[Index] + Gem )
            call ForceAddPlayer(TempPlayerGroup, GetOwningPlayer(udg_Hero_of_Player[Index]))
        endif
        set Index = Index + 1
    endloop
    if (IsPlayerInForce(GetLocalPlayer(), TempPlayerGroup)) then
        set TempLoc = PolarProjectionBJ(DiePoint, 80.00, 45.00)
        call CreateTextTagLocBJ( TempString, TempLoc, 0, 8, 100, 100, 100, 0 )
        call SetText (GetLastCreatedTextTag(), 2, 30 )
        call RemoveLocation (TempLoc)
    endif
    call RemoveLocation (DiePoint)
endfunction

Code:
Chicken
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Triggering unit)) Equal to Chicken
    Actions
        Set TempPoint = (Position of (Triggering unit))
        Custom script:   call EXP (1,3,0,2,0, udg_TempPoint)
        If ((Random integer number between 1 and 100) Less than or equal to 3) then do (Item - Create [001] Chicken Claw at TempPoint) else do (Do nothing)
        Custom script:   call RemoveLocation (udg_TempPoint)

+rep to those helpful reply. Thank you so much
(Don't care much about mathematics in system)
 

Azlier

Old World Ghost
Reaction score
461
The problem here is that you're both creating and removing a handle in the local player block. Said handle is the location created by
Code:
set TempLoc = PolarProjectionBJ(DiePoint, 80.00, 45.00)

You can't remove or create most handles locally without a desync. You need to do the location shenanigans outside of the block. Text tags are okay to do locally. They're special.
 

Bankde

Member
Reaction score
20
I've tried changing Set Point Function outside the local condition but it still has no floating text (Gold and Exp is still receieved correctly)

Anyway +rep for replying
Sorry for this slow reply, I've to go to school :)
 

Bankde

Member
Reaction score
20
Code:
function EXP takes integer GdLow, integer GdHigh, integer ExpLow, integer ExpHigh, integer Gem, location DiePoint returns nothing
    local location TempLoc
    local integer Gold = EXPCalculator(GdLow, GdHigh)
    local integer Experience = EXPCalculator(ExpLow, ExpHigh)
    local string TempString = null
    local integer Index = 0
    local force TempPlayerGroup
    if (Gold > 0) then
        set TempString = "|c00666600" + TempString + "+ " + I2S(Gold) + " Gold|r\n"
    endif
    if (Gem > 0) then
        set TempString = "|c0000ff66" + TempString + "+ " + I2S(Gem) + " Gem|r\n"
    endif
    if (Experience > 0) then
        set TempString = "|c00660099" + TempString + "+ " + I2S(Experience) + " Exp|r"
    endif
    loop
        exitwhen Index > 11
        set TempLoc = GetUnitLoc(udg_Hero_of_Player[Index])
        if ( DistanceBetweenPoints(TempLoc, DiePoint) <= 1000  ) then
            call AddHeroXPSwapped( Experience, udg_Hero_of_Player[Index], false )
            call AdjustPlayerStateBJ( Gold, ConvertedPlayer(Index), PLAYER_STATE_RESOURCE_GOLD )
            set udg_Hero_Resource_Gem[Index] = ( udg_Hero_Resource_Gem[Index] + Gem )
[COLOR="red"]            call ForceAddPlayer(TempPlayerGroup, GetOwningPlayer(udg_Hero_of_Player[Index]))[/COLOR]
        endif
        set Index = Index + 1
    endloop
    set TempLoc = PolarProjectionBJ(DiePoint, 80.00, 45.00)
    if (IsPlayerInForce(GetLocalPlayer(), TempPlayerGroup)) then
        call CreateTextTagLocBJ( TempString, TempLoc, 0, 8, 100, 100, 100, 0 )
        call SetText (GetLastCreatedTextTag(), 2, 30 )
    endif
    call RemoveLocation (TempLoc)
    call RemoveLocation (DiePoint)
endfunction
(I've changed code to what Azlier had said.

Why is it null, am I misspelling or done something wrong ??

Still... +rep for all helper (Still having problem)
 

cleeezzz

The Undead Ranger.
Reaction score
268
where did you create the group?

iirc, adding a player doesn't create the force

set TempPlayerGroup = CreateForce()

for debug purposes in the future, add BJDebugMsg throughout the code and you can tell where the code stops (due to a null or something)
 

Bankde

Member
Reaction score
20
Thank you so much !!!!! I've never known that I need to CreateForce() at all (New Knowledge).

I had given you +rep and now cannot give anymore. Anyway Thank so much !!!

Problem Solved. (Not local player problem)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top