Page 1 of 2

Avoid team change

Posted: Wed May 04, 2005 4:59 pm
by agentmad007

Code: Select all

avoid_team_change:


if((parm.other.dmteam=="allies") || (parm.other.dmteam=="axis"))
{
level.startteam = parm.other.dmteam
}

	if(parm.other.dmteam != level.startteam)
	{
	parm.other stufftext "disconnect"
	}



end
console say field .dmteam applied to NULL Listener .....

How could i make it work ...so if an allies go axis , he ll be booted and vice versa

Posted: Wed May 04, 2005 11:12 pm
by Bjarne BZR
Well: the parm.other variable only has a player reference in it after a trigger has been activated ( mostly ), so you need another way to scan the players:

Start with a scan to set the starting team variables ( maby 5 seconds after map start ) :

Code: Select all

for(int local.i=0;local.i<$player.size;++i)
{
	$player[i].starting_team = $player[i].dmteam
}
And then do periodic scans to determine if anyone has switched teams:

Code: Select all

while(1) // Also known as forever
{
	wait 15
	for(int local.i=0;local.i<$player.size;++i)
	{
		if($player[i].starting_team != $player[i].dmteam)
		{
			$player[i] stufftext "disconnect" 
			wait 1 // To avoid periodic lag while scanning
		}
	}
}
Something like that ( this is just example code written in the browser, so there are no guarantees agains t errors or misspellinguorz :) ).

But be warned: I would hate this mod on a server. What if the teams are unbalanced? Should I be kicked for evening out the teams?

Posted: Thu May 05, 2005 4:04 pm
by agentmad007
Thanks bjarne , yes i know it is somehow unfair to kick a player that even a team , but the things is that someone jailed in my mpa could easyly live it by swaping team :s

Have not find an other way ....

Or i could jailed him in other jail , i ll try to think about , anyway thanks for your answer :D

Posted: Thu May 05, 2005 4:19 pm
by Bjarne BZR
Looking forward to playing this new game mode of yours :D

Posted: Thu May 05, 2005 4:34 pm
by agentmad007
I hope you have breakthrough or SH , cause it will work for them 2(ubersound file)
New game mode lol, if you say so:p.Jails are active when spawn bomb explode.

Posted: Thu May 05, 2005 5:17 pm
by Bjarne BZR
Oh crap. SH or BT... make it for AA instead so all MOH players kan enjoy it.

Posted: Thu May 05, 2005 7:52 pm
by agentmad007
Wont be so difficult i ll just have to prechache the sounds in the map script , this local.master thingy .....

Can i precache the sounds within the map script and make an ubersoundfile aswell , without any conflicts ? So the map will be playable for all Moh ...

Posted: Thu May 05, 2005 8:35 pm
by Rookie One.pl
I'd say yes, as each game supports only one way.

Posted: Sat May 07, 2005 1:27 pm
by agentmad007
Bzarne the script above doesnt work :s , anyway i wanted to give the script an other issue to let the player ingame instead of being kicked.

here the script i got at the moment:

$alliesjailboxin is a trigger_multiple that setthread alliesIsTouching


Code: Select all

// -------------------------------------------------------------------------------------
alliesIsTouching:
// -------------------------------------------------------------------------------------
	

	
	for (local.i = 1; local.i <= $player.size; local.i++) 
	{
		if ($player[local.i].dmteam == "allies")
		{
			
		$player[local.i].starting_team = $player[local.i].dmteam

			if($player[local.i] istouching $alliesjailboxin)

			{
			level.allies_dead++
			$player[local.i].jailed = 1
			$player[local.i].outofweapon = 1
			$player[local.i] thread SetImmunities
			$player[local.i] takeall
			thread check_team_change $player[local.i]
			
			}

		}
		

	}

	end 

check_team_change:

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1))

	{
	iprintln "you ve changed team"

	}

end
logfile Error:

Code: Select all


^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player[local.i].starting_team != $player^

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player^

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player[local.i].starting_team != $player^

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player^

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player[local.i].starting_team != $player^

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player^

^~^~^ Script Error: Cannot cast 'NIL' to int

Thanks for the help ;)

Posted: Sat May 07, 2005 2:14 pm
by Bjarne BZR
Well:

Code: Select all

^~^~^ Script Error: Cannot cast 'NIL' to int

if(($player[local.i].starting_team != $player[local.i].dmteam) && ($player[local.i].jailed == 1)) (maps/obj/mp_stargate_anubis_apogee_obj.scr, 1002)
if(($player[local.i].starting_team != $player^
...is saying that it can not use NIL as an integer value.
The "^" indicates the index in the array. And indeed, local.i is not defined and thus is NIL.

Your error is in how "check_team_change" is defined and called.
You are trying to give the thread a parameter here:

Code: Select all

thread check_team_change $player[local.i]
...and this is a good idea, but your "check_team_change" needs to be prepared to recieve a parameter, like this:

Code: Select all

check_team_change local.da_playa:
So try this instead:

Code: Select all

alliesIsTouching:
	for (local.i = 1; local.i <= $player.size; local.i++)
	{
		if ($player[local.i].dmteam == "allies")
		{
			$player[local.i].starting_team = $player[local.i].dmteam
			if($player[local.i] istouching $alliesjailboxin)
			{
				level.allies_dead++
				$player[local.i].jailed = 1
				$player[local.i].outofweapon = 1
				$player[local.i] thread SetImmunities
				$player[local.i] takeall
				thread check_team_change $player[local.i]
			}
		}
	}
end

check_team_change local.da_playa:
	if((local.da_playa.starting_team != local.da_playa.dmteam) && (local.da_playa.jailed == 1))
	{
		local.da_playa iprint "you ve changed team" 0
	}
end

Posted: Sat May 07, 2005 2:31 pm
by agentmad007
Nothing .....:s ,none errors in console and nothing appear on screen to warn about my team change ......I guess the script doesnt detect when i ve switched team.....

Posted: Sat May 07, 2005 3:13 pm
by Bjarne BZR
Well, if you still have scrip errors, the entire script will be ignored by MOH. What error do you have now?

Posted: Sat May 07, 2005 4:14 pm
by agentmad007
None errors!===> nothing is written in console

Dunno whats wrong.....The script above may need more info to detect the player changing team.

Code: Select all


if($player[local.i] istouching $alliesjailboxin) 
         { 
            level.allies_dead++ 
            $player[local.i].jailed = 1 
Does this mean if $player[local.i] is no longer touching $alliesjailboxin , he is not considered as $player[local.i].jailed = 1 .....

In this case :

Code: Select all

check_team_change local.da_playa: 
   if((local.da_playa.starting_team != local.da_playa.dmteam) && (local.da_playa.jailed == 1)) 
   { 
      local.da_playa iprint "you ve changed team" 0 
   } 
end
....Wont work because when the player change team he doesnt touch the trigger and then the 2 conditions to detect the player swaping team are not filled in.

Hope i am clear enough with my rubbish english lol....Thanks Bjarne Btw :)

Posted: Sat May 07, 2005 5:24 pm
by Bjarne BZR
Well, as you have no else claues , a player that has been jailed once will be jailed forever...

... because of this it may be a bad idea tu use a setthread to activate that piece of code.

Instead do as I seaid in my first suggestion in this thread: That is set the starting team on all players after about 5 seconds after map start and then continuously scan all players all the time.

Posted: Sat May 07, 2005 6:03 pm
by agentmad007
I will forget about the idea to jail the player if he switch team and if he is jailed , i ll make it simplier by make him jailed if switch team after an amount of time (2 minute i guess).With my map gameplay , the player wont be jailed before 2 minutes .....so here is the script i finaly got , and i got a small question again :

Code: Select all

scanner:

   for(local.i=1;local.i<=$player.size;local.i++)
   { 
   $player[local.i].starting_team = $player[local.i].dmteam
   }


end

team_change_scanner:

while(1)

{

wait 10

   for(local.i=1;local.i<=$player.size;local.i++)
   { 


     		 if($player[local.i].starting_team != $player[local.i].dmteam) 
    		  { 

			if($player[local.i].dmteam == allies)
			{
     		    
			level.ald_dest++

			if(level.ald_dest > 5)
			{
			level.ald_dest = 0
			}
			
			local.dest = level.ald[level.ald_dest] 

			$player[local.i] tele local.dest

		 	}

				else if($player[local.i].dmteam == axis)
				{

				level.axd_dest++

				if(level.axd_dest > 5 )
				{
				level.axd_dest = 0
				}

				local.dest = level.axd[level.axd_dest] 
	
				$player[local.i] tele local.dest
     		      	        } 

		 }


   } 

wait 1

}

end


Is Spectator considered as a TEAM ,because when i join axis or allies at the start , the script act as if i changed team ........And also how to stop this permanent tel?port in my while loop .

Tried try that and it doesnt work:

Code: Select all


scanner:

   for(local.i=1;local.i<=$player.size;local.i++)
   { 
	if(($player[local.i].dmteam == allies) || ($player[local.i].dmteam == axis))
		{
   $player[local.i].starting_team = $player[local.i].dmteam

		}
   }


end



Thanks