hi
so im new to c++ and am trying to change a number;
int hep=0;
switch(hep)
{
case 0:
if ( item.name=="barrel")
{
AddMessage(S+"111111");
int hep= ++hep;//this part gives me trouble
//hep =versy;
}
case 1:
if ( item.name=="barrel2")
{
AddMessage(S+"22222");
}
right now it works where the BOTH cases show when item names are touched (this is for a game im using essenthial engine) and I want the first case to be no longer recognized, ie if case 1 is true case 0 is no longer 0. I thnk it hs to do with how Im adding I thought hep++ may do it but Im stuck! thanks in advance!
if ( item.name=="barrel")
{
AddMessage(S+"111111");
int hep= ++hep;//this part gives me trouble
//hep =versy;
}
In the above code you are creating a new variable named hep in the scope of the if statement, not using the previous variable named hep. All you should need is ++hep;.
thank you.
ok i have this now..not sure if c++ needs {} for the ifs there...but its actually reading 0,then 1 then sometimesgoesback to 0- cant get it to two ...yet.. o k thanks
int hep=0;
switch(hep)
{
case 0:
if ( item.name=="barrel")
++hep;
AddMessage(S+"111111er"+ hep);
// int hep= ++hep;
//hep =versy;
//if item name ==?? new cas
break;
case 1:
if ( item.name=="biggun")