Page 1 of 1

Global and Public Varibles

Posted: Sat Mar 11, 2017 9:55 pm
by Elias79
Is there a way to store information even after the map is reset?

It tried to use a script to prevent player movement before the countdown in Co-op Survival but i cant prevent the OPEN and ENTER from running twice,
also the RETURN does not get triggered and REOPEN does not even want to compile, so how would i store mod data across maps and levels?

Code: Select all

#library "CVARS"
#include "zcommon.acs"

int counter = 0;

script 1001 OPEN
{
while (counter < 1000)
   {
   Delay(3);
   counter++;
   print(d:counter);
   Delay(3);
   }   
}

Re: Global and Public Varibles

Posted: Sat Mar 11, 2017 10:01 pm
by Fused
I believe it's
global int 1:counter;

Just be sure to reset it back to 0 the second time or whatever so it doesnt mess up the third time.

Re: Global and Public Varibles

Posted: Sat Mar 11, 2017 10:07 pm
by Elias79
Fused wrote:I believe it's
global int 1:counter;

Just be sure to reset it back to 0 the second time or whatever so it doesnt mess up the third time.
Im getting this error:

Code: Select all

CVARS.acs:4: Missing semicolon.
> global int 1:counter = 
>                      ^
And this is my code:

Code: Select all

#library "CVARS"
#include "zcommon.acs"

global int 1:counter = 0;

while (counter < 1000)
	{
	Delay(3);
	counter++;
	print(d:counter);
	Delay(3);
	}	
}
The while loop game me an Invalid declarator but when i put it in the OPEN script it worked, thank you.

Re: Global and Public Varibles

Posted: Sat Mar 11, 2017 11:20 pm
by Fused
You can't define zero to it. it has to be like I have it. That's why you have to reset it inside the script basically.
And yeah, you have to define you start a script or it will throw an error like that for example.