AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why in this code bonus doesn't work (https://forums.alliedmods.net/showthread.php?t=252000)

danonix 11-23-2014 15:25

Why in this code bonus doesn't work
 
Hello, I have changed a bit code from surf-desk, to earn bonus from npc, but only bonus is error, and I'm not receiving bonus from NPC ( for example model )etc.
Can someone analize this ? please

Exactly this:
Code:

L 11/23/2014 - 10:23:25: String formatted incorrectly - parameter 4 (total 3)
L 11/23/2014 - 10:23:25: [AMXX] Displaying debug trace (plugin "mikolaj.amxx")
L 11/23/2014 - 10:23:25: [AMXX] Run time error 25: parameter error
L 11/23/2014 - 10:23:25: [AMXX]    [0] colorchat.inc::ColorChat (line 51)
L 11/23/2014 - 10:23:25: [AMXX]    [1] mikolaj.sma::SprawdzPrezent (line 129)
L 11/23/2014 - 10:23:25: [AMXX]    [2] mikolaj.sma::npcMenuEnter (line 185)

I have got this piece of code
Code:

public plugin_init(){
register_menucmd(register_menuid("npcMenu"), menuKeys, "npcMenuEnter");
}

....

public SprawdzPrezent(id)
{
        if(is_user_alive(id))       
        {
                NieDostal[id] = true;
                new prezent = random_num(0, 7);
                switch(prezent){
                        case 0:{

                        }

                        }
                        case 2: {
                                ColorChat(id, GREEN, "[%s]^x01 Swiatecznie dostales prezent - super vipa na jedna mape!")
                                set_user_flags(id, get_user_flags(id) | ADMIN_LEVEL_G);
                                server_cmd("amx_reloadadmins");
                        }
                        case 3: {

                        }
                        case 4: {
                        }
                        case 5: {
                        }
                        case 6: {
                        }
                        case 7: {

                        }
                       
                }
        }
        return FMRES_HANDLED;
}

//////////////////////////////////////////////
// NPC STUFF
//////////////////////////////////////////////
public npcMenu(id)
{
        if(get_user_flags(id) & ADMIN_IMMUNITY){
                new name[33], text[512];
               
                get_user_name(id, name, 32);
                format(text, 511, "Witaj %s!^n^nHave you got present?t?\y^n^n1: No  -  2: Yes", name);
               
                show_menu(id, menuKeys, text, -1, "npcMenu");
                return FMRES_HANDLED;
        }
        return PLUGIN_CONTINUE
}

public npcMenuEnter(id, key)
{
        switch(key)
        {
                case 0:
                {       
                        if(!NieDostal[id]) SprawdzPrezent(id);
                        else ColorChat(id, GREEN, "[%s]You took present already!", PREFIX);
                        inMenu[id] = false;
                }
                case 1:
                {
                        inMenu[id] = false;
                }
        }
}


WildCard65 11-23-2014 15:35

Re: Why in this code bonus doesn't work
 
You forgot to specify what %s is suppose to be in call to ColorChat

danonix 11-23-2014 15:39

Re: Why in this code bonus doesn't work
 
Could you explain please?

fysiks 11-23-2014 15:41

Re: Why in this code bonus doesn't work
 
For every % parameter in a formatted string, you must have a corresponding variable that will be used in the formatting process.

danonix 11-23-2014 15:53

Re: Why in this code bonus doesn't work
 
Ohh yeah! I forgot to put Prefix at the end of ColorChat lol. Right thanks!

Can someone tell me one more thing please?
If I have got here, in cases, bonus for players they are not getting it. Why?
Or just maybe everything was fine, but I didn't get message about that? lol
Code:

                        case 0:{ Y
                        }
                        }
                        case 2: {
                                ColorChat(id, GREEN, "[%s]^x01 Swiatecznie dostales prezent - super vipa na jedna mape!")
                                set_user_flags(id, get_user_flags(id) | ADMIN_LEVEL_G);
                                server_cmd("amx_reloadadmins");
                        }
                        case 3: { D
                        }
                        case 4: { A
                        }
                        case 5: { S
                        }
                        case 6: { B
                        }
                        case 7: { C
 
                        }


YamiKaitou 11-23-2014 15:55

Re: Why in this code bonus doesn't work
 
Because you are issuing amx_reloadadmins after you set the flag, resulting in the flag being removed. Just using set_user_flags is enough to change their access

danonix 11-23-2014 16:06

Re: Why in this code bonus doesn't work
 
Quote:

Originally Posted by YamiKaitou (Post 2227503)
Because you are issuing amx_reloadadmins after you set the flag, resulting in the flag being removed. Just using set_user_flags is enough to change their access

Thanks dude!

Have a good night guys, thanks for answers


All times are GMT -4. The time now is 17:41.

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