[HELP] How to control only first few characters of a string
Hello, I need a little help.
For example if the string I have would be "123456789". If the string begins with "123", it would do the function I want to. If it begins with any other number/character, I want to perform another function (if/else). That's all, thank you! simply: string is 123456789 if string begins with 123 = perform function else = perform another function |
Re: [HELP] How to control only first few characters of a string
native equali(const a[],const b[],c=0);
Example: Code:
|
Re: [HELP] How to control only first few characters of a string
Quote:
Can you explain this part of code? Code:
If I understand it well, the first part of code means - if lenMapName variable has length of more than 4 characters & first 4 characters of mapName variable match and it ends with bsp, then it does the function? But I don't understand the thing i quoted in [ PAWN ]. |
Re: [HELP] How to control only first few characters of a string
If the last 4 mapName characters are equal to '.bsp', then they are removed from the string.
'^0' is espace character for the integer 0. It it used to not use an integer, and let the code reader know that mapName stores an string instead of a array on integers. See also: |
Re: [HELP] How to control only first few characters of a string
Just use equal/equali and specify the number of characters that you want to be checked in the 3 rd param.
|
Re: [HELP] How to control only first few characters of a string
Well, what if I want to use it for a cvar?
for example - amx_randomcvar has a value: 123456 I just need to check for the first three characters, if they are equal, then the function I want (for example user_kill) may be triggered. Can you post me an example of that? |
Re: [HELP] How to control only first few characters of a string
Code:
Prefer 'get_pcvar_string' instead of 'get_cvar_string' because they are faster, but you need the cvar pointer, which you can save at register_cvar. Example: Code:
|
Re: [HELP] How to control only first few characters of a string
Quote:
|
Re: [HELP] How to control only first few characters of a string
Quote:
Works like a charm! Thank you! :) Oh and sorry for my English :P |
| All times are GMT -4. The time now is 09:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.