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

Solved check a string from enum


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-04-2021 , 18:28   check a string from enum
Reply With Quote #1

hello
PHP Code:

enum _
:DATA
{
NAME[35]
}

new 
g_szSomething[33][DATA]

public function()
{
if(
g_szSomething[NAME] != EOS_
//do stuff


Last edited by lexzor; 05-04-2021 at 19:41.
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-04-2021 , 18:50   Re: check a string from enum
Reply With Quote #2

NAME within the enum is an array, and you are sizing DATA already as part of a 2-dimension array, making it a 3-dimension array for the NAME variable.

PHP Code:
if ( g_szSomethingindex ][ NAME ][ ] == EOS )

    
//eat cabbage

__________________
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-04-2021 , 19:41   Re: check a string from enum
Reply With Quote #3

Thanks.
lexzor is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 05-05-2021 , 04:30   Re: check a string from enum
Reply With Quote #4

you can use strlen too.
__________________
LondoN is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2021 , 09:36   Re: check a string from enum
Reply With Quote #5

While the difference is negligible, it's more efficient to not call a native and just check that the first char is null/EOS.
__________________
Bugsy 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 14:18.


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