Frictional Games Forum (read-only)
[SCRIPT] Help with global var ints. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Help with global var ints. (/thread-25017.html)



Help with global var ints. - Radical Batz - 04-06-2014

Hey guys this is my first time using globalvarints and I am just confused of how to sue them or when, So in this particular map, you pickup a jar of acid and in that function I made this
PHP Code:
void CleanContainer(string &in asEntityNamestring &in asType)
{
    
AddPlayerSanity(2);
    
PlayMusic("02_puzzle.ogg"false0.7f0.5f9false);
    
SetEntityActive("AreaSpawn"true); 
    
SetGlobalVarInt("GotJarofAcid"1);    


Now when that happened a script box is supposed to be active now in another map since I made this in that code for the other map
PHP Code:
void CheapScare(string &in asParentstring &in asChildint alState)
{
    
//If you got the jar of acid
 
if(GetGlobalVarInt("GotJarofAcid")==1)
 {
     
SetEntityActive("AreaCheapScare"true);
 }
 
SetGlobalVarInt("GotJarofAcid"1);
}

//A function when looking at the Suitor
void SanityDamage(string &in asEntitystring &in asType)
{
SetEntityActive("enemy_suitor_1"true);
 
FadeEnemyToSmoke("enemy_suitor_1"true);


But it still doesn't work do you guys know what's the problem here or am i just stupid cause this is my first time using globalvarints and I might not do a good job at it! so eyah, am I supposed to put something onstart?

IDK tell em down in the comments, thnx.


RE: Help with global var ints. - PutraenusAlivius - 04-06-2014

GlobalVarInt can only be used in a seperate hps called global.hps.

EDIT:
Here's my tutorial on GlobalVar.


RE: Help with global var ints. - Romulator - 04-06-2014

^Would recommend adding that to the wiki one day Smile


RE: Help with global var ints. - daortir - 04-06-2014

Dude there is no need for a global.hps to use global variables ^^. Your tutoral is good otherwise but there is absolutely no need to decare global variables in a global.hps file. You can perfectly create them in a classic .hps file, and reuse them from any other file.


RE: Help with global var ints. - Neelke - 04-06-2014

^^

Code:
Global variables can be used throughout several maps and can be accessed by several script files.

void SetGlobalVarInt(string& asName, int alVal);
void AddGlobalVarInt(string& asName, int alVal);
int GetGlobalVarInt(string& asName);

void SetGlobalVarFloat(string& asName, float afVal);
void AddGlobalVarFloat(string& asName, float afVal);
float GetGlobalVarFloat(string& asName);

void SetGlobalVarString(string& asName, const string& asVal);
void AddGlobalVarString(string& asName, string& asVal);
string& GetGlobalVarString(string& asName);



RE: Help with global var ints. - PutraenusAlivius - 04-06-2014

edit: oh sorry wio incorrect thread


RE: Help with global var ints. - Mudbill - 04-06-2014

(04-06-2014, 03:35 PM)SomethingRidiculous Wrote: When a white man gets all racist they get discrimination, but IF a black man gets all racist they get compliments!

Sorry, what? Is that some sort of example?
I mean, I agree, but I don't see how it has any relevance here.


RE: Help with global var ints. - Radical Batz - 04-06-2014

um guys thanks for the replies and everything but I seem not to get it working!


RE: Help with global var ints. - Mudbill - 04-06-2014

Try putting the check in OnEnter.

PHP Code:
void OnEnter()
{
    if(
GetGlobalVarInt("GotJarofAcid")==1)
    {
        
SetEntityActive("AreaCheapScare"true);
        
SetGlobalVarInt("GotJarofAcid"0);
    }