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

Get String[] first character problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_COLOURFUL
Member
Join Date: May 2017
Location: Hong Kong
Old 09-01-2017 , 11:07   Get String[] first character problem
Reply With Quote #1

Code:
	new String:arg[128];
	GetCmdArg(1, arg, sizeof(arg));
	if(StrEqual(arg[0], "/") || StrEqual(arg[0], "!"))
	{
		blah blah blah...
	}
SourcePawn just ignored the "[0]" instead of processing like "String:arg[128]".
How to Get String[] first character?
__________________
Love Dodgeball
_COLOURFUL is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-01-2017 , 11:21   Re: Get String[] first character problem
Reply With Quote #2

It did not ignore it, it did what's called array/string slicing.
What you can do is
Code:
if(arg[0] == '/' || arg[0] == '!')
klippy is offline
_COLOURFUL
Member
Join Date: May 2017
Location: Hong Kong
Old 09-01-2017 , 13:44   Re: Get String[] first character problem
Reply With Quote #3

Oh thanks fixed.
__________________
Love Dodgeball
_COLOURFUL is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 09-01-2017 , 17:00   Re: Get String[] first character problem
Reply With Quote #4

If you need compare only part of string use strncmp function.
for example:
PHP Code:
if (strncmp(buffer"weapon_"7) == 0// if string start with "weapon_" 
Kailo 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 16:02.


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