AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]For-Loops, Contain, len++ MOTD's (https://forums.alliedmods.net/showthread.php?t=19936)

Charr 10-28-2005 23:06

[SOLVED]For-Loops, Contain, len++ MOTD's
 
Quote:

Originally Posted by Charr
Ive been trying to add a search funciton to amx_help, but with absolutly no success. I've been tring for over two hours now, and it just won't work. It prints all commands availible to a person, floods the realible channel, or prints several random commands.

I've narrowed down the problem to the contain, because when I use equal in its place, it works fine.

The problem was:
Code:
if(contain(a,b))
Wasn't properly returning all the Information in a for-loop.
Solution:
Code:
if(contain(a,b)!=-1)

And the other problem was:
Code:
len = format(motd,sizeof(motd)-len,"...")
Each line overwrote the line before it in a loop.
Solution:
Code:
len += format(motd[len],sizeof(motd)-len,"...")

Hawk552 10-28-2005 23:16

You should use if(contain(whatever)!=-1) { do stuff }

Edit: Scratch the below, thought it was contain.
You should also use containi if it's user related input stuff, As SoMe PeOpLe TyPe LIKE ThiS.

Edit2: You should also not use if(equal(whatever,""). Instead, use if(!string). I've found the equal version never works.

Charr 10-29-2005 16:46

The !=-1 worked, and how do you use format inside of a for-loop, cause I used:
Code:
len = format(motd,sizeof(motd)-len,...)
And it didnt work since the len value is the same for each line, so only the last line shows.

Hawk552 10-29-2005 21:24

Paste the entire code with that section.

Xanimos 10-29-2005 22:21

Quote:

Originally Posted by Charr
The !=-1 worked, and how do you use format inside of a for-loop, cause I used:
Code:
len = format(motd,sizeof(motd)-len,...)
And it didnt work since the len value is the same for each line, so only the last line shows.

its
Code:
len += format(motd[len] , sizeof(motd)-len,...)

Charr 10-29-2005 23:28

Thanks - It works great!


All times are GMT -4. The time now is 00:03.

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