HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

WE Crash w/ Code

01-14-2007, 10:59 AM#1
ixmike88
Whenever I try saving the editor with this code it crashes, could anyone assist me with possible bugs?

Collapse JASS:
function mvpfuncA takes nothing returns nothing
    local integer x = 1
    loop
        exitwhen x>12
        set udg_PlayerScores[x]=0
        set x=x+1
endloop
set x=2
    loop
        exitwhen x>12
        if(x==7) then
            call DoNothing()
         else
            set udg_PlayerScores[x]=I2R(udg_Stats_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
            x=x+1
    endloop
set x=2
local real b=2
    loop
        set b=2
        exitwhen x>12
        if(x==7) then
            call DoNothing()
        else
            loop
                exitwhen b>12
                if(b==7) then
                    call DoNothing()
                else if(x==b) then
                    call DoNothing()
                else if(x>b) then
                    set udg_MVP=Player(x)
                endif
            endif
        endif   
        set b=b+1
endloop
endif
set x=x+1
endloop
    call DisplayTextToForce(GetPlayersAll(),("Most valuable player is: |CFFFF0303"+GetPlayerName(udg_MVP)))
    call DisplayTextToForce(GetPlayersAll(),"Scores...")
    set x = 2
    loop
        exitwhen x>12
        if (x==7)
            call DoNothing()
        else
            call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(udg_MVP)+R2S(udg_PlayerScores[x])))
        endif
        set x=x+1
    endloop
call RemovePlayer(udg_MVP)
set udg_MVP=null
endfunction

function InitTrig_mvpfunc takes nothing returns nothing
local trigger mvpfunc takes nothing returns nothing
call TriggerAddAction(mvpfunc, fuction mvpfuncA)
set mvpfunc=null
endfunction
01-14-2007, 11:06 AM#2
Captain Griffen
Missing endif.
01-14-2007, 11:11 AM#3
ixmike88
I added the missing endif, WE still errors when I attempt to enable the trigger.

Collapse JASS:
    loop
        exitwhen x>12
        if(x==7) then
            call DoNothing()
         else
            set udg_PlayerScores[x]=I2R(udg_Stats_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
            x=x+1
    endif
    endloop
01-14-2007, 11:15 AM#4
DioD
Use jass craft from resources section
01-14-2007, 11:31 AM#5
Chocobo
Collapse JASS:
    loop
        exitwhen x>12
        if(x==7) then
            call DoNothing()
         else
            set udg_PlayerScores[x]=I2R(udg_Stats_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
            x=x+1
    endloop

Missing : Endif, set x=x+1


Collapse JASS:
    loop
        set b=2
        exitwhen x>12
        if(x==7) then
            call DoNothing()
        else
            loop
                exitwhen b>12
                if(b==7) then
                    call DoNothing()
                else if(x==b) then
                    call DoNothing()
                else if(x>b) then
                    set udg_MVP=Player(x)
                endif
            endif
        endif   
        set b=b+1
endloop

Missing endif again and missing one endloop.


Collapse JASS:
    loop
        exitwhen x>12
        if (x==7)
            call DoNothing()
        else
            call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(udg_MVP)+R2S(udg_PlayerScores[x])))
        endif
        set x=x+1
    endloop

Missing x=7 instead of x==7, and missing then.

Collapse JASS:
call RemovePlayer(udg_MVP)

Missing one argument (player game result).


Collapse JASS:
local trigger mvpfunc takes nothing returns nothing

Not allowed.



Collapse JASS:
call TriggerAddAction(mvpfunc, fuction mvpfuncA)

function instead of fuction.



Collapse JASS:
function mvpfuncA takes nothing returns nothing
    local integer x = 1
    local real b=2
    loop
        exitwhen x>12
        set udg_PlayerScores[x]=0
        set x=x+1
endloop
set x=2
    loop
        exitwhen x>12
        if(x==7) then
            call DoNothing()
         else
            set udg_PlayerScores[x]=I2R(udg_Stats_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
            set x=x+1
        endif
    endloop
set x=2
    loop
        set b=2
        exitwhen x>12
        if(x==7) then
            call DoNothing()
        else
            loop
                exitwhen b>12
                if(b=!7 and x=!b and x<b) then
                set udg_MVP=Player(x)
             set b=b+1
endif
endloop
set x=x+1
    call DisplayTextToForce(GetPlayersAll(),("Most valuable player is: |CFFFF0303"+GetPlayerName(udg_MVP)))
    call DisplayTextToForce(GetPlayersAll(),"Scores...")
    set x = 2
    loop
        exitwhen x>12
        if x==7 then
            call DoNothing()
        else
            call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(udg_MVP)+R2S(udg_PlayerScores[x])))
        endif
        set x=x+1
    endloop
//call RemovePlayer(udg_MVP)
set udg_MVP=null
endfunction

function InitTrig_mvpfunc takes nothing returns nothing
local trigger mvpfunc
call TriggerAddAction(mvpfunc, function mvpfuncA)
set mvpfunc=null
endfunction

3 errors still there :

-> Missing endloop in loop-endloop
-> if(b=!7 and x=!b and x<b) differant types.
-> Disabled call RemovePlayer(udg_MVP)
01-14-2007, 11:46 AM#6
ixmike88
Thanks for the help Chocobo, still trying to remember the simple JASS syntax errors :(.

Which parameter should be used in RemovePlayer() to have no effect on the game? PLAYER_GAME_RESULT_NEUTRAL? Or is there none?
01-14-2007, 11:53 AM#7
Chocobo
Quote:
Originally Posted by ixmike88
Thanks for the help Chocobo, still trying to remember the simple JASS syntax errors :(.

Which parameter should be used in RemovePlayer() to have no effect on the game? PLAYER_GAME_RESULT_NEUTRAL? Or is there none?

Do you know first, what exactly RemovePlayer() does?

btw the parameters are :
PLAYER_GAME_RESULT_VICTORY
or
PLAYER_GAME_RESULT_DEFEAT

I don't know for what you are going to use this.
01-14-2007, 12:14 PM#8
ixmike88
I have 6 compile errors which I cannot figure out:

Line 820: Expected 'endif'
Line 823: Expected a variable name
Line 829: Expected a name
Line 830: Expected a name
Line 832: Expected a variable name
Line 833: Expected 'endloop'

Collapse JASS:
function mvpfuncA takes nothing returns nothing
local integer x=1
    loop
        exitwhen x>12
        set udg_PlayerScores[x]=0
        set x=x+1
endloop
set x=2
    loop
        exitwhen x>12
        if(x==7) then
            call DoNothing()
         else
            set udg_PlayerScores[x]=I2R(udg_Stat_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
            set x=x+1
    endif
    endloop
set x=2 //[b]line 820[/b]
local integer b=2
    loop
        set b=2 //[b]line 823[/b]
        exitwhen x>12
        if(x==7) then
            call DoNothing()
        else
            loop
                exitwhen b>12 //[b]line 829[/b]
                if(b=!7 and x=!b and x>b) then //[b]line 830[/b]
                    set udg_MVP=Player(x)
            set b=b+1 //[b]line 832[/b]
                endif //[b]line 833[/b]
        endloop
    endif
    set x=x+1
endloop
    call DisplayTextToForce(GetPlayersAll(),("Most valuable player is: |CFFFF0303"+GetPlayerName(udg_MVP)))
    call DisplayTextToForce(GetPlayersAll(),"Scores...")
    set x = 2
    loop
        exitwhen x>12
        if (x==7) then
            call DoNothing()
        else
            call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(udg_MVP)+R2S(udg_PlayerScores[x])))
        endif
        set x=x+1
    endloop
set udg_MVP=null
endfunction

function InitTrig_mvpfunc takes nothing returns nothing
local trigger mvpfunc = CreateTrigger()
call TriggerAddAction(mvpfunc, function mvpfuncA)
set mvpfunc=null
endfunction
01-14-2007, 12:26 PM#9
Chocobo
I said, 3 errors missing because I don't know really how it will end :

3 errors still there :

-> Missing endloop in loop-endloop
-> if(b=!7 and x=!b and x<b) differant types.
-> Disabled call RemovePlayer(udg_MVP)


Line 832/823: Expected a variable name
Put the local at the top just after local integer x.
01-14-2007, 12:37 PM#10
ixmike88
Putting the declaration at the top solved 4 errors, and the not-equal should be != not =!, which solved the other two errors.

Thank you for your help.
01-14-2007, 12:49 PM#11
rulerofiron99
lol, use gui
01-14-2007, 01:34 PM#12
Fireeye
I wrote the function again and optimized it a bit.
That's all i changed

Trigger

Collapse JASS:
globals
    real array udg_PlayerScores
    integer array udg_Stat_Ints
    integer array udg_Stat_Sacks
    integer array udg_Stat_Tackles
    integer array udg_Stat_Touchdowns
    integer array udg_Stat_YardsGained
    player udg_MVP = null
endglobals

function mvpfuncA takes nothing returns nothing
    local integer x=1
    local integer b=2
    loop
        exitwhen x>12
        set udg_PlayerScores[x]=0
        set x=x+1
    endloop
    set x=2
    loop
        exitwhen x>12
        if(x!=7) then
            set udg_PlayerScores[x]=I2R(udg_Stat_Ints[x]*3)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Sacks[x]+udg_Stat_Tackles[x])
            set udg_PlayerScores[x]=udg_PlayerScores[x]+I2R(udg_Stat_Touchdowns[x]*2)
            set udg_PlayerScores[x]=udg_PlayerScores[x]+(udg_Stat_YardsGained[x]/3)
        endif
        set x=x+1
    endloop
    set x=2 //[b]line 820[/b]
    loop
        set b=2 //[b]line 823[/b]
        exitwhen x>12
        if(x!=7) then
            loop
                exitwhen b>12
                if(b!=7)and(x!=b)and(x>b) then
                    set udg_MVP=Player(x)
                endif
                set b=b+1
            endloop
        endif
        set x=x+1
    endloop
    call DisplayTextToForce(GetPlayersAll(),("Most valuable player is: |CFFFF0303"+GetPlayerName(udg_MVP)))
    call DisplayTextToForce(GetPlayersAll(),"Scores...")
    set x = 2
    loop
        exitwhen x>12
        if (x!=7) then
            call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(udg_MVP)+R2S(udg_PlayerScores[x])))
        endif
        set x=x+1
    endloop
//you don't have to nullify a gobal variable.
endfunction

01-14-2007, 08:22 PM#13
Vexorian
Quote:
Originally Posted by rulerofiron99
lol, use gui
...

_________
Whatever, just get yourself something nice like WEHelper so your editor won't crash if you make mistakes in code and it will actually tell you correct error messages in the correct line numbers
01-14-2007, 10:50 PM#14
darkwulfv
Quote:
Originally Posted by rulerofiron99
lol, use gui

Failure to the extreme.