Combinating problems - The chaser - 08-02-2013
So, I have been trying to get a chemical script to work, but for unknown reasons it says "The combination doesn't work".
My inventory.hps: (The hammer part works perfectly)
Code: //COMBINE HAMMER//
////////////////////
void hammer_chipper(string &in asItemA, string &in asItemB)
{
PlayGuiSound("15_make_hammer", 1.0f);
RemoveItem(asItemA); RemoveItem(asItemB);
GiveItem("stone_hammer_chipper", "Puzzle", "stone_hammer_chipper", "stone_hammer_chipper.tga", 0);
}
//COMBINE EXPLOSIVE CHEMICALS////
void make_explosive(string &in asItemA, string &in asItemB)
{
if (GetLocalVarInt("chemical_dynamite") == 0)
{
GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1);
AddLocalVarInt("chemical_dynamite", 1);
RemoveItem(asItemA); RemoveItem(asItemB);
RemoveCombineCallback("Add_var_explosive");
}
if (GetLocalVarInt("chemical_dynamite") == 1)
{
RemoveCombineCallback("Add_var_explosive_1");
AddLocalVarInt("chemical_dynamite", 1);
}
if (GetLocalVarInt("chemical_dynamite") == 2)
{
RemoveCombineCallback("Add_var_explosive_2");
AddLocalVarInt("chemical_dynamite", 1);
}
}
////////////////////////////
// Run at the start of the game.
void OnGameStart()
{
SetLocalVarInt("chemical_dynamite", 0);
/////HAMMER & CHIPPER COMBO/////
AddCombineCallback("hammer_chipper", "stone_hammer_1", "stone_chipper_1", "hammer_chipper", false);
////Before Hall chemicals before mixed
AddCombineCallback("Add_var_explosive", "ingredient_complement_Hexanitrate mannitol", "chemical_container_1", "make_explosive", true);
AddCombineCallback("Add_var_explosive", "ingredient_complement_Silver_acetylide", "chemical_container_1", "make_explosive", true);
AddCombineCallback("Add_var_explosive", "ingredient_complement_plumb_Styphnate", "chemical_container_1", "make_explosive", true);
////Before Hall chemicals after one has been mixed
AddCombineCallback("Add_var_explosive_1", "ingredient_complement_Hexanitrate mannitol", "chemical_container_half", "make_explosive", true);
AddCombineCallback("Add_var_explosive_1", "ingredient_complement_Silver_acetylide", "chemical_container_half", "make_explosive", true);
AddCombineCallback("Add_var_explosive_1", "ingredient_complement_plumb_Styphnate", "chemical_container_half", "make_explosive", true);
////Before Hall chemicals after two have been mixed
AddCombineCallback("Add_var_explosive_2", "ingredient_complement_Hexanitrate mannitol", "chemical_container_half", "make_explosive", true);
AddCombineCallback("Add_var_explosive_2", "ingredient_complement_Silver_acetylide", "chemical_container_half", "make_explosive", true);
AddCombineCallback("Add_var_explosive_2", "ingredient_complement_plumb_Styphnate", "chemical_container_half", "make_explosive", true);
}
I have checked names, they are all the same, and there isn't any .map_cache.
Any ideas?
RE: Combinating problems - PutraenusAlivius - 08-02-2013
I don't think if-else statements are compatible. I mean I don't think it can be used.
RE: Combinating problems - The chaser - 08-02-2013
Well, I removed the if's and it didn't work either...
RE: Combinating problems - Rapture - 08-02-2013
Change the last two "if"s to "else".
Code: //COMBINE EXPLOSIVE CHEMICALS////
void make_explosive(string &in asItemA, string &in asItemB)
{
if (GetLocalVarInt("chemical_dynamite") == 0)
{
GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1);
AddLocalVarInt("chemical_dynamite", 1);
RemoveItem(asItemA); RemoveItem(asItemB);
RemoveCombineCallback("Add_var_explosive");
}
else (GetLocalVarInt("chemical_dynamite") == 1)
{
RemoveCombineCallback("Add_var_explosive_1");
AddLocalVarInt("chemical_dynamite", 1);
}
else (GetLocalVarInt("chemical_dynamite") == 2)
{
RemoveCombineCallback("Add_var_explosive_2");
AddLocalVarInt("chemical_dynamite", 1);
}
}
RE: Combinating problems - The chaser - 08-02-2013
That doesn't work either... thanks anyway for the try
RE: Combinating problems - Tomato Cat - 08-02-2013
PHP Code: void make_explosive(string &in asItemA, string &in asItemB) { if (GetLocalVarInt("chemical_dynamite") == 0) { GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1); AddLocalVarInt("chemical_dynamite", 1); RemoveItem(asItemA); RemoveItem(asItemB); RemoveCombineCallback("Add_var_explosive"); } else if(GetLocalVarInt("chemical_dynamite") == 1) { RemoveCombineCallback("Add_var_explosive_1"); AddLocalVarInt("chemical_dynamite", 1); } else if(GetLocalVarInt("chemical_dynamite") == 2) { RemoveCombineCallback("Add_var_explosive_2"); AddLocalVarInt("chemical_dynamite", 1); } }
"else" statements do not check if a condition is met. They are executed of none if the other conditions are met. i.e, if "chemical_dynamite" was neither 0, 1 or 2.
I believe several "if" statements will work, but it's generally only used when 2 separate conditions are being checked.
RE: Combinating problems - Rapture - 08-02-2013
Tomato Cat is right, that was my Error. I'm guessing the compiler doesn't mine a bunch of "if"'s because I have a old working one.
Code: void Timer_IntroFade(string &in asTimer)
{
if(asTimer == "IntroFade_0")
{
FadeIn(1);
StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
}
if(asTimer == "IntroFade_1")
{
StopPlayerLookAt();
StartPlayerLookAt("Area_Look_2", 1, 1, "");
}
if(asTimer == "IntroFade_2")
{
SetPlayerActive(true);
}
if(asTimer == "IntroFade_3")
{
SetMessage("Message", "001_Sally01", 0);
}
if(asTimer == "IntroFade_4")
{
SetMessage("Message", "001_Michael01", 0);
}
if(asTimer == "IntroFade_5")
{
SetMessage("Message", "001_Sally02", 0);
}
if(asTimer == "IntroFade_6")
{
StopPlayerLookAt();
SetPlayerMoveSpeedMul(1);
SetPlayerRunSpeedMul(1);
SetPlayerLookSpeedMul(1);
SetPlayerJumpDisabled(false);
SetPlayerCrouchDisabled(false);
SetInventoryDisabled(false);
}
}
Like Tomato Cat said, if I place another one of the "if(asTimer == "IntroFade_7) and replace the "if" with "else". The timer will default to "IntroFade_7" if none of the other above conditions match.
RE: Combinating problems - SilentStriker - 08-03-2013
(08-02-2013, 10:45 PM)Rapture Wrote: Tomato Cat is right, that was my Error. I'm guessing the compiler doesn't mine a bunch of "if"'s because I have a old working one.
Code: void Timer_IntroFade(string &in asTimer)
{
if(asTimer == "IntroFade_0")
{
FadeIn(1);
StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
}
if(asTimer == "IntroFade_1")
{
StopPlayerLookAt();
StartPlayerLookAt("Area_Look_2", 1, 1, "");
}
if(asTimer == "IntroFade_2")
{
SetPlayerActive(true);
}
if(asTimer == "IntroFade_3")
{
SetMessage("Message", "001_Sally01", 0);
}
if(asTimer == "IntroFade_4")
{
SetMessage("Message", "001_Michael01", 0);
}
if(asTimer == "IntroFade_5")
{
SetMessage("Message", "001_Sally02", 0);
}
if(asTimer == "IntroFade_6")
{
StopPlayerLookAt();
SetPlayerMoveSpeedMul(1);
SetPlayerRunSpeedMul(1);
SetPlayerLookSpeedMul(1);
SetPlayerJumpDisabled(false);
SetPlayerCrouchDisabled(false);
SetInventoryDisabled(false);
}
}
Like Tomato Cat said, if I place another one of the "if(asTimer == "IntroFade_7) and replace the "if" with "else". The timer will default to "IntroFade_7" if none of the other above conditions match.
The code you got there is easier to do as a switch instead of a bunch of ifs
RE: Combinating problems - Rapture - 08-03-2013
^
Can I see a example?
I do it that way because I find it easier to keep it neater and more open to understanding at a quick glance. 1000 ways to skin a cat.
RE: Combinating problems - SilentStriker - 08-04-2013
(08-03-2013, 10:44 PM)Rapture Wrote: ^
Can I see a example?
I do it that way because I find it easier to keep it neater and more open to understanding at a quick glance. 1000 ways to skin a cat.
Here's an example:
Let's see if I remember correctly
Code: void Timer_IntroFade(string &in asTimer)
{
AddLocalVarInt("IntroFade", 1
switch(GetLocalVarInt("IntroFade")){
case 1:
FadeIn(1);
StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
break;
case 2:
StopPlayerLookAt();
StartPlayerLookAt("Area_Look_2", 1, 1, "");
break;
case 3:
SetPlayerActive(true);
break;
case 4:
SetMessage("Message", "001_Sally01", 0);
break;
case 5;
SetMessage("Message", "001_Michael01", 0);
break;
case 6:
SetMessage("Message", "001_Sally02", 0);
case 7:
StopPlayerLookAt();
SetPlayerMoveSpeedMul(1);
SetPlayerRunSpeedMul(1);
SetPlayerLookSpeedMul(1);
SetPlayerJumpDisabled(false);
SetPlayerCrouchDisabled(false);
SetInventoryDisabled(false);
break;
if(GetLocalVarInt("IntroFade") < 7) AddTimer("IntroFade", 1, "Timer_IntroFade");
}
}
|