Code bugging

cleeezzz

The Undead Ranger.
Reaction score
268
SOLVED i used d.destroy in a PUI struct

JASS:
scope KD initializer Init

globals
    private integer c = 0
endglobals

struct KDS
    //! runtextmacro PUI()
    player p
    timer t
    method onDestroy takes nothing returns nothing
        set .p = null
        call ReleaseTimer(.t)
        set .t = null
    endmethod
endstruct

private function Conditions takes nothing returns boolean
    return GetUnitPointValue(GetTriggerUnit()) == 100
endfunction

private function Add takes nothing returns nothing
    set c = c + Kills[GetPlayerId(GetEnumPlayer())]
endfunction

private function End takes nothing returns nothing
    local KDS d = GetCSData(GetExpiredTimer())
    set MKCount[GetPlayerId(d.p)] = 0
    set KDS[Hero[GetPlayerId(d.p)]] = 0
    call d.destroy()
endfunction

private function Actions takes nothing returns nothing
    local multiboarditem mbi = null
    local integer kid = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
    local integer did = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    local integer bounty = 0
    local integer i = 0
    local string s
    local KDS d = KDS[Hero[kid]]
    if GetOwningPlayer(GetKillingUnit()) != GetOwningPlayer(GetTriggerUnit()) then
        if GetPlayerSlotState(GetOwningPlayer(GetTriggerUnit())) == PLAYER_SLOT_STATE_PLAYING and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) and GetUnitPointValue(GetTriggerUnit()) == 100 then
            if GetPlayerSlotState(GetOwningPlayer(GetKillingUnit())) == PLAYER_SLOT_STATE_PLAYING then   
                set Deaths[did] = ( Deaths[did] + 1 )
                set TDeaths[did] = ( TDeaths[did] + 1 )
                set MKCount[kid] = MKCount[kid] + 1
                if d == 0 then
                    set d = KDS.create()
                    set d.t = NewTimer()
                    set d.p = Player(kid)
                    set KDS[Hero[kid]] = d
                    call SetCSData(d.t,d)
                else
                    call PauseTimer(d.t)
                endif
                call TimerStart(d.t,1,false,function End)
                if MKCount[kid] > 3 then
                    set MKCount[kid] = 3
                endif
                if MKCount[kid] > 1 then
                    call StartSound(MKSound[MKCount[kid]] )
                    call SetPlayerState(GetOwningPlayer(GetKillingUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetKillingUnit()), PLAYER_STATE_RESOURCE_GOLD) + MKGold[MKCount[kid]] )
                    set s = PlayerColors[kid] + GetPlayerName(GetOwningPlayer(GetKillingUnit())) + "|r"  + MKAnnounce[MKCount[kid]]
                    if IsPlayerInForce(GetLocalPlayer(),bj_FORCE_ALL_PLAYERS) then
                        call DisplayTimedTextToPlayer( GetLocalPlayer(), 0,0,10.00, s)
                    endif
                endif
            endif
        endif
    endif     
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( trig, Condition( function Conditions))
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


the mk is the multikill, if you get 2 kills in less than 1s, you get a double kill and you get another second to get a triple kill, but for some reason, some times the variable does not reset and i get double kills out of the blue. whats wrong?
 
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