Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 10-28-2005 , 23:06   [SOLVED]For-Loops, Contain, len++ MOTD's
Reply With Quote #1

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,"...")
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-28-2005 , 23:16  
Reply With Quote #2

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 10-29-2005 , 16:46  
Reply With Quote #3

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.
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-29-2005 , 21:24  
Reply With Quote #4

Paste the entire code with that section.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 10-29-2005 , 22:21  
Reply With Quote #5

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,...)
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 10-29-2005 , 23:28  
Reply With Quote #6

Thanks - It works great!
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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