Raised This Month: $51 Target: $400
 12% 

while i++ == containi[i] problem, i need to skip letters ( fixed)


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:10   Re: while i++ == containi[i] problem
Reply With Quote #11

You don't need errors to troubleshoot/debug the code. I always start outputing results in chat (if it's a chat command; in console if it's a console command; etc.) to see if they are what I expect. And go from there.
__________________
fysiks is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-10-2009 , 09:11   Re: while i++ == containi[i] problem
Reply With Quote #12

o no wait
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 04-10-2009 at 09:23.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:17   Re: while i++ == containi[i] problem
Reply With Quote #13

The contain condition? If so, I would troubleshoot. Try different things. Use a test code.
__________________
fysiks is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-10-2009 , 09:25   Re: while i++ == containi[i] problem
Reply With Quote #14

o no wait, now it finds it, contain condition is met, but replace idea does not work, when i type "say !hi" it works fine and shows hud, but when I type "say > !hi" debug says contain condition is met but msg is still goes to chat and no hud

PHP Code:
public cmdSayChat(id)
{
    if (!
access(idg_AdminChatFlag))
    {
        return 
PLUGIN_CONTINUE
    
}
    
    new 
said[6], 0
    read_argv
(1said5)
    
    if(
contain(said[i], ">") != -1)
    {
        
replace(said5"> """)
        
log_amx("> ! Found!")
    }
    
    while (
said[i] == '!')
    {
        
i++
    }
    
    if (!
|| 3)
    {
        return 
PLUGIN_CONTINUE
    
}
    
    new 
message[192], 0
    read_args
(message191)
    
remove_quotes(message)
    
    switch (
said[i])
    {
        case 
'z'1
        
case 'x'2
        
case 'c'3
        
case 'v'4
        
case 'b'5
        
case 'n'6
        
case 'm'7
        
    
}
    
    new 
ni
    
if (a)
    {
        
n++
        
s++
    }
    while (
said[s] && isspace(said[s]))
    {
        
n++
        
s++
    }
    

    new 
name[32], authid[32], userid
    
    get_user_authid
(idauthid31)
    
get_user_name(idname31)
    
userid get_user_userid(id)
    
    
log_amx("Chat: ^"%s<%d><%s><>^" tsay ^"%s^""nameuseridauthidmessage[n])
    
log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%L^")"nameuseridauthidmessage[n], "en"g_Colors[a])
    
    if (++
g_msgChannel || g_msgChannel 3)
    {
        
g_msgChannel 3
    
}
    
    new 
Float:verpos g_Pos[i][1] + float(g_msgChannel) / 35.0
    
    set_hudmessage
(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos06.06.00.50.15, -1)

    switch ( 
get_pcvar_num(amx_show_activity) )
    {
        case 
34:
        {
            new 
maxpl get_maxplayers();
            for (new 
pl 1pl <= maxplpl++)
            {
                if (
is_user_connected(pl) && !is_user_bot(pl))
                {
                    if (
is_user_admin(pl))
                    {
                        
show_hudmessage(pl"%s :   %s"namemessage[n])
                        
client_print(plprint_notify"%s :   %s"namemessage[n])
                    }
                    else
                    {
                        
show_hudmessage(pl"%s"message[n])
                        
client_print(plprint_notify"%s"message[n])
                    }
                }
            }
        }
        case 
2:
        {
            
show_hudmessage(0"%s :   %s"namemessage[n])
            
client_print(0print_notify"%s :   %s"namemessage[n])
        }
        default:
        {
            
show_hudmessage(0"%s"message[n])
            
client_print(0print_notify"%s"message[n])
        }
    }

    return 
PLUGIN_HANDLED

__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:28   Re: while i++ == containi[i] problem
Reply With Quote #15

Yeah, I know why, I'll try to get it working. BRB.
__________________
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:34   Re: while i++ == containi[i] problem
Reply With Quote #16

Ok, try this. I think this is probably the best. Not tested in full plugin though.

PHP Code:
    new said[6], 
    read_argv
(1said5
     
    if(
contain(said"> !") != -1
    {
        
contain(said"> !") + 2
    
}
    else
    {
        return 
PLUGIN_CONTINUE 
    
}
    
    while (
said[i] == '!'
    { 
        
i++ 
    }
    
    if (!
|| 3
    { 
        return 
PLUGIN_CONTINUE 
    

__________________
fysiks is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-10-2009 , 09:39   Re: while i++ == containi[i] problem
Reply With Quote #17

PHP Code:
    new said[6], 
    read_argv
(1said5
     
    if(
contain(said"> !") != -1
    {
        
contain(said"> !") + 2
        log_amx
("> ! Found!")
    }
    
    while (
said[i] == '!'
    { 
        
i++ 
    }
    
    if (!
|| 3
    { 
        return 
PLUGIN_CONTINUE 
    

it does not say found when i type "say > !hi" )=
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 04-10-2009 at 09:43.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:52   Re: while i++ == containi[i] problem
Reply With Quote #18

If you do it in console you MUST use quotes around the message.

Code:
say "> !Hi"
__________________
fysiks is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-10-2009 , 09:57   Re: while i++ == containi[i] problem
Reply With Quote #19

no, i do it in chat

btw, i tried this code
PHP Code:
new 0

if(said[k] == '>')
    {
        
k++
        
k++
        
k++
    } 
    
    while (
said[k] == '!')
    {
        
i++
    } 
it only works when i type >!!!hi and shows a hud saying !!!hi but does not work when i type > !!!hi with space >_< what is wrong this this?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 04-10-2009 at 10:00.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 10:03   Re: while i++ == containi[i] problem
Reply With Quote #20

I don't know. Why would anyone want something that complicate for a prefix? "> !"

But, I know that if you want it to work with more than one exclamation mark similar to the @ symbols before you will need to change hardcoded numbers and indices for hardcoded hud message variables.
__________________
fysiks is offline
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 10:18.


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