[Noob@work]Needs help .

Post your scripting questions / solutions here

Moderator: Moderators

KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

[Noob@work]Needs help .

Post by KC25m »

Hello everybuddy,

im new with MoH scripting but i have a big problem.
I need a script to print textes on the clientside.
Now its easy i think iprint "Hello User" .
But after a try in the console its write only Hello.
After a space ther write nothing.

I need the script to write from HLSW or ASE or my Python Script to the users.
Infos likes Time , How many player joinet today and so.

Can some one help me , please ?

Im german and my english is very bad so i dosent asked some one bevor.
But now its importent for me.

Lots of thanks.

Greets KC25m
Noob @ Work.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

It seems that the Linux version has a script parsing deficiency. I'm afraid you'll have to use underscores (the '_' char).

As to what you're trying to do, it's impossible with the MoHAA scripting. You'd have to establish RCON access on the server and use an UDP client to issue console commands to the server (the protocol is fairly simple). Which is, as far as I know, easily doable with Python. ;)
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

i use a Python Socket UDP to connect to the server ,
i send status , got the result back.
Test for new players and when some one comes in i will send Hello PlayerName ...
But when i send iprint "Hello "+str(Name) its displays only Hello.

i think this is a mistake of me so i tryed on server in console to write iprint "Hello Users" and ... its comes only Hello.

i dont will have _ i will have some spaces ...
so i think when i write a funktione vprint as script in moh i can use it over console , 2.

is it right ?
Noob @ Work.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hmm yah some bit somewhere in moh's code is somewhat narrow-minded... for some reason it'll only take one argument for any command sent via rcon and anything containing spaces is seen as 2 or more arguments.

It can be very annoying :(
Image
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

yea but when i write it : rcon say Hello USERNAME ... its works fine.

so i think i need qutes iprint "Hello \""+NAME+"\""
example :
iprint "Hello User"
so i have only 2 comands iprint and the string.

but , its dosent works.

From Game self when im on Server i write rcon iprint "Hello U" its dosent works,2.
Noob @ Work.
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

If your not using a script i would try just plain ol' rcon say "hello guys"

Try underscores like rookie said, It might change the underscore to a space :wink:
Image
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

To time i write over console with "rcon say xxxxxxxx" ...
i tryed with underscores , its dosent works.
Ther comes the underscores and no spaces :(

i saw a script that was for Foresight or an other scanner , ther was a simple routine for the server to print messages to all coordinaten.
Noob @ Work.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Ah my original reply was wrong (as you already mentioned). In fact what happens is that rcon strips quotes.. hence iprint "hello world" would become iprint hello world.. recognized as iprint with arguments hello and world. iprint takes only the first argument.

Say, on the other hand, takes multiple arguments.
say arg1 arg2 arg3 ... argn

That's why you can say something with spaces in between without using quotes.

That said, the only way I can think of to solve your problem is by setting a cvar via rcon with a custom seperator character, and have a script (.scr) running on the server that reads this cvar, adds spaces, prints it, then empties the cvar.

It would work like this:

Add a call to your printing script from map script (i.e. maps/dm/mohdm1.scr, do this for all maps):

Code: Select all

   (...)

   // find this line
   level waittill spawn

   // add this directly below (example)
   exec global/KC25m/printer.scr

   (...)
Then the file global/KC25m/printer.scr (example):

Code: Select all

main:

	local.mycvar = KC25m_iprint
	local.space_surrogate = "_" // may NOT be ';'
	local.space = " " // a space

	// loop forever
	while(1)
	{
		local.string = getcvar local.mycvar
		
		// checks if string is not empty
		if(local.string)
		{
			// replace surrogate char with a space
			local.string = waitthread char_replace local.string local.space_surrogate local.space
			
			// print to all players
			waitthread broadcast local.string 0
			
			// clear cvar
			setcvar local.mycvar ""
		}
		
		// need this or it'll crash
		waitframe
	}
	

end

// replaces any chars in string matching find with replace
// find and replace should be single characters
char_replace local.string local.find local.replace:

	// the result
	local.result = ""

	// strings start indexing at 0
	// vectors start indexing at 0
	// arrays  start indexing at 1
	for(local.i = 0; local.i < local.string.size; local.i++)
	{
		// I believe strings are immutable,
		// so making a new string with the result.
		// Might not be necessary to do it this way, though
		local.char = local.string[local.i]
		if(local.char == local.find)
		{
			local.result += local.replace
		}
		else
		{
			local.result += local.char
		}
	}

end local.result

// broadcasts string to all players
// if bold is set to 1, text will print in white clicking text
// if bold is set to 0, text will print in yellow
broadcast local.string local.bold:

	// strings start indexing at 0
	// vectors start indexing at 0
	// arrays  start indexing at 1
	
	// $player is an array of Players
	// $player == $player[1] when there is only 1 player
	for(local.i = 1; local.i <= $player.size; local.i++)
	{
		$player[local.i] iprint local.string local.bold
	}

end
Unless I made a mistake somewhere you can now iprint to all players by rconing 'rcon set KC25m_iprint Hello_World' and it will print 'Hello World' with a space.

Good luck :)
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

Strings are immutable in Java, i know. But it's a transparant difference, you can initiate a different string via the same pointer and it will make a new one. I believe MOH is the same way, although i'm not completely sure. I'd be surprised if they didn't support it.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

In MoHAA scripting you don't deal with pointers at all, apart from entities (because the entity script variables are actually entity pointers).
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

omg nice script , thanks so lot :)

Thats a very cool and simple script likes C/++ or some one else.

What is it for a language can i download a eBook over scripting ?
Its interessting for me :)

Thanks so mutch again :)
Noob @ Work.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

There's a lot of info in our tutorials section (see main page) and at Bjarne's site:
http://gronnevik.se/rjukan/
Image
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

Thanks for the Infos and Help , its works realy great and i taked it as totourial for me.

I will read a all what i can find :) ( Hope something is in german ;) )

Thanks so mutch.
Noob @ Work.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

I don't think so, unless there are some German community websites that have scripting tutorials.

The language is a custom language developed by the authors of Heavy Metal FAKK 2 (the game MoHAA is based upon). It's a cross between C and PHP with some custom features. I'm afraid there are no e-books for it, just the documentation included with MoH Radiant and/or Spearhead SDK.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
KC25m
Lance Corporal
Posts: 12
Joined: Sun Aug 20, 2006 11:43 am

Post by KC25m »

@jv_map u script prints all 2 time on display :P

i must clear cvar after copy into a string ...
or i get it to times on screen.

But its runs fine.
Now a question u write that i can print withe and yellow texts but how can i give the arguments dynamic not in script ?

Yea something of the scripts looks likes C and PHP.

i think when i find german toturials i can write own good scripts :)

Thanks for the Answers .
Noob @ Work.
Post Reply