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

CharToLower()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dakex
Junior Member
Join Date: Mar 2019
Old 03-19-2019 , 12:37   CharToLower()
Reply With Quote #1

Hi guys. I need help with this code:

PHP Code:
public Action OnClientCommand(int clientint args)
{
    
char cmd[16];
    
GetCmdArg(0cmdsizeof(cmd));
    
    if (
StrEqual(CharToLower(cmd), "help"))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

This code return error: error 035: argument type mismatch (argument 1)
Why is
PHP Code:
if (StrEqual(CharToLower(cmd), "help")) 
not working? or how to use it?
Dakex is offline
Wyon
Junior Member
Join Date: Mar 2018
Old 03-19-2019 , 13:49   Re: CharToLower()
Reply With Quote #2

Try this:
PHP Code:
public Action OnClientCommand(int clientint args

    
char cmd[16]; 
    
GetCmdArg(0cmdsizeof(cmd)); 
     
    if (
StrEqual(cmd"help"false)) 
    { 
        return 
Plugin_Handled
    } 
     
    return 
Plugin_Continue

PHP Code:
bool StrEqual(const char[] str1, const char[] str2bool caseSensitive
Wyon is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-19-2019 , 14:15   Re: CharToLower()
Reply With Quote #3

CharToLower only take 1 char not a string but you can accomplish what you are looking for with Wyon answer
Mathias. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-19-2019 , 14:18   Re: CharToLower()
Reply With Quote #4

CharToLower only works on single characters. As Wyon said, StrEqual has an optional argument that you can set to false to do a case-insensitive comparison (i.e. it will consider "HELP", "help", "hElP", etc... to be equal).

Actually, that reminds me, I wonder if the doc creator will ever be updated to show the default values of optional arguments. The actual signature for StrEqual is

PHP Code:
stock bool StrEqual(const char[] str1, const char[] str2bool caseSensitive=true
but the "=true" is missing from the documentation page for it.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-19-2019 , 14:38   Re: CharToLower()
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
but the "=true" is missing from the documentation page for it.
CliptonHeist is offline
Dakex
Junior Member
Join Date: Mar 2019
Old 03-19-2019 , 14:58   Re: CharToLower()
Reply With Quote #6

Thank you guys! I wasnt expecting such an friendly community!
I was programming C++, and everyone was like "if you dont know it, you are bad programmer".
Dakex is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-19-2019 , 15:22   Re: CharToLower()
Reply With Quote #7

Quote:
Originally Posted by Dakex View Post
Thank you guys! I wasnt expecting such an friendly community!
I was programming C++, and everyone was like "if you dont know it, you are bad programmer".
oh sorry we just forgot to tell you "you are a bad programmer".
jk lol, welcome

Last edited by Mathias.; 03-19-2019 at 15:22.
Mathias. is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-19-2019 , 19:46   Re: CharToLower()
Reply With Quote #8

Quote:
Originally Posted by CliptonHeist View Post
[ img ]
It's supposed to also show up in the actual prototype.

What we see:

PHP Code:
bool StrEqual(const char[] str1, const char[] str2bool caseSensitive
What we should see:
PHP Code:
stock bool StrEqual(const char[] str1, const char[] str2bool caseSensitive=true
__________________
ddhoward is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-19-2019 , 21:20   Re: CharToLower()
Reply With Quote #9

Quote:
Originally Posted by ddhoward View Post
It's supposed to also show up in the actual prototype.

What we see:

PHP Code:
bool StrEqual(const char[] str1, const char[] str2bool caseSensitive
What we should see:
PHP Code:
stock bool StrEqual(const char[] str1, const char[] str2bool caseSensitive=true
It still shows that the default for that parameter is true, but yes I agree it would be nice if default values for parameters were shown in the docs properly
CliptonHeist is offline
Reply


Thread Tools
Display Modes

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:50.


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