AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   CharToLower() (https://forums.alliedmods.net/showthread.php?t=315051)

Dakex 03-19-2019 12:37

CharToLower()
 
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?

Wyon 03-19-2019 13:49

Re: CharToLower()
 
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


Mathias. 03-19-2019 14:15

Re: CharToLower()
 
CharToLower only take 1 char not a string but you can accomplish what you are looking for with Wyon answer

Powerlord 03-19-2019 14:18

Re: CharToLower()
 
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.

CliptonHeist 03-19-2019 14:38

Re: CharToLower()
 
Quote:

Originally Posted by Powerlord (Post 2644039)
but the "=true" is missing from the documentation page for it.

https://i.gyazo.com/d30a602f6d2266d6...0824fa1b92.png

Dakex 03-19-2019 14:58

Re: CharToLower()
 
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".

Mathias. 03-19-2019 15:22

Re: CharToLower()
 
Quote:

Originally Posted by Dakex (Post 2644041)
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 :)

ddhoward 03-19-2019 19:46

Re: CharToLower()
 
Quote:

Originally Posted by CliptonHeist (Post 2644040)
[ 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


CliptonHeist 03-19-2019 21:20

Re: CharToLower()
 
Quote:

Originally Posted by ddhoward (Post 2644074)
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


All times are GMT -4. The time now is 21:14.

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