AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   is here somethinge wrong ? (https://forums.alliedmods.net/showthread.php?t=214849)

risontek22 04-30-2013 11:35

is here somethinge wrong ?
 
hi, a would like ask you what is here wrong?

PHP Code:

public Body_Vloz(id)
{
    new 
Sprava[256]
    
read_argv(idSpravacharsmax(Sprava))
    if(!(
equali(Sprava,"ALL")) || !(equali(Sprava,"all")))
    {
    
        if((
containi(Sprava"q") != -1) || 
        (
containi(Sprava"w") != -1) || 
        (
containi(Sprava"e") != -1) || 
        (
containi(Sprava"r") != -1) || 
        (
containi(Sprava"t") != -1) || 
        (
containi(Sprava"z") != -1) || 
        (
containi(Sprava"u") != -1) || 
        (
containi(Sprava"i") != -1) || 
        (
containi(Sprava"o") != -1) || 
        (
containi(Sprava"p") != -1) || 
        (
containi(Sprava"a") != -1) || 
        (
containi(Sprava"s") != -1) || 
        (
containi(Sprava"d") != -1) || 
        (
containi(Sprava"f") != -1) || 
        (
containi(Sprava"g") != -1) || 
        (
containi(Sprava"h") != -1) || 
        (
containi(Sprava"i") != -1) || 
        (
containi(Sprava"k") != -1) || 
        (
containi(Sprava"l") != -1) || 
        (
containi(Sprava"m") != -1) || 
        (
containi(Sprava"n") != -1) || 
        (
containi(Sprava"b") != -1) || 
        (
containi(Sprava"v") != -1) || 
        (
containi(Sprava"c") != -1) ||
        (
containi(Sprava"y") != -1) || 
        (
containi(Sprava"x") != -1))
        {
            
ChatColor(id,"%s Do kolonky napis len !tcislo!y alebo slovo !tall",Prefix)
            return 
PLUGIN_HANDLED
        
}
    }
    if(
equali(Sprava,"ALL") || equali(Sprava,"all"))
    {
        
UserBank[id] += UserMoney[id]
        
ChatColor(id,"%s Uspesne si si do banky vlozil %i$",Prefix,UserMoney[id])
        
UserMoney[id] = 0
    
    
}
    else
    {
        new 
Vklad 
        Vklad 
Sprava[charsmax(Sprava)]
        if(
Vklad >= UserMoney[id])
        {
            
UserBank[id] += Vklad
            UserMoney
[id] -= Vklad
            ChatColor
(id,"%s Uspesne si si do banky vlozil %i$",Prefix,Vklad)
        }
        else
        {
            
Vklad -= UserMoney[id]
            
ChatColor(id,"%s Nemas tolko penazi, chyba ti %i$",Prefix,Vklad)
        }
    }
    return 
PLUGIN_HANDLED



Backstabnoob 04-30-2013 11:51

Re: is here somethinge wrong ?
 
Code:
        if((containi(Sprava, "q") != -1) ||           (containi(Sprava, "w") != -1) ||           (containi(Sprava, "e") != -1) ||           (containi(Sprava, "r") != -1) ||           (containi(Sprava, "t") != -1) ||           (containi(Sprava, "z") != -1) ||           (containi(Sprava, "u") != -1) ||           (containi(Sprava, "i") != -1) ||           (containi(Sprava, "o") != -1) ||           (containi(Sprava, "p") != -1) ||           (containi(Sprava, "a") != -1) ||           (containi(Sprava, "s") != -1) ||           (containi(Sprava, "d") != -1) ||           (containi(Sprava, "f") != -1) ||           (containi(Sprava, "g") != -1) ||           (containi(Sprava, "h") != -1) ||           (containi(Sprava, "i") != -1) ||           (containi(Sprava, "k") != -1) ||           (containi(Sprava, "l") != -1) ||           (containi(Sprava, "m") != -1) ||           (containi(Sprava, "n") != -1) ||           (containi(Sprava, "b") != -1) ||           (containi(Sprava, "v") != -1) ||           (containi(Sprava, "c") != -1) ||         (containi(Sprava, "y") != -1) ||           (containi(Sprava, "x") != -1))

Really? Why not just check if the amount is numeric?

Code:
if(equali(Sprava,"ALL") || equali(Sprava,"all"))

This + the else will never be called because you're preventing the rest of the code from executing by doing what you did above.

risontek22 04-30-2013 12:54

Re: is here somethinge wrong ?
 
how can i chect it ?
and it is called becouse in start before containi... is
PHP Code:

if(!(equali(Sprava,"ALL")) || !(equali(Sprava,"all"))) 


Backstabnoob 04-30-2013 14:34

Re: is here somethinge wrong ?
 
I don't get it

daniel46 04-30-2013 14:45

Re: is here somethinge wrong ?
 
make const of all your letter or whatever and then make FOR for all of the const DONE

risontek22 04-30-2013 15:39

Re: is here somethinge wrong ?
 
But how can i do this, for example. If(sprava >= usermonez) ? This dpnt work

Backstabnoob 04-30-2013 15:59

Re: is here somethinge wrong ?
 
Go read some tutorials on pawn basics before attempting to code, there's plenty on these forums.

hornet 05-01-2013 04:44

Re: is here somethinge wrong ?
 
Explain what you actually want to achieve.

risontek22 05-01-2013 05:25

Re: is here somethinge wrong ?
 
Bank this is function called on messagemod Body_Vloz

hornet 05-01-2013 06:11

Re: is here somethinge wrong ?
 
You could run a simple check like !str_to_num() instead of having all of that ridiculous code. Also you do realise that || means or? Which means that your function would never reach the rest of the code as Backstabnoob said?


All times are GMT -4. The time now is 10:54.

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