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

[ Solved ]switch string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 12:52   [ Solved ]switch string
Reply With Quote #1

How to ?
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define ADMIN_KICK_RANK "Basic Moderator"
#define ADMIN_BAN_RANK "Co Moderator"

#define GetPlayerBits(%1,%2)    ( %1 &     1 << ( %2 & 31 ) )

new g_Adminrank[20],
    
i_xtrem

public plugin_init() {
        
register_plugin(PLUGINVERSIONAUTHOR)
        
register_clcmd("say test","Just_try")
}
public 
client_connect(id) {
    
    new 
szName[32]
    
get_user_name(id,szName,charsmax(szName))
    if(
GetPlayerBits(id,i_xtrem)){
        
        if(
check_flg(id,ADMIN_KICK)){
            
                
g_Adminrank ADMIN_KICK_RANK

        
}

        else if (
check_flg(id,ADMIN_KICK))
        {
                
g_Adminrank ADMIN_BAN_RANK
        
}
    }
}
public 
Just_try(id){
    
/*
    switch(g_Adminrank){
        case '':
        //  Nothing yet :v
        
    }
    */
}
stock check_flg(idFLAG
{
    return (
get_user_flags(id) & FLAG)


Last edited by Freezo Begin; 01-09-2015 at 16:26.
Freezo Begin is offline
yan1255
Senior Member
Join Date: Jul 2011
Old 01-09-2015 , 12:57   Re: switch string
Reply With Quote #2

Please explain more accuratly what do you want...
__________________
yan1255 is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 13:06   Re: switch string
Reply With Quote #3

how to switch a string value like

PHP Code:
g_Adminrank 
With statement

if(equal(g_Adminrank,"Basic Moderator")){
// Bla bla
}

i wan't to make it in a switch like this
switch(g_Adminrank){
case 'Basic Moderator': // Bla bla
Freezo Begin is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 01-09-2015 , 13:11   Re: switch string
Reply With Quote #4

You can not, as the switch statement only accepts integer values.
mottzi is offline
Send a message via MSN to mottzi
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 13:19   Re: switch string
Reply With Quote #5

how about doing it with enum ?
Freezo Begin is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-09-2015 , 13:33   Re: switch string
Reply With Quote #6

How about testing it before asking for help?

Last edited by RateX; 01-09-2015 at 13:34.
RateX is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 13:35   Re: switch string
Reply With Quote #7

how about shut the fuck up . and don't put a post just for spam or '...' .
Freezo Begin is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-09-2015 , 13:53   Re: switch string
Reply With Quote #8

Dude, I haven't insulted you in anyway.
If you test it yourself you would have had the result. Should it be a success, you got for yourself a solution. If no, you can post what you have done and others can help you with an appropriate and efficient way to solve your problem. You win in anyway and definitely faster than just waiting for someone to answer your random question.
So stop being a dick and start testing.
RateX is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 16:25   Re: switch string
Reply With Quote #9

If you wan't to help just post it i will be appreciated . but if its out of the object just leave .
Because you don't help me at all .


Thanks ,

[ Solved using enumeration ] .
Freezo Begin is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2015 , 18:25   Re: [ Solved ]switch string
Reply With Quote #10

An enum doesn't satisfy what you are requesting in post #3. However, the best you could do is use a Trie to get an integer (that is associated with the input string) to use in your switch.

Based on the purpose of the code in post #1, you should be using integers or enums anyways. I'm glad you found the answer.

All 'good' scripters try stuff on their own before asking "will this work" unless it's extremely complicated.
__________________

Last edited by fysiks; 01-09-2015 at 18:27.
fysiks is online now
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 04:40.


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