| 06-06-2004, 04:52 AM | #1 |
ok, i am making a voting system heavily based on Lord Vexorians InputMsgI function, this code is what i have come up with but when i try to save warcraft doesn't recognize me declaring my local variables, insetad it says "expected name" for all of them except for the first two.(better explination in the code its self) can any one tell my why it is doing this? Code:
function DialogHide takes nothing returns nothing
call DialogDisplayBJ( false, udg_Dialog[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer() )
endfunction
function Trig_Voting_System_Actions takes nothing returns nothing
local dialog array prompt
local trigger array trig
local string array button [color=DarkRed]<--- here down it doesn't recognize my variables.[/color]
local integer n=0
local integer i=0
local integer u = 0
local real x = 0
local integer bindx = 1
local integer result=0
local trigger counter = CreateTrigger()
set button[1] = "Noobie"
set button[2] = "Trainee"
set button[3] = "Normal"
set button[4] = "Gosu"
set button[5] = "UberGosu"
loop
exitwhen u>4
if GetPlayerSlotState(Player(u)) == PLAYER_SLOT_STATE_PLAYING then
set prompt[u] = DialogCreate()
call DialogSetMessage( prompt[u], "Vote for Difficulty" )
set trig[u] = CreateTrigger()
call TriggerRegisterDialogEvent( trig[u], prompt[u] )
call TriggerAddAction( trig[u], function DialogHide )
loop
exitwhen bindx>5
set trig[VoteNum(u+2,bindx)] = CreateTrigger()
call TriggerRegisterDialogButtonEvent( trig[VoteNum(u+2, bindx)], DialogAddButton( prompt[u], button[bindx] ) )
set bindx=bindx+1
endloop
call DialogDisplay( Player(u), prompt[u], true)
endif
set u = u + 1
endloop
set u = 0
call StartTimerBJ( udg_difficulty_timer, false, 20.00 )
call TriggerRegisterTimerExpireEventBJ( counter, udg_difficulty_timer )
loop
exitwhen u>4 or GetTriggerEvalCount(counter)>1
loop
exitwhen GetTriggerEvalCount(trig[u]) > 0 or GetPlayerSlotState(Player(u)) != PLAYER_SLOT_STATE_PLAYING or GetTriggerEvalCount(counter)>1
call TriggerSleepAction(0)
endloop
set u = u + 1
endloop
set i=0
loop
exitwhen i>3
call DialogClear(prompt[i])
call DialogDestroy(prompt[i])
set prompt[i]=null
set i = i + 1
endloop
set i = 0
set n = 0
loop
exitwhen n>3
if GetPlayerSlotState(Player(n)) == PLAYER_SLOT_STATE_PLAYING then
loop
exitwhen i>5
if GetTriggerEvalCount(trig[VoteNum(n+2,i)]) > 0 then
set result = result + i
endif
call DestroyTrigger(trig[i])
set trig[i] = null
set i=i+1
endloop
set x = x + 1
endif
endloop
set x = I2R(i)/x
if x < 2.00 then
call UberDisp(0.52, -1.00, 5.00, "|c0080ffffNoobie|r difficulty has been chosen!!")
set udg_attacker_number = ( udg_attacker_number - 15 )
elseif x < 3 then
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_682" )
set udg_attacker_number = ( udg_attacker_number - 10 )
elseif x < 4 then
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_681" )
elseif x<5 then
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_680" )
set udg_attacker_number = ( udg_attacker_number + 5 )
else
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_679" )
set udg_attacker_number = ( udg_attacker_number + 10 )
endif
call StartTimerBJ( udg_Gameexplain, false, 10.00 )
call CreateTimerDialogBJ( GetLastCreatedTimerBJ(), "TRIGSTR_683" )
set udg_timer[3] = GetLastCreatedTimerDialogBJ()
call TriggerSleepAction( 10.00 )
call ClearTextMessagesBJ( GetPlayersAll() )
call TriggerExecute( gg_trg_Respawn )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction |
| 06-06-2004, 09:12 AM | #2 |
It gets totally confused by your call: Code:
DialogAddButton( prompt[u], button[bindx]) Code:
native DialogAddButton takes dialog whichDialog, string buttonText, integer hotkey returns button How did I find this out then? I used JEdit 1.5, which ran the pjass syntax checker for me, which found the call to DialogAddButtan. I then asked JEdit to go and find the definition of the DialogAddButton for me. :> |
| 06-06-2004, 02:33 PM | #3 |
lol wow, i did exactly the same thing, but it still won't recognize my local variable... |
| 06-06-2004, 06:14 PM | #4 |
You can't have names for something that are extensions of handle. Button is an extension of handle, so what you did is almost exatly identical to this line of code. Code:
local integer string = 5 That isn't legal because string is a primitivie type so you can't have a variable named string. |
