Frictional Games Forum (read-only)

Full Version: Help with global var ints.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
GlobalVarInt can only be used in a seperate hps called global.hps.

EDIT:
Here's my tutorial on GlobalVar.
^Would recommend adding that to the wiki one day Smile
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.
^^

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);
edit: oh sorry wio incorrect thread
(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.
um guys thanks for the replies and everything but I seem not to get it working!
Try putting the check in OnEnter.

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