Page 1 of 2
[Noob@work]Needs help .
Posted: Sun Aug 20, 2006 11:47 am
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
Posted: Sun Aug 20, 2006 12:41 pm
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.

Posted: Sun Aug 20, 2006 1:25 pm
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 ?
Posted: Sun Aug 20, 2006 1:46 pm
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

Posted: Sun Aug 20, 2006 1:54 pm
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.
Posted: Fri Aug 25, 2006 2:47 pm
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

Posted: Sat Aug 26, 2006 12:20 am
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.
Posted: Sat Aug 26, 2006 9:31 am
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

Posted: Sat Aug 26, 2006 10:36 pm
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.
Posted: Sun Aug 27, 2006 4:44 pm
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).
Posted: Sun Aug 27, 2006 6:07 pm
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

Posted: Sun Aug 27, 2006 6:18 pm
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/
Posted: Sun Aug 27, 2006 8:32 pm
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.
Posted: Sun Aug 27, 2006 9:41 pm
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.
Posted: Sun Aug 27, 2006 11:10 pm
by KC25m
@jv_map u script prints all 2 time on display
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 .