Page 1 of 2

Simple Script Help

Posted: Wed May 07, 2003 10:24 am
by The Jackal
I am new to this whole biz of scripting. I think it's sexy though. All I got in my head is some qBasic I learnt a couple a years ago on my DOS PC.
I am working on a script to perform a simple print command.

I would like the correct syntax and argument to display a looped message on screen if a condition is met.

For example.
The script with check to see if FF is on. And if Yes, it would display "TEXT". If NO, it would display "TEXT2"

And loop in at intervals (60secs)

I once saw an example on a message board that contained something like this:

local.ff = 0
get_cvar "g_teamdamage"

if (local.FF==1)
wait 5
iprintInbold "FF is ON"

else
wait 5
iprintInbold "FF is OFF"

Somewhere in it had the [/i][/b]While statement, I guess to perform the loop function.

Please help me. Once I get this I am on my way to more complex ones. [/i][/b]

Posted: Wed May 07, 2003 11:45 am
by Bjarne BZR

Code: Select all

check_ff:
   while ( true )
   {
      wait 60
      if (local.FF==1)
      {
         iprintInbold "FF is ON"
      }
      else
      {
         iprintInbold "FF is OFF" 
      }
   }
end
... for this to work, you must set the local.FF variable to the value of FF... or replace local.FF with a reference to the variable that controls FF ( I dont know what it is called... maby game.teamdamage or something ).

Posted: Wed May 07, 2003 2:38 pm
by jv_map
Well I'd make a couple of changes:

Code: Select all

check_ff:
   while (1)
   {
      local.FF = getcvar "g_teamdamage"
      if (local.FF==1)
      {
         iprintlnbold "FF is ON"
      }
      else
      {
         iprintlnbold "FF is OFF"
      }
      wait 5 // just for testing :)
   }
end
Although I'm not sure I don't think while (true) works. Also the command is iprintlnbold (with a 'l'), not iprintInbold (with a capital 'i'). These are just minor things though.

Thanks for the syntax, but I am still stuck

Posted: Wed May 07, 2003 5:57 pm
by The Jackal
I used that syntax and argument. It displays the message onscreen, like it should.

However, the problem is that it does not recognize the state of the cvar "teamdamage"

I turned FF on and restarted, but the script continued to print the text for "FF is OFF".

This is exactly as I have it in mp_malta_dm.scr

check_ff:
while (1)
{
local.FF = getcvar "g_teamdamage"
if (local.FF==1)
{
wait 15
iprintlnbold "Friendly Fire is ON"
}
else
{
wait 15
iprintlnbold "Friendly Fire is OFF"
}
wait 30
}
end

I think the problem lies in line 4. Please see how I can be helped.

Thanks. :roll: [/b]

Just another quick question.....

Posted: Wed May 07, 2003 6:04 pm
by The Jackal
What are the differences between:

While (1) and While (true)?

Doesn't (1) the works the same as (true)?

Posted: Wed May 07, 2003 6:39 pm
by jv_map
if (local.FF==1)

should be

if (local.FF=="1")

:oops:

Posted: Wed May 07, 2003 6:48 pm
by nihilo
thats odd, maybe you could explain this one to me jv

When it looks at local.FF it finds the char 1 (string 1, cause there's no char type) instead of the int value 1? In other words local.FF is equal the symbol "1" or "0" instead of the value 1 or 0?!? Seems bizarre.. do they do this for other things too?

guess

Posted: Wed May 07, 2003 7:04 pm
by tltrude
This is just a guess, but maybe "1" and "0" mean "on" and "off". Where as 1 and 0 would mean "true" and "false".

Why does it need to continually check if FF is on or off. Shouldn't it just check one time at the start of the round and then print the results in the timed loop?

Posted: Wed May 07, 2003 7:08 pm
by nihilo
I would think it would be easier to say on and off is the same as true and false. So light == on is the same as light == true. No need to have two different values, right? I don't really know, my experience with MoHAA scripting doesn't come close to many others here.

Would be nice

Posted: Wed May 07, 2003 7:13 pm
by tltrude
It would be nice to know it FF is on or off while the map is loading--on the loading screen.

Posted: Wed May 07, 2003 7:18 pm
by jv_map
Well you can't use the script to modify the loading screen, since the script is server side whereas the loading screen is client side.

getcvar returns a string, that's why you have to use if(local.ff=="1").
You can also use:

Code: Select all

local.ff = int(getcvar "g_teamdamage")
if(local.ff == 1)
This just casts the getcvar output to a regular integer (which you could use in calculations).

It Works

Posted: Wed May 07, 2003 7:25 pm
by The Jackal
Thanks guys, it works like a charm.

The reason I want it to check and then loop thought-out round is because we do not play Time Limit Rounds. We are a bunch of snipers that hide all night. So if we called the cvar was changed in between rounds, the message can display our rules with cvar status. I am our clan's best scripter and I don't know crap like you guys - GOD HELP US.

Take a look at this script I made. A simple one. It is supposed to print a set of messages when a client logs on, only on that client's screen. I only tested it on my game and not on a full server. Do you think it will do just what I want?

wait 5
$player[0] iprint "Welcome To <[OneX]> Snipers Only!"
if($player[1])
$player[1] iprint "Welcome To <[OneX]> Snipers Only!"
if($player[2])
$player[2] iprint "Welcome To <[OneX]> Snipers Only!"
if($player[3])
$player[3] iprint "Welcome To <[OneX]> Snipers Only!"
.....and so on, and so on.

Will it? Please tell me Yes. It it in the map script file.

Posted: Wed May 07, 2003 7:28 pm
by nihilo
ahh.. ok. I can see that. thx.

iprint

Posted: Wed May 07, 2003 8:07 pm
by tltrude
I think "iprint" will crash it. Try, "iprintln" (thats an L not an I). It stands for iprint line.

Posted: Wed May 07, 2003 8:17 pm
by jv_map
No, iprint is a valid command for the Player class.

The $player array starts indexing at 1 though, so $player[0] is NIL.

Jackal, I suppose you're looping that code or something?