Raised This Month: $ Target: $400
 0% 

Why in this code bonus doesn't work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 11-23-2014 , 15:25   Why in this code bonus doesn't work
Reply With Quote #1

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;
		}
	}
}

Last edited by danonix; 11-23-2014 at 15:26.
danonix is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 11-23-2014 , 15:35   Re: Why in this code bonus doesn't work
Reply With Quote #2

You forgot to specify what %s is suppose to be in call to ColorChat
__________________

Last edited by WildCard65; 11-23-2014 at 15:35.
WildCard65 is offline
danonix
Senior Member
Join Date: Dec 2012
Old 11-23-2014 , 15:39   Re: Why in this code bonus doesn't work
Reply With Quote #3

Could you explain please?
danonix is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-23-2014 , 15:41   Re: Why in this code bonus doesn't work
Reply With Quote #4

For every % parameter in a formatted string, you must have a corresponding variable that will be used in the formatting process.
__________________
fysiks is offline
danonix
Senior Member
Join Date: Dec 2012
Old 11-23-2014 , 15:53   Re: Why in this code bonus doesn't work
Reply With Quote #5

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
 
			}

Last edited by danonix; 11-23-2014 at 15:54.
danonix is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-23-2014 , 15:55   Re: Why in this code bonus doesn't work
Reply With Quote #6

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
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
danonix
Senior Member
Join Date: Dec 2012
Old 11-23-2014 , 16:06   Re: Why in this code bonus doesn't work
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
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
danonix 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 17:41.


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