View Single Post
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 08-12-2013 , 09:21   Re: shorten a string ?
Reply With Quote #8

Do you know what the string is actually equivalent to? I am going to presume that it is as you stated earlier: "just a test". The native StrEqual is going to check if two strings are 100% equal (use the bool to enable/disable case sensitivity).

So if you define String test like this:
PHP Code:
new String:sTest[] = { "just a test" }; 
and then check this:
PHP Code:
if (StrEqual(sTest"just"))
{
    
LogError("This Worked");
} else
{
    
LogError("This Did Not Work");

Then it is ALWAYS going to return false, because String:sTest is not "just" but rather "just a test". For that kind of a check you want to do something like this:
PHP Code:
if (StrContains(sTest"just") != -1)
{
    
LogError("This Worked");
} else
{
    
LogError("This Did Not Work");

StrContains is a nice native that simply checks if one string is found inside another; if the string is not found, a value of -1 is returned (this is why you specify != -1). Hope this helps you!
Marcus_Brown001 is offline