Raised This Month: $ Target: $400
 0% 

Message's bugged!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-07-2012 , 17:23   Message's bugged!
Reply With Quote #1

Hello there,

i hooked say, but for example im saying 'You know i love you' i still unlock the phrase, it has to be only: 'i love you' for example. What am i doing wrong here?

PHP Code:
public CmdSay(id)
{
    new 
message[192], name[32]
    
read_args(messagecharsmax(message))
    
get_user_name(idname31)
    
remove_quotes(message)
    
    if (
contain(message"i love you") >= 0)
    {
        
client_cmd(0"spk misc/trophy.wav")
        
ColorChat(idGREY"%s ^4%s^1 has unlocked the achievement: ^4Secret Phrase #1"Prefixname)
        return 
PLUGIN_HANDLED
    
}
    if (
contain(message"i hate you") >= 0)
    {
        
        
client_cmd(0"spk misc/trophy.wav")
        
ColorChat(idGREY"%s ^4%s^1 has unlocked the achievement: ^4Secret Phrase #2"Prefixname)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.

Last edited by Bilal Pro; 05-07-2012 at 17:27.
Bilal Pro is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-07-2012 , 21:52   Re: Message's bugged!
Reply With Quote #2

Code:
if(containi(message, "i love you") != -1)
use containi as to make sure its is NOT case sensitive.
containi returns -1 on failure, so just make sure that it DOES NOT EQUAL -1, rather than >= 0 -a more direct way of doing it.
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 01:49   Re: Message's bugged!
Reply With Quote #3

Are you sure you hooked it correctly? Everything looks correct to me.

Quote:
Originally Posted by Liverwiz View Post
Code:
if(containi(message, "i love you") != -1)
use containi as to make sure its is NOT case sensitive.
containi returns -1 on failure, so just make sure that it DOES NOT EQUAL -1, rather than >= 0 -a more direct way of doing it.
>=0 and !=-1 are the same thing (regarding contain and containi). That's twice now. Also, he doesn't have to use case insensitive functions if he doesn't want to do so.
__________________

Last edited by fysiks; 05-08-2012 at 01:49.
fysiks is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-08-2012 , 08:34   Re: Message's bugged!
Reply With Quote #4

Use equal, it checks if 2 strings are the same, which you need in this case.
Contain only checks if one string contains the other, but that doesn't mean they are the same.
__________________

Last edited by <VeCo>; 05-08-2012 at 08:35.
<VeCo> is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-08-2012 , 08:46   Re: Message's bugged!
Reply With Quote #5

@fysiks, Im pretty sure that i hooked it correctly

@Veco, What do you mean with use equal?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-08-2012 , 08:52   Re: Message's bugged!
Reply With Quote #6

Ok, you are saying "You know I love you". The string that you need is "I love you".
Then contain cheks if the message contains the needed string, so that's: "You know I love you". It just checks if the needed string is somewhere in the message, not if the message is the same as the string you want.
So you need equal - it will check if the message is exactly the same as the string: "You know I love you" won't pass this time, because there is also "You know ", which you don't want, so the funtion will be called only if you type "I love you" (nothing more, nothing less) - that's what you need.
__________________

Last edited by <VeCo>; 05-08-2012 at 08:53.
<VeCo> is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-08-2012 , 09:03   Re: Message's bugged!
Reply With Quote #7

But i can unlock it either in another sentec, for example: owkadoawjlad i love you.

It will still unlock :s
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.

Last edited by Bilal Pro; 05-08-2012 at 09:12.
Bilal Pro is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-08-2012 , 09:20   Re: Message's bugged!
Reply With Quote #8

Use equal and you won't have such problem.
__________________
<VeCo> is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-08-2012 , 09:25   Re: Message's bugged!
Reply With Quote #9

Thank you sir, worked really well
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 12:59   Re: Message's bugged!
Reply With Quote #10

Using equal is not a solution to finding a string within a string like he was originally trying to do. I don't know how he got it to work with equal because it's not possible to say "You know I love you" and use equal() to know if the string "i love you" is in it.
__________________
fysiks is offline
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 00:29.


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