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

[solved]strlen block problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 05-08-2015 , 00:20   [solved]strlen block problem
Reply With Quote #1

Please read the code

PHP Code:
#include <amxmodx>

new TextE[255];
new 
Lenth_Of_the_string;

public 
plugin_init()
{
    
register_clcmd("test","get_the_output");
    
register_clcmd("say /test""ShowMenu");
}

public 
ShowMenu(id)
{
    new 
menu menu_create("TestMenu""mh_TestMenu");
    
menu_additem(menu"Input """0);
    
menu_display(idmenu0);
}

public 
mh_TestMenu(idmenuitem)
{
    switch(
item)
    {
        case 
0: {
            
client_cmd(id"messagemode test")
        }
    }
    
    
menu_destroy(menu);
}

public 
get_the_output(id)
{
    
//if(equal(TextE, ""))//if i uncomment this line nthing printing dont know why whatever i gave input 
        //return PLUGIN_HANDLED;
    
Lenth_Of_the_string strlen(TextE)//strlen = to calculate the string of the length
    // if i gave input as indraraj (8>6) True then Return nthing and stop execution?
    
if(Lenth_Of_the_string 6)
    {
        
client_print(id,print_chat,"string should be less than 6");
        return 
PLUGIN_HANDLED;
    }    
    
read_args(TextEcharsmax(TextE)) ;
    
remove_quotes(TextE);
    
//but still read_args giving output if string is greater than 6 
    //no need to print output directly out of this function if string is greater than 6
    
client_print(id,print_chat,"the output is %s",TextE);
    
server_print("the output is %s",TextE);
    
log_amx("the output is %s",TextE);
    return 
PLUGIN_CONTINUE;

Output :
Quote:
the output is indra (5>6) false this is fine
the output is sdsadadf (8>6) true but still not blocked
After this all string blocked whatever if less than or greater than 6
__________________
Thanks everyone. #miss_you_all

Last edited by indraraj striker; 05-10-2015 at 01:01.
indraraj striker is offline
Kiske
Veteran Member
Join Date: May 2009
Old 05-08-2015 , 02:10   Re: [help] strlen block problem
Reply With Quote #2

PHP Code:
    Lenth_Of_the_string strlen(TextE)//strlen = to calculate the string of the length 
    // if i gave input as indraraj (8>6) True then Return nthing and stop execution? 
    
if(Lenth_Of_the_string 6
    { 
        
client_print(id,print_chat,"string should be less than 6"); 
        return 
PLUGIN_HANDLED
    }     
    
read_args(TextEcharsmax(TextE)) ; 
    
remove_quotes(TextE); 
->
PHP Code:
    read_args(TextEcharsmax(TextE)) ; 
    
remove_quotes(TextE); 
    
    
Lenth_Of_the_string strlen(TextE)//strlen = to calculate the string of the length 
    // if i gave input as indraraj (8>6) True then Return nthing and stop execution? 
    
if(Lenth_Of_the_string 6
    { 
        
client_print(id,print_chat,"string should be less than 6"); 
        return 
PLUGIN_HANDLED
    } 
Why you use global variables for this ?
__________________


Last edited by Kiske; 05-08-2015 at 02:10.
Kiske is offline
Send a message via Skype™ to Kiske
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 05-08-2015 , 04:06   Re: [help] strlen block problem
Reply With Quote #3

my bad
i changed its working
ty for solve the problem

one question:@Kiske
TextE[255] this means i can give 251 letter input ? useless for me point of this plugin
instead of this can i use TextE[10]
__________________
Thanks everyone. #miss_you_all

Last edited by indraraj striker; 05-08-2015 at 04:16.
indraraj striker is offline
Kiske
Veteran Member
Join Date: May 2009
Old 05-08-2015 , 05:24   Re: [help] strlen block problem
Reply With Quote #4

Yes, you can, in fact, you should use [5] in this example, and use local variables instead of global.
__________________


Last edited by Kiske; 05-08-2015 at 05:26.
Kiske is offline
Send a message via Skype™ to Kiske
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-08-2015 , 07:17   Re: [help] strlen block problem
Reply With Quote #5

Quote:
Originally Posted by Kiske View Post
Yes, you can, in fact, you should use [5] in this example, and use local variables instead of global.
What? In that way it will always return plugin handled.
This is XY problem, we can't tell you what the value to use unless we know what you want to do. You must think by yourself and decide what's the max characters you want it to have. But using less than 6 is exactly what you should NOT do becauseit will always return for insuficient characters.
__________________

Last edited by Jhob94; 05-08-2015 at 07:20.
Jhob94 is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 05-08-2015 , 10:34   Re: [help] strlen block problem
Reply With Quote #6

ty @Jhob94 and @Kiske
__________________
Thanks everyone. #miss_you_all
indraraj striker is offline
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 10:43.


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