Raised This Month: $51 Target: $400
 12% 

Help Trying


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LordOfBlade
Member
Join Date: Feb 2015
Old 05-04-2017 , 12:22   Help Trying
Reply With Quote #1

good day.

help. I trying to check zombie classes with switch

like this:

PHP Code:
switch (zp_get_user_zombie_class(id))
    {
        case 
g_class_1:
        {
        
        }
                case 
g_class_2:
        {
        
        }
    } 
But this gives me an error.
Code:
Error: Must be a constant expression; assumed zero
I want to check with switch. Since I have many classes. And I do not like to use:

Code:
if
else if
else if
else if
else if
else if
else if
reason.. 30 class on code.

If anyone can give me a hand. I would be grateful.
LordOfBlade is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 05-04-2017 , 13:51   Re: Help Trying
Reply With Quote #2

The error tells it all. You can't use non-constant statements in switch. Use 'if' and 'else if'.
__________________
edon1337 is offline
LordOfBlade
Member
Join Date: Feb 2015
Old 05-05-2017 , 10:55   Re: Help Trying
Reply With Quote #3

But there is no way to switch it to switch?

Since they would be 29 else if...
LordOfBlade is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-05-2017 , 11:06   Re: Help Trying
Reply With Quote #4

I know a solution, but will mean to modify your zombie plague plugin or whatever you're using, and you're beginer so the answer is: use Else Ifs.
__________________
Project: Among Us

Last edited by Craxor; 05-05-2017 at 11:06.
Craxor is offline
Send a message via ICQ to Craxor
LordOfBlade
Member
Join Date: Feb 2015
Old 05-05-2017 , 11:11   Re: Help Trying
Reply With Quote #5

Quote:
Originally Posted by Craxor View Post
I know a solution, but will mean to modify your zombie plague plugin or whatever you're using, and you're beginer so the answer is: use Else Ifs.
tell me. I will do my best to do it.
LordOfBlade is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-05-2017 , 13:00   Re: Help Trying
Reply With Quote #6

You can do this with mapping g_class_X to your enum.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
LordOfBlade
Member
Join Date: Feb 2015
Old 05-05-2017 , 15:37   Re: Help Trying
Reply With Quote #7

Quote:
Originally Posted by PRoSToTeM@ View Post
You can do this with mapping g_class_X to your enum.
like this?

PHP Code:
enum Zombies_Class
{
    
g_class_1 1,
    
g_class_1 2
}

switch (
zp_get_user_zombie_class(id)) 
    { 
        case 
1
        { 
         
        } 
                case 
2
        { 
         
        } 
    } 
LordOfBlade is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-05-2017 , 18:58   Re: Help Trying
Reply With Quote #8

Don't ask, make a small plugin by yourself with an example of constant class and you test by yourself, if something goes wrong post here the code.

And btw: Is not necesary to set number , you can make your enum just with classes, they will be automatcly indexed

enum Test
{
One, // '0'
Two, // '1'
Three // '2'
}
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-07-2017 , 04:34   Re: Help Trying
Reply With Quote #9

Here create a 1d array szArray[classidinarray] = idofclass
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode