Timelimit Changes effect script, how do i / by 60:S

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Timelimit Changes effect script, how do i / by 60:S

Post by Elgan »

help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


hey i got this itmer thing run when the map is on and reset everyone at 10.

u cna increase the time limit and it keeps up with it. but if u decrease say


rcon timlimit 20 down to time limit 10. it's wayyy out and the counter goes wrong/


NOTE: ITS MOHAA'S FAULT.GRR. IF U CHANGE THE TIME LIMIT FROM 1 TO SAY 2, IT WILL INCREASE 1 MINUTE AND KEEP THE SECONDS, ITS WEIRD.

IF U DECREASE FROM LIKE 5.30 TO 1, IT KEEPS THE SECONDS AND ENDS UP ON 0.30

Code: Select all



time:

	local.mytimer = getcvar "timelimit"
	local.mytimer = int local.mytimer
	local.timer = local.mytimer
	local.mytimer = local.mytimer * 60
	local.mytimer--	

	while(1)
	{
		local.tmr = getcvar "timelimit"
		local.tmr = int local.tmr
		
		if(local.timer!=local.tmr)
		{
			local.timediff = local.timer//gets the old time limit
			local.time =local.mytimer
			local.mytimer = getcvar "timelimit"
			local.mytimer = int local.mytimer
			local.timer = local.mytimer 

			local.times  = local.timer * 60
			local.timediff = local.timediff - local.times
		

			if(local.timediff<local.timer)//////////////this bit. if its increased it runs 
			{
//increased time limit (works fine)
				local.mytimer = local.mytimer * 60
				local.mytimer = local.mytimer - 60
				local.mytimer = local.mytimer + local.time
			}
			else
			{
	//de-creased time limit. the time ends up wrong for everyhting i try
				//local.mytimer = local.mytimer * 60
				local.mytimer = local.mytimer - 60
				local.mytimer = local.mytimer + ( local.time - local.timediff / 60  )
			}	
			

		}



		local.mytimer--

		println local.mytimer

		if (local.mytimer==10)
		{


			setcvar "Flyable" "0"

			println "PLANES DISSABLED, Players Reset"

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

				if($player[level.i].hasplane==1)
				{
					

					if($player[level.i].dmteam=="axis")
					{

						$player[level.i] stufftext ("hidemenu PLANE_HUD_AXIS")

					}
					else
					{
						$player[level.i] stufftext ("hidemenu PLANE_HUD_ALLIES")
					}


					$player[level.i] stufftext ("hidemenu PLANE_CRASH")

					$player[level.i] stufftext "hidemenu PLANE_CROSSHAIR"
				
					$player[level.i] stufftext "ui_crosshair 1"

					$player[level.i] stufftext "hidemenu PLANE_WARNING"

					$player[level.i].is_high=0
	

					local.stearing = getcvar "pro"
					local.stearing = int local.stearing

					if(local.stearing==1)	
					{
						$player[level.i] stufftext ("sensitivity 5")
						$player[level.i] stufftext ("exec sensitivity.cfg")
					}


					$player[level.i].can=1
					$player[level.i].hasplane=0
					$player[level.i] show
					$player[level.i].c47=0
					$player[level.i].stuka=0
					$player[level.i].anniken=0

		
					//$player[level.i] stufftext "spectator"

					
				}	


			
			}

			level waittill spawn

			setcvar "Flyable" "1"
			local.mytimer = getcvar "timelimit"
			local.mytimer = int local.mytimer
			local.timer = local.mytimer
			local.mytimer = local.mytimer * 60
			local.mytimer--	

		}

		wait 1

	}
end

User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

local.mytimer = local.mytimer * 60

isn't that 60 times the timelimit ? What exactly are you trying to do ?
Image
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

by all means i am no scripter but after looking at code is this really what you are trying to do with line in question?

local.mytimer = local.mytimer + ( local.time - local.timediff / 60 )

might be

local.mytimer = local.mytimer + ( ( local.time - local.timediff ) / 60 )

You see it is my understanding the * / % all are done in highest priority.
So before the first calculation would be local.timediff / 60 and then it would subtract that from local.time. But arent you wanting to subtract local.time from local.timediff and then divide it by 60 and then add that to local.mytimer?

Not sure just a thought,

G3mInI
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

ok.ty so far. that made my brain hurt jus readin ur reply:S:S. i failed all types of maths i ever did. but anyway.


what i am trying to do.- when ur ina plane the crosshair and stuff is setup and changed for u. then when u crash it sets it back. but sometimes the map ends before u can crash and thus makin it annoying and u have to reset all ur options and hide huds and things.

so. the code. gets the timelimit and then changes it into the correct ammoutnof seconds by * 60. then counts down second by second until 10 seconds before the map ends then resets everyhting and does what is needed.

but if the timelimit is changed while it is counting down. the time would be wrong. so if its changed longer it works fine as ea made the timelimit just add on. but with takin away time they made it real weird.

if u go in game set timelimit 10, wait 3 seconds and set it to 3 it will end pu on 1.03 or somehting., so the timing with the loop becomes wrong.

Code: Select all


time:

	local.mytimer = getcvar "timelimit"
	local.mytimer = int local.mytimer
	local.timer = local.mytimer
	local.mytimer = local.mytimer * 60
	local.mytimer--	

	while(1)
	{
		local.tmr = getcvar "timelimit"
		local.tmr = int local.tmr
		
		if(local.timer!=local.tmr)
		{
			local.timediff = local.timer
			local.time =local.mytimer
			local.mytimer = getcvar "timelimit"
			local.mytimer = int local.mytimer
			local.timer = local.mytimer 



			if(local.timediff<local.timer)
			{

				local.mytimer = local.mytimer * 60
				local.mytimer = local.mytimer - 60
				local.mytimer = local.mytimer + local.time
			}
			else
			{	
println "u just messed up the timer in the code, please load map again"

				
			}	
			

		}



		local.mytimer--

		//println local.mytimer

		if (local.mytimer==10)
		{


			setcvar "Flyable" "0"

			println "PLANES DISSABLED, Players Reset"

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

				$player[level.i] show

				if($player[level.i].hasplane==1)
				{
					$player[level.i] stufftext "spectator"

					if($player[level.i].dmteam=="axis")
					{

						$player[level.i] stufftext ("hidemenu PLANE_HUD_AXIS")

					}
					else
					{
						$player[level.i] stufftext ("hidemenu PLANE_HUD_ALLIES")
					}


					$player[level.i] stufftext ("hidemenu PLANE_CRASH")

					$player[level.i] stufftext "hidemenu PLANE_CROSSHAIR"
				
					$player[level.i] stufftext "ui_crosshair 1"

					$player[level.i] stufftext "hidemenu PLANE_WARNING"

					$player[level.i].is_high=0
	

					local.stearing = getcvar "pro"
					local.stearing = int local.stearing

					if(local.stearing==1)	
					{
						$player[level.i] stufftext ("sensitivity 5")
						$player[level.i] stufftext ("exec sensitivity.cfg")
					}


					$player[level.i].can=1
					$player[level.i].hasplane=0
					$player[level.i] show
					$player[level.i].c47=0
					$player[level.i].stuka=0
					$player[level.i].anniken=0

		
					
				}	


			
			}

			level waittill spawn

			thread enable

			local.mytimer = getcvar "timelimit"
			local.mytimer = int local.mytimer
			local.timer = local.mytimer
			local.mytimer = local.mytimer * 60
			local.mytimer--	

		}

		wait 1

	}
end

enable:
	wait 10	
	setcvar "Flyable" "1"
end
		
the counting up works perfect but where it detects if its lost time ive treid everything for months now and it just wont work.. i get different results everytime i change the timelimit less so i cant figgure it out. i need ea's mohaa code,


hope u understand?
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

ok getting a cvar every min is going to cause lag.nm
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Elgan wrote:ok getting a cvar every min is going to cause lag.nm
Na I think you can safely grab tons of them every frame :) ... don't see why it would lag.
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

u sure, i did some testing setting and takin in a loop wiht wait and it lagged, take it away and lag goes away:S:S:
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Admin

Post by tltrude »

Why don't you just set one timelimit and keep the Server Admin guy's sticky hands off the controls? Why do you need to screw with the client's game so much?
Tom Trude,

Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

because.

the plane may show a cockpit view or a crosshair and needs to hide these again. but if the ma p ends thye dont get hidden.

the code will work as long as no one messes with the timelimit
Post Reply