[Question] Null parameter constant, loop inside a loop
Hey, I wanted to ask you here two questions, far far different. I know that on oe thread there should be one topic, but these questions are pretty little and not that improtant (and people here don't like giving PM support, so...) and I thought it would be better to put them in one thread isntead of flooding with useless threads. But anyways, if it's problem, I'll post nother thread.
The first question is if there is some problem with making a loop inside another loop? I'm asking this, beacuse sometimes I want to combine two constants in one and I have to use two loops inside, one inside the other. Giving example: PHP Code:
And the second question I want to know just for information - does living a null parameter in a constant matter with something? I mean, that empty space that is used as a null parameter in the constants so often. I ask this, beacause the arrays also start from index 0, like the constants. Does this null parameter mean with something? PHP Code:
|
Re: [Question] Null parameter constant, loops
It's fine to make loops inside loops, however in Pawn, you should consider not creating variables inside loops (in your case the variable a is created inside a loop) to not needlessly re-create them on each iteration.
You don't have to add a null value to the arrays. Since the indexing starts from 0, in the loop you just do new i = 0 (or rather, just new i) instead of = 1 and for the array you just skip the null value: new const array[] = {"value1", "value2", ...}. |
Re: [Question] Null parameter constant, loops
(Uhm, the string is created otside any functions, it's global)
Okay, thanks! Waiting for another opinions, since I've heard many different things about that null parameter. |
Re: [Question] Null parameter constant, loops
"a" is created inside of the first loop.
Start using 0 as the first index. You're wasting memory for no reason. If you register "say /" it will only match "say /" not, for example, "say /hello". |
Re: [Question] Null parameter constant, loops
Well, the idea of these loops is the current keyword typed in all the styles. That's why I formatexed them side by side, so all of the keywords will be registered after each style. About that "a", right.
|
Re: [Question] Null parameter constant, loops
Oh right. Sorry.
|
Re: [Question] Null parameter constant, loop inside a loop
Problems solved, thanks to all these guys! Okay, now for that topics. I don't want to look stupid, but I rather ask you what to do, when obviously there are two topic in one thread here and this is against the rules.
|
Re: [Question] Null parameter constant, loop inside a loop
I'm not sure what you're asking.
In some cases it serves a purpose. For example when using an array of strings to convert a weapon index to a weapon name. Since there is not weapon id 0 there's no point of filling that with anything. And you could of course shift everything by 1 step and use mystringarray[weaponid - 1], but that would just make things complicated for no good reason. |
Re: [Question] Null parameter constant, loop inside a loop
I was asking what to do with the problem, that there are two topics in one thread. To delete one of the questions or what? Because it's violating the rules.
Thanks for the information! |
| All times are GMT -4. The time now is 21:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.