shorten a string ?
I want to retunr a part of my string. How I'm supposed to do that ?
Exemple : new String:test[32]; Format(test, sizeof(test), "just a test"); And I want to shorten the content of test to "just" |
Re: shorten a string ?
They easiest you can do in this case is this.
PHP Code:
Impact |
Re: shorten a string ?
Quote:
if(test[4] == "test") PrintToChatAll("Sucess, the value of "test" is %s", test[0]); it's will work ? EDIT : Yep, it's work. |
Re: shorten a string ?
No, don't do that.
Strings are char arrays, thus the number there is a index of the array which refers to a single char. You can't compare chars with strings that way, use something like this instead. Using an string index with PrintTo* is a special case i won't explain here, more info below. Before you continue, please head over here and read how strings in SourcePawn work. Yours sincerely Impact |
Re: shorten a string ?
Quote:
|
Re: shorten a string ?
You don't really need to fullquote.
Yours sincerely Impact |
Re: shorten a string ?
Okay, but now I don't understand. How I can use this ?
PHP Code:
It does print : "Don't work," :( |
Re: shorten a string ?
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:
PHP Code:
PHP Code:
|
Re: shorten a string ?
Quote:
|
Re: shorten a string ?
He used PrintToChat in his code, thus i referred to that.
Yours sincerely Impact |
All times are GMT -4. The time now is 02:05. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.