Raised This Month: $ Target: $400
 0% 

Can someone clarify why "containi" did this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-26-2006 , 00:19   Can someone clarify why "containi" did this?
Reply With Quote #1

Code:
if(containi(szModel, "models/mymodel.mdl"))      client_print(id, print_chat, "True") if(!containi(szModel, "models/mymodel.mdl"))      client_print(id, print_chat, "False");

So this is what I have, lets say that the item that is supposed to trigger this event does not have mymodel.mdl, but has a different model, but it triggers as "True", and the item that does have mymodel.mdl triggers "False"...
O.o whats up with that??
doesn't !containi mean if it doesn't contain the model "mymodel"???
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-26-2006 , 00:20   Re: Can someone clarify why "containi" did this?
Reply With Quote #2

Code:
if(containi(szModel, "models/mymodel.mdl") != -1)     client_print(id, print_chat, "True") if(containi(szModel, "models/mymodel.mdl") == -1)     client_print(id, print_chat, "False");

contain or containi return -1 when it doesn't contain your argument. If it contain your argument I believe it will return the cell it start at.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-26-2006 , 00:33   Re: Can someone clarify why "containi" did this?
Reply With Quote #3

Now everything comes out as true.
O.o
I'm gonna stick with
Code:
if(!containi(szModel, "models/mymodel.mdl"))      client_print(id, print_chat, "True");
since it works.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-26-2006 , 00:47   Re: Can someone clarify why "containi" did this?
Reply With Quote #4

Code:
#include <amxmodx> new szModel[] = "models/mymodel.mdl"; public plugin_init() {     new IsTrue = containi(szModel, "models/mymodel.mdl"); // This will match     if(IsTrue != -1)         log_amx("[containi] is true %i", IsTrue);     new IsFalse = containi(szModel, "models/_mymodel.mdl"); // This won't match     if(IsFalse == -1)         log_amx("[containi] is false %i", IsFalse); }

Quote:
L 10/25/2006 - 21:55:40: [test.amxx] [containi] is true 0
L 10/25/2006 - 21:55:40: [test.amxx] [containi] is false -1
It seem from that code your going to match a string to another string and match it completely .. So I would just use equali

Since your doing if(!containi("What", "What")) So it kinda be the same thing as if(equal("What", "What")) if your checking if it return 0.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 10-26-2006 at 01:30.
teame06 is offline
Send a message via AIM to teame06
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-26-2006 , 09:54   Re: Can someone clarify why "containi" did this?
Reply With Quote #5

alright I'll try that when I come back from school today.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 10-26-2006 , 15:09   Re: Can someone clarify why "containi" did this?
Reply With Quote #6

I could be wrong on some of this...so I'll admit it if I am. This was just thrown together of the top of my head.

Code:
equal - Checks if two strings are equal. 
equal ( const a[], const b[], [ c ] ) 

Example: if(equal(string, mystring))
This checks if string and mystring are exactly the same, case for case.
string = Test, mystring = Test: Both strings are equal
string = Test, mystring = tEsT: Both strings are not equal

equali - Checks if two strings are equal, case insensitive.
equali ( const a[], const b[], [ c ] )
 
Example: if(equali(string, mystring))
This checks if string and mystring are the same, regardless of case.
string = test, mystring = TesT, equali will return that string and mystring are the same

contain - Returns position of string found inside of source, or -1 on failure. 
contain ( const source[], const string[] ) 

Example: Using mapname...if(contain(map, "cs_"))
This checks if anywhere in the mapname contains the string "cs_" Exactly
if(contain(map, "Cs_"))
This checks if anywhere in the mapname contains the string "Cs_" Exactly.
Will return false if mapname is "cs_assualt", etc.

containi - Returns position of string found inside of source, or -1 on failure. Case insensitive. 
containi ( const source[], const string[] ) 

Example: Using mapname...if(containi(map, "awp_"))
This checks if anywhere in the mapname contains the string "awp_", regardless of case.
So mapname of "Awp_" or "aWp_" will return true.

Then the extra values are your choice:

> -1
!= -1
== -1

Last edited by organizedKaoS; 10-26-2006 at 15:15.
organizedKaoS is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-26-2006 , 19:13   Re: Can someone clarify why "containi" did this?
Reply With Quote #7

well yeah, that SHOULD be correct
Except for that I have 2 models
Lets name em:
w_firstmodel.mdl, and w_secondmodel.mdl
I do "containi(model, "w_firstmodel.mdl"); but models with the w_secondmodel.mdl are triggering the containi true.
Why? O.o

edit:
I'm gonna use equali, it works (and makes more sense)
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))

Last edited by TheNewt; 10-26-2006 at 19:26.
TheNewt is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-26-2006 , 19:29   Re: Can someone clarify why "containi" did this?
Reply With Quote #8

Code:
if(containi(model, "w_firstmodel.mdl")) { } if(containi(model, "w_secondmodel.mdl")) {      // Will be true even if it can't find it. }

Is this what your code look like?

If that is what it look like. Since it return -1 if it not found. Then if(-1) is still true. if(1) is still true. The only time it will return false is when it if(0) but for containi returning 0 mean it matches the string you want with the string your searching. When it return -1 it mean it couldn't find a match in your string. So you need to check it return value is greater than -1 or does not equal to -1 for contain or containi.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-26-2006 , 20:33   Re: Can someone clarify why "containi" did this?
Reply With Quote #9

Gotcha. =P
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
k007
BANNED
Join Date: Mar 2006
Location: bacon?
Old 10-27-2006 , 01:01   Re: Can someone clarify why "containi" did this?
Reply With Quote #10

yeah mystic use equali or equal it's better the containi is usaly used to find letters, names.. etc
k007 is offline
Send a message via MSN to k007
Reply


Thread Tools
Display Modes

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 04:45.


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