AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   while i++ == containi[i] problem, i need to skip letters ( fixed) (https://forums.alliedmods.net/showthread.php?t=89764)

Owyn 04-10-2009 08:22

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

new said[6], 0
    read_argv
(1said5)
    
    while (
containi(said[i], "> !") != -1)
    {
        
i++
    }
    
    while (
said[i] == '!')
    {
        
i++
    } 

hi, i'm trying to modify admin chat, so when admin types !hi it will make a hud message like @hi, but also i want to make a hud message appear he admin types > !hi
and this part i can't get to work, when admin types > !hi nothing happens, it just shows in chat like usual

and i tried
PHP Code:

if (containi(said"> !") != -1)
    {
        
i++
        
log_amx("> ! Found!")
    } 

but when admin typed > !hi
nothing it didn't found it )= no amx log was made

and if i do while (containi(said[i], "!") != -1) it works only for first characters, i want to make string like "> !hi" make an hud chat like @hi and "> !!hi" make it like @@hi

fysiks 04-10-2009 08:32

Re: while i++ == containi[i] problem
 
You are comparing a single character (said[i]) to a string of three characters ("> !")

Owyn 04-10-2009 08:35

Re: while i++ == containi[i] problem
 
yea i thought of it, and i want to know how make comparation right so it would compare to three characters right and after remove it from message like it removes "!" if it begins with em and make i++ or a thing like that like this code does with single character !
PHP Code:


    
while (said[i] == '!')
    {
        
i++
    } 


fysiks 04-10-2009 08:45

Re: while i++ == containi[i] problem
 
Code removed.

But, the first character after the last '!' will be expected to be a color indicator.

Owyn 04-10-2009 08:51

Re: while i++ == containi[i] problem
 
Quote:

replace(said, "> ", "")
that gives an argument type mismatch (arg 2) error on compile

Spunky 04-10-2009 08:54

Re: while i++ == containi[i] problem
 
Code:
replace(said, 5, "> ", "")

fysiks 04-10-2009 08:54

Re: while i++ == containi[i] problem
 
Oops, I forgot an argument. http://www.amxmodx.org/funcwiki.php?go=func&id=47

Wow, three posts all at once :).

Owyn 04-10-2009 09:02

Re: while i++ == containi[i] problem
 
PHP Code:

new said[6], 0
    read_argv
(1said5)
    
    if(
contain(said"> !") != -1)
    {
        
replace(said5"> """)
    }
    
    while (
said[i] == '!')
    {
        
i++
    } 

does not work, it does not catch when i type "> !hi" and does nothing

fysiks 04-10-2009 09:06

Re: while i++ == containi[i] problem
 
Quote:

Originally Posted by .Owyn. (Post 802166)
does not work, it does not catch when i type "> !hi" and does nothing

Try to debug it then.

Owyn 04-10-2009 09:07

Re: while i++ == containi[i] problem
 
i get no errors, and as i mentioned in 1st post thins condition does not met, dunno what is wrong


All times are GMT -4. The time now is 13:25.

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