Page 1 of 1

iprintln prints twice?

Posted: Mon Jul 30, 2007 6:40 pm
by Duke

Code: Select all

main:
level waittill spawn
thread welcomemsg
wait 10.0
end
welcomemsg:
wait 30.0
iprintln "Welcome to my server"
wait 10.0
iprintln "Enjoy it"
wait 10.0
iprintln "www.myclan.com"
wait 300.0
goto welcomemsg
end
why does this print each line twice?
the output looks like this for me

Welcome to my server
Welcome to my server


Enjoy it
Enjoy it


www.myclan.com
www.myclan.com

any help would be appreciated

Posted: Mon Jul 30, 2007 9:37 pm
by erick
If you only want the message to print once take out the "goto welcomemsg"
Then I will only print once at the beginning to the map.
Also what it 'wait 10' supposed to do after thread welcomemsg? It doesnt do nothing to what happens in the map.
Another tip-- When using wait commands and you want it to wait for example '10' you dont need to add the extra decimal.

Posted: Mon Jul 30, 2007 10:05 pm
by wacko
Using 'goto' isn't the pretty way, I was told, so I'd do

Code: Select all

welcomemsg:
wait 20
while(1)
	{
	iprintln "Welcome to my server"
	wait 2
	iprintln "Enjoy it"
	wait 2
	iprintln "www.myclan.com"
	wait 20
	}
end
Then, neither with ur nor with my script, I get these doubled lines, so I can't help much.

@erick: I think, this script is supposed to print these lines repeately, but each line just once each time. So we can't delete the goto without replacement :wink:

Posted: Mon Jul 30, 2007 11:28 pm
by tltrude
"thread welcomemsg" probably runs everytime a player joins the game. Was there two people when you tested it? Moving that line to level waittill prespawn might fix it.

Posted: Tue Jul 31, 2007 12:19 am
by erick
Oops! My mistake :oops:
I always wondered what 'while(1)' meant.
Now i know :D

Posted: Tue Jul 31, 2007 1:44 am
by bdbodger

Code: Select all

main: 
level waittill spawn 
thread welcomemsg 
wait 10.0 
end 
welcomemsg: 
wait 30.0 
iprintln "Welcome to my server" 
wait 10.0 
iprintln "Enjoy it" 
wait 10.0 
iprintln "www.myclan.com" 
wait 300.0 
goto welcomemsg 
end
The only way that can print twice is if you had forgot to but the end after the wait 10.0 or ran the main thread twice so it is not that . Use the while loop though goto has its uses but not here .

Posted: Wed Aug 01, 2007 5:30 pm
by Duke
hey thanks everyone however it still prints twice:/ maybe it has something to do with it being in the DMprecache.scr? dunno very new to this scripting thing

also I have another very newb question ..... umm what is a cvar? I would have to know what it is before i could use it i guess lol


anyway thanks guys i was not sure about some things in the scripting tutorials.

For example does every .scr have to contain a main method or is that optional(and if optional does that mean that moh collects all main methods and runs them from all scripts?)

threads and methods confuse me a little bit.

anyway thanks again everyone so far all help is just that very good help.

Posted: Wed Aug 01, 2007 7:40 pm
by erick
Just some reference for new scripters like you. This is where I learned
http://gronnevik.se/rjukan
And at .MAP ofcourse 8-)

Posted: Thu Aug 02, 2007 12:36 am
by tltrude
DMprecache.scr is a game script and should not be altered. Typically, mymapname_precache.scr is used to precache (pre-load) models and large sound files -- so there is no pause to load them during the game.

A "cvar" is a client variable. They are set by the game, but you can set some of them too. Here is an example.

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"


Not all scripts have a main: thread. Most scripts are loaded by your mymapname.scr script as they are needed. Look for the "exec" lines.

Code: Select all

// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm2"

	// call additional stuff for playing this map round based is needed
	if(level.roundbased)
		thread roundbasedthread

	level waittill prespawn

	//*** Precache Dm Stuff
	exec global/DMprecache.scr // pre-load the normal DM game models.

	exec global/door_locked.scr::lock  // runs a thread named "lock:" in a global folder script.
	level.script = maps/dm/mohdm2.scr
	exec global/ambient.scr mohdm2  // adds background sounds
	
	level waittill spawn

end

//-----------------------------------------------------------------------------

roundbasedthread:

	// Can specify different scoreboard messages for round based here. 


	level waitTill prespawn

	level waittill spawn

	// set the parameters for this round based match
	level.dmrespawning = 0 // 1 or 0
	level.dmroundlimit = 5 // round time limit in minutes
	level.clockside = kills // set to axis, allies, kills, or draw

	level waittill roundstart

end
That script is typical for a multiplayer map -- in this case, mohdm2 (Destroyed Village). I don't know what you mean by "method", but threads start with a name and a collon like this, "mythread:". And, they end with the word "end". The "//" marks are for script comments and are not read by the game.

Hope that helps!

Posted: Mon Aug 06, 2007 1:56 pm
by Duke
hmmm ?? well more than half the scripts I have dled have all used the DMprecache for exec global/theirscropts.scr if not there where should i do this?


thanks again for the help

DMprecache

Posted: Tue Aug 07, 2007 3:55 am
by tltrude
Ok, I can see what you mean. People use the DMprecache script because it gets read for every multiplayer game. The game will read every copy of the DMprecache script it can find -- starting with the one in the global folder of Pak0.pk3, and working its way through the other pk3s in numerical and alphabetical order (one named zzz.pk3 would be read last).

So, you don't have to rewrite the orginal DMprecache script in pak0. Just make a new DMprecache.scr, put it in a folder named "global", and compress it in a new pk3 file (like zzz.pk3).

The game will also read any DMprecache scripts it finds in loose folders. So, if you have another "global" folder that is not in a pk3, it will read that one too.