Individual player variables in MP ???

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
sysQuik
Corporal
Posts: 25
Joined: Fri Feb 07, 2003 9:54 am

Individual player variables in MP ???

Post by sysQuik »

All I want to do is have a variable that can have a unique value for each player in MP. I've tried "parm.other.xxx = 1" but all the players on the same team seem to inherit the same value whenever I assign to it.

$player seems to be an array, I guess if it's a hash, something like "$player[local.n].var = 1" inside a for loop could work, but I haven't been able to get it working.

Any help at all would be greatly appreciated. I've been through every scrap of moh doc I can find. If anyone can throw down an example code morsel, that would be excellent. Ultimately, I'd like to have the unique variable value be assigned by a trigger_multiple.

Thanks for your time,
SysQuik
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hi sysQuik, thank you for registering at .map but please use the search function in the future :wink:

Only about 10 threads down you would've found this
/forum/viewtopic.php?t=3928

Once again welcome to .map :D enjoy your stay :D
Image
sysQuik
Corporal
Posts: 25
Joined: Fri Feb 07, 2003 9:54 am

Post by sysQuik »

I actually saw that one, but when I set parm.other.warning from a trigger_multiple, and then did a println of parm.other.warning, all of the players huds listed the new value assigned to what I expected to be only the player that triggered the trigger.multiple. Here's the code:

Code: Select all

main:
	thread parm_other_warning_trigger

	level waittill spawn
	thread trace_parm_other_warning

end

parm_other_warning_trigger:

	while ( $parm_other_warning_trigger )
	{	
		( $parm_other_warning_trigger ) waittill trigger
		parm.other.warning = "1"
	}		
end

trace_parm_other_warning:

	while (1)
	{
		iprintln "parm.other.warning = " (parm.other.warning)
		wait .3
	}
end
Code seems simple enough. Player joins the dm, "parm.other.warning = NIL" displays in the hud until the player walks into the trigger, then "parm.other.warning = 1" is displayed in the hud. Now have another player join the dm and as soon as they join "parm.other.warning = NIL" is displayed again in both player's huds. What I would expect to happen is for the 1st player hud to display "parm.other.warning = 1" and the 2nd player hud to display "parm.other.warning = NIL". Since after all parm.other.warning should be unique for each player right? What am I missing? I wouldn't think I'd have to use an array, but if I do could someone post the simplest array that would work?

Thanks for your time and your amazingly fast response! :)

SysQuik
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

At some points your understanding of the scripting language is fundamentally wrong and I'll try to correct that 8-)

First of all, the script runs on the server only, and therefore is the same for all players. An iprintln command can't possibly give a different output for different players.

Next, parm.other does not represent a player property. The parm object is a rather mysterious object that can be used for specific script functions, like finding out who triggered something. The parm.other variable is set by any trigger when it's triggered, the value will be the entity that triggered it.

For example, a trigger could set parm.other = $player[2], that is the second player in the $player array.

Then, by typing parm.other.warning = 1, you're actually setting $player[2].warning = 1.

By typing:
println parm.other.warning

you're printing the .warning variable of the last player who triggered something (or NIL if parm.other is NIL (will result in a cannot cast NIL to listener error)).

Anyway I hope this clears up some clouds :wink:
Image
sysQuik
Corporal
Posts: 25
Joined: Fri Feb 07, 2003 9:54 am

Post by sysQuik »

Thank you, thank you, thank you, this is the fundamental core scripting info that has been so sorely documented in all the places I've looked. I knew I was missing something. Very cool. Do you know of a document that covers core principals of this sort of thing?

Thanks again,
Sysquik :lol:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

See the stickies on top of this forum :wink:
Image
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

Post by The Jackal »

sysQuik wrote:Do you know of a document that covers core principals of this sort of thing?
http://www.planetmedalofhonor.com/rjuka ... guage.html
sysQuik
Corporal
Posts: 25
Joined: Fri Feb 07, 2003 9:54 am

Post by sysQuik »

Excellent, I read it and I'll refer to it.

Thanks!
SysQuik
Post Reply