AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error: Must be a constant expression // help please (https://forums.alliedmods.net/showthread.php?t=206707)

danonix 01-25-2013 11:15

Error: Must be a constant expression // help please
 
Hello guys, I need your help again. How I can do it, so It wont send me error? I want to do prefix in say as same as actual rank. Thanks

Code:

public handleSayText(msgId,msgDest,msgEnt){
        new id = get_msg_arg_int(1);
        static stats[8]
       
            new ranga[30]
 
    if ( stats[0] >= 0 && stats[0] <= 29)
        format(ranga,29,"Lamus")
    else if ( stats[0] >= 30 && stats[0] <= 59)
        format(ranga,29,"Poczatkujacy")
    else if ( stats[0] >= 60 && stats[0] <= 119)
        format(ranga,29,"Wiesniak")
    else if ( stats[0] >= 120 && stats[0] <= 209)
        format(ranga,29,"Sierota")
    else if ( stats[0] >= 210 && stats[0] <= 324)
        format(ranga,29,"Kox")
    else if ( stats[0] >= 325 && stats[0] <= 499)
        format(ranga,29,"Cherlak")
    else if ( stats[0] >= 500 && stats[0] <= 729)
        format(ranga,29,"Kozak")
    else if ( stats[0] >= 730 && stats[0] <= 999)
        format(ranga,29,"Snajper")
    else if ( stats[0] >= 100 && stats[0] <= 1399)
        format(ranga,29,"Macho")
    else if ( stats[0] >= 1400 && stats[0] <= 1849)
        format(ranga,29,"Rambo")
    else if ( stats[0] >= 1850 && stats[0] <= 2299)
        format(ranga,29,"Terminator")
    else if ( stats[0] >= 2300 && stats[0] <= 2899)
        format(ranga,29,"Joker")
    else if ( stats[0] >= 2900 && stats[0] <= 3549)
        format(ranga,29,"Morfeusz")
    else if ( stats[0] >= 4200 && stats[0] <= 4999)
        format(ranga,29,"Wybraniec")
    else if ( stats[0] >= 5000 && stats[0] <= 5899)
        format(ranga,29,"Killer")
    else if ( stats[0] >= 5900 && stats[0] <= 6899)
        format(ranga,29,"Multi Killer")
    else if ( stats[0] >= 6900 && stats[0] <= 7999)
        format(ranga,29,"Owner")
    else if ( stats[0] >= 8000 && stats[0] <= 9299)
        format(ranga,29,"Cziter")
    else if ( stats[0] >= 9300 && stats[0] <= 1999)
        format(ranga,29,"Vip TeamKielce")
    else if ( stats[0] >= 1000 )
        format(ranga,29,"GM TeamKielce")
       
        if(is_user_connected(id)){
                new szTmp[256],szTmp2[256];
                get_msg_arg_string(2,szTmp, charsmax(szTmp))
               
                new szPrefix[64] = ranga;
               
                if(!equal(szTmp,"#Cstrike_Chat_All")){
                        add(szTmp2,charsmax(szTmp2),szPrefix);
                        add(szTmp2,charsmax(szTmp2)," ");
                        add(szTmp2,charsmax(szTmp2),szTmp);
                }
                else{
                        add(szTmp2,charsmax(szTmp2),szPrefix);
                        add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 :  %s2");
                }
                set_msg_arg_string(2,szTmp2);
        }
        return PLUGIN_CONTINUE;
}


fysiks 01-25-2013 16:21

Re: Error: Must be a constant expression // help please
 
You said in your other thread that you already have a plugin that does this and that you only need to move the rank names to a file. So, you have implied that you already have a plugin that works. In this case, you merely need to add reading a file into an array of strings and then replacing the hard coded rank names with the array indexed appropriately.

If this is not the case, you need to be much more clear when you post for help.

danonix 01-26-2013 02:55

Re: Error: Must be a constant expression // help please
 
I gave up, I can't do this alone, so I would like just to make a prefix in chat that if X person has got 1000 frags it shows "Macho" as a prefix in say, just that.

Cheers

@@ Ok, I found that on polish forum, if someone ever will need that, here is the code for it. Cheers

Code:

public handleSayText(msgId,msgDest,msgEnt){
        new id = get_msg_arg_int(1);
       
        if(!is_user_connected(id))        return PLUGIN_CONTINUE;
       
        new szTmp[256],szTmp2[256];
        get_msg_arg_string(2,szTmp, charsmax( szTmp ) )
       
        new szPrefix[64]
        formatex(szPrefix,charsmax(szPrefix),"^x04[Ranga: %s]",ranga)
       
        if(!equal(szTmp,"#Cstrike_Chat_All")){
                add(szTmp2,charsmax(szTmp2),szPrefix);
                add(szTmp2,charsmax(szTmp2)," ");
                add(szTmp2,charsmax(szTmp2),szTmp);
        }
        else{
                add(szTmp2,charsmax(szTmp2),szPrefix);
                add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 :  %s2");
        }
       
        set_msg_arg_string(2,szTmp2);
       
        return PLUGIN_CONTINUE;
}



All times are GMT -4. The time now is 20:32.

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