Simple Script Help
Moderator: Moderators
- The Jackal
- Sergeant Major
- Posts: 101
- Joined: Wed May 07, 2003 10:09 am
- Contact:
Simple Script Help
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]
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]
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
Code: Select all
check_ff:
while ( true )
{
wait 60
if (local.FF==1)
{
iprintInbold "FF is ON"
}
else
{
iprintInbold "FF is OFF"
}
}
endWell I'd make a couple of changes:
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.
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
- The Jackal
- Sergeant Major
- Posts: 101
- Joined: Wed May 07, 2003 10:09 am
- Contact:
Thanks for the syntax, but I am still stuck
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.
[/b]
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.
- The Jackal
- Sergeant Major
- Posts: 101
- Joined: Wed May 07, 2003 10:09 am
- Contact:
Just another quick question.....
What are the differences between:
While (1) and While (true)?
Doesn't (1) the works the same as (true)?
While (1) and While (true)?
Doesn't (1) the works the same as (true)?
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?
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
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?
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?
Last edited by tltrude on Wed May 07, 2003 7:09 pm, edited 1 time in total.
Would be nice
It would be nice to know it FF is on or off while the map is loading--on the loading screen.
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:
This just casts the getcvar output to a regular integer (which you could use in calculations).
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)
- The Jackal
- Sergeant Major
- Posts: 101
- Joined: Wed May 07, 2003 10:09 am
- Contact:
It Works
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.
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.
iprint
I think "iprint" will crash it. Try, "iprintln" (thats an L not an I). It stands for iprint line.


