Post: switch case statement not working
03-22-2016, 03:31 PM #1
BullyWiiPlaza
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); Why is the switch case statement not working? Given the following code:
    switch(friendlyFire)
{
case 0:
self printGlobalPlayerAction("No Friendly Fire");
break;

case 1:
self printGlobalPlayerAction("Friendly Fire");
break;

case 2:
self printGlobalPlayerAction("Reflected Friendly Fire");
break;

case 3:
self printGlobalPlayerAction("Shared Friendly Fire");
break;
}

Nothing happens.

If I write the same with if and else statements, it works fine:
    if(friendlyFire == 0)
{
self printGlobalPlayerAction("No Friendly Fire");
}
else if(friendlyFire == 1)
{
self printGlobalPlayerAction("Friendly Fire");
}
else if(friendlyFire == 2)
{
self printGlobalPlayerAction("Reflected Friendly Fire");
}
else if(friendlyFire == 3)
{
self printGlobalPlayerAction("Shared Friendly Fire");
}

Why? I'm using GSC Studio 16.2.15.0 and I'm pretty sure I can write switch case statements correctly.
(adsbygoogle = window.adsbygoogle || []).push({});
03-25-2016, 05:10 AM #11
iRnZ
NextGenUpdate Elite
Originally posted by BullyWiiPlaza View Post
Can or will this be fixed? It would be great since there doesn't seem to be a reason for it

put on spawn or on bool function
self.count = 0;

this on function ;d
self.count++;
switch(self.count)
{
case 1:
self iPrintLnBold("^5Hi");
break;

case 2:
self iPrintLnBold("^5Hello");
break;

default:
self iPrintLnBold("^5 GoodBye");
break;
}
if(self.count > 2)
self.count = 0;
hope this help you ;d
03-25-2016, 09:09 AM #12
BullyWiiPlaza
Climbing up the ladder
Originally posted by iReZ View Post
put on spawn or on bool function
self.count = 0;

this on function ;d
self.count++;
switch(self.count)
{
case 1:
self iPrintLnBold("^5Hi");
break;

case 2:
self iPrintLnBold("^5Hello");
break;

default:
self iPrintLnBold("^5 GoodBye");
break;
}
if(self.count > 2)
self.count = 0;
hope this help you ;d

Does it work on consoles? Except for the self there is no difference...
03-25-2016, 02:12 PM #13
Looks like this is just a problem with the compiler, therefor nothing you can do
Closed.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo