HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help with jass I dont know what is wrong

09-09-2006, 11:48 AM#1
Fr0zenLord
I want this to happen, every .25 seconds it sets udg_a = udg_a + 1 (Counting up)
if its over 50> display text
if its equal to 5 display text
if its equal to 15 display text
FIRST trigger'
Collapse JASS:
function Trig_RandomString_Actions takes nothing returns nothing
 local string a = "m"
 local string b = "a"
 local string c = "n"
 local string z = "i"
 local string d = (c+b)
 local string f = (a+z)
 local string g = (c+b)
 set udg_a = ( udg_a + 1)
     call DisplayTextToForce( GetPlayersAll(), I2S(udg_a) )
if udg_a > 50 then
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      endif
     elseif udg_a==5 then
      call DisplayTextToForce( GetPlayersAll(), g )
      call DisplayTextToForce( GetPlayersAll(), f )
      endif
     elseif udg_a==15 then
     endif
     else udg_a==7
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      endif
     endif

//===========================================================================
function InitTrig_RandomString takes nothing returns nothing
    set gg_trg_RandomString = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_RandomString, .25 )
    call TriggerAddAction( gg_trg_RandomString, function Trig_RandomString_Actions )
endfunction

Oh btw, I have 99% no idea what im doing with the if statements lolz...
is there a better way to randomly display strings? (e.g scrambling words, man, nma, nam, amn, anm etc...)

OK

I did that

Now I get 2 errors, "No endif" and expected end of line

Collapse JASS:
function Trig_RandomString_Actions takes nothing returns nothing
 local string a = "m"
 local string b = "a"
 local string c = "n"
 local string z = "i"
 local string d = (c+b)
 local string f = (a+z)
 local string g = (c+b)
 set udg_a = ( udg_a + 1)
     call DisplayTextToForce( GetPlayersAll(), I2S(udg_a) )
if udg_a > 50 then
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     elseif udg_a==5 then
      call DisplayTextToForce( GetPlayersAll(), g )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     elseif udg_a==15 then
     
     else udg_a==7(Where it highlights the "expected end of line" problem
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     endif(Where it highlights the "Endif" problem)
endfunction

what is wrong with it now?
09-09-2006, 11:57 AM#2
Captain Griffen
You only need a endif at the end of the if/elseif/else statement.

You need an endfunction at the end.
09-09-2006, 12:12 PM#3
aquilla
else udg_a==7 should be elseif udg_a==7 then
09-09-2006, 12:41 PM#4
The)TideHunter(
Change
Collapse JASS:
function Trig_RandomString_Actions takes nothing returns nothing
 local string a = "m"
 local string b = "a"
 local string c = "n"
 local string z = "i"
 local string d = (c+b)
 local string f = (a+z)
 local string g = (c+b)
 set udg_a = ( udg_a + 1)
     call DisplayTextToForce( GetPlayersAll(), I2S(udg_a) )
if udg_a > 50 then
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     elseif udg_a==5 then
      call DisplayTextToForce( GetPlayersAll(), g )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     elseif udg_a==15 then
     
     else udg_a==7(Where it highlights the "expected end of line" problem
          call DisplayTextToForce( GetPlayersAll(), d )
      call DisplayTextToForce( GetPlayersAll(), f )
      
     endif(Where it highlights the "Endif" problem)
endfunction

to

Collapse JASS:
function Trig_RandomString_Actions takes nothing returns nothing
    local string a = "m"
    local string b = "a"
    local string c = "n"
    local string z = "i"
    local string d = (c+b)
    local string f = (a+z)
    local string g = (c+b)
    set udg_a = udg_a + 1
    call DisplayTextToForce( GetPlayersAll(), I2S(udg_a) )
    if(udg_a > 50) then
        call DisplayTextToForce( GetPlayersAll(), d )
        call DisplayTextToForce( GetPlayersAll(), f )
    elseif(udg_a==5) then
        call DisplayTextToForce( GetPlayersAll(), g )
        call DisplayTextToForce( GetPlayersAll(), f )
    elseif(udg_a==15) then
        // Do something, display text that you wanted to display
    elseif(udg_a==7) then
        call DisplayTextToForce( GetPlayersAll(), d )
        call DisplayTextToForce( GetPlayersAll(), f )
    endif
endfunction

Also, watch out with your indents.
The standard is: add 4 lines after you write: function/if/loop/else/elseif, and remove 4 lines after you write: endfunction/endif/endloop.
09-09-2006, 08:24 PM#5
Fr0zenLord
Sorry, What is an indent?

- also, how many if then else statements can I use ? in the same thing e.g

if - then
elseif - then
else if -then
endif
if - then
elseif- then
elseif -then
endif
etc....?


Ohhh! I see what you mean by indents ty

Thanks tide XD
09-09-2006, 08:26 PM#6
Captain Griffen
Collapse JASS:
not indented
 indented by 1
  indented by 2
   indented by 3
    indented by 4 - standard
09-09-2006, 08:49 PM#7
The)TideHunter(
You can have as many If statements as you want, and as many elseif/else's, only.
But be carful for things like:
Collapse JASS:
else if
elseif then
else then

Only valid ones are, for ifs:
Collapse JASS:
if
then
and
or
else
elseif
endif
09-09-2006, 08:58 PM#8
Fr0zenLord
Can I please ask something confusing lol..

How would i write in jass

I wanna kind of make a trivia thing
so I need to know

how to do this, first, turn off jass? lol

how to type -start, and every 60 seconds, it says some words...

and how to set that word into a chat string... then if a player says that word...
turn the trigger off...
then turn it back on after

Basically, Player gets the word right +1 point... but he cant say it again nor can any other players...

lolz I kinda wanna get this down,but I cant find any stuff in tutorials
about that

Also, at map init, how do I get a players name?

and display it like this call DisplayTextToForce( GetPlayersAll(), Players name?? )

would I have to set
his name into a string? then call that string?

If anyone could help that'd be great
09-09-2006, 10:59 PM#9
The)TideHunter(
I dont understand your first question, but to get a players name and display it to all players, simply use:

Collapse JASS:
call DisplayTextToForce( GetPlayersAll(), GetPlayerName(Player(0))

0 = Player 1
1 = Player 2
2 = Player 3
etc.
So Player(0) = Player 1
Confusing but true.
09-10-2006, 12:07 AM#10
shadow1500
Collapse JASS:
call DisplayTextToForce( GetPlayersAll(), GetPlayerName(Player(0))
You are missing an end parenthesies there. Also,
Collapse JASS:
call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetPlayerName(Player(0)))
is a more efficient way to do it.