• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Well, im new on jass, so im having problems

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2008
Messages
279
Hey, i converted to custom script, understanded everything, BUT, still have a bug that i cant understand.
JASS:
function Trig_Green_Press_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Green_Press_Actions takes nothing returns nothing
local integer array greeninteger
local unit array greenunit
local integer array streaks
    set greeninteger[1] = ( greeninteger[1] + 1 )
    call CreateNUnitsAtLoc( 1, 'h000', GetTriggerPlayer(), GetRectCenter(gg_rct_Explode_Green), bj_UNIT_FACING )
    set greenunit[greeninteger[1]] = GetLastCreatedUnit()
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', greenunit[greeninteger[1]] )
    set streaks[GetConvertedPlayerId(GetOwningPlayer(greenunit[greeninteger[1]]))] = (streaks[GetConvertedPlayerId(GetOwningPlayer(greenunit[greeninteger[1]]))] - 1 )
    call LeaderboardSetPlayerItemValueBJ( GetOwningPlayer(udg_GreenUnit[greeninteger[1]]), GetLastCreatedLeaderboard(), streaks[GetConvertedPlayerId(GetOwningPlayer(greenunit[greeninteger[1]]))] )
    call LeaderboardSortItemsBJ( GetLastCreatedLeaderboard(), bj_SORTTYPE_SORTBYVALUE, false )
endfunction

//===========================================================================
function InitTrig_Green_Press takes nothing returns nothing
    set gg_trg_Green_Press = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Green_Press, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Green_Press, Condition( function Trig_Green_Press_Conditions ) )
    call TriggerAddAction( gg_trg_Green_Press, function Trig_Green_Press_Actions )
endfunction
Says the problem is Expecting a name.Here is the line with the problem.
JASS:
call LeaderboardSetPlayerItemValueBJ( GetOwningPlayer(udg_GreenUnit[greeninteger[1]]), GetLastCreatedLeaderboard(), streaks[GetConvertedPlayerId(GetOwningPlayer(greenunit[greeninteger[1]]))] )
 
Level 11
Joined
May 16, 2007
Messages
288
After running Jass Craft syntax checker on it, I didn't get any problem that said it was expecting a name, however there is something that you should check, it might be causing it:

JASS:
( GetOwningPlayer(udg_GreenUnit[greeninteger[1]])

Check if udg_GreenUnit is an array variable, if it's not, that's the problem.

The code could also be optimized and there are leaks that should be cleaned, but I suppose you'll do it later.
 
Level 6
Joined
Mar 20, 2008
Messages
208
JASS:
function Trig_Green_Press_Conditions takes nothing returns boolean    
         return GetSpellAbilityId() == 'A000' 
endfunction

function Trig_Green_Press_Actions takes nothing returns nothing
local integer array greeninteger
local unit array greenunit
local integer array streaks    

local player p = GetTriggerPlayer()
local unit u = CreateNUnitsAtLoc( 1, 'h000', p, GetRectCenter(gg_rct_Explode_Green), 0)   
local integer pid = GetConvertedPlayerId(p)
local leaderboard lb = GetLastCreatedLeaderBoard()

set greeninteger[1] = greeninteger[1] + 1
set greenunit[greeninteger[1]] = u 

call UnitApplyTimedLife(u, 'BTLF', 1)    

set streaks[pid] = streaks[pid]-1

set p = GetOwningPlayer(udg_GreenUnit[greeninteger[1]])

call LeaderboardSetItemValue(lb, LeaderboardGetPlayerIndex(lb,p), streaks[pid])

call LeaderboardSortItemsByValue(lb, false)

set u = null
set p = null
set lb = null
set greenunit = null
endfunction

Just a side note, using local arrays = not stored for later, you needa global array for that.
 
Status
Not open for further replies.
Top