Raised This Month: $ Target: $400
 0% 

Problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maniok112
Junior Member
Join Date: Mar 2015
Old 04-07-2015 , 09:39   Problems
Reply With Quote #1

Hello I have a problem with the plugin because I want to count the players frags and wrote out towards the end of the map to the hut. Everything works besides the one with the end of the maps do not print quantity chat frags frags only writes "0".

HTML Code:
public EndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
	new players[32], num;

	new tempfrags, id;

	new swapfrags, swapid;

	new starfrags[3];
	new starid[3];
	
	new timeleft;
	GetMapTimeLeft(timeleft);
	if (timeleft <= 0)
	{
		for(new i = 0; i < num; i++)
		{
			id = players[i];
			tempfrags = GetClientFrags(id);
			if (tempfrags > starfrags[0])
			{
				starfrags[0] = tempfrags;
				starid[0] = id;
				cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+900);
				if (tempfrags > starfrags[1])
				{
					swapfrags = starfrags[1];
					swapid = starid[1];
					starfrags[1] = tempfrags;
					starid[1] = id;
					starfrags[0] = swapfrags;
					starid[0] = swapid;
					cod_set_user_xp(starid[1], cod_get_user_xp(starid[1])+600);
					
					if ( tempfrags > starfrags[2] )
					{
						swapfrags = starfrags[2];
						swapid = starid[2];
						starfrags[2] = tempfrags;
						starid[2] = id;
						starfrags[1] = swapfrags;
						starid[1] = swapid;
						cod_set_user_xp(starid[2], cod_get_user_xp(starid[2])+300);

					}
				}
			}
		}
	}
	
	PrintToChatAll("Najlepsi Gracze na Mapie:");
	PrintToChatAll("1. %i Fragow (+900 dosw.)", starfrags[2]);
	PrintToChatAll("2. %i Fragow (+600 dosw.)", starfrags[1]);
	PrintToChatAll("3. %i Fragow (+300 dosw.)", starfrags[0]);
	
	return 0;
}

Help Me
maniok112 is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 04-07-2015 , 11:42   Re: Problems
Reply With Quote #2

Well, num is 0 so

PHP Code:
for(new 0numi++) 
won't do anything
Miu is offline
maniok112
Junior Member
Join Date: Mar 2015
Old 04-08-2015 , 10:52   Re: Problems
Reply With Quote #3

HTML Code:
public EndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
	new players[32];

	new tempfrags, id;

	new swapfrags, swapid;

	new starfrags[3];
	new starid[3];
	
	new timeleft;
	GetMapTimeLeft(timeleft);
	if (timeleft <= 0)
	{
		for(new i = 1; i <= MaxClients; i++)
			if (IsClientInGame(i) && !IsFakeClient(i))
		{
			id = players[i];
			tempfrags = GetClientFrags(id);
			if (tempfrags > starfrags[0])
			{
				starfrags[0] = tempfrags;
				starid[0] = id;
				cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+900);
				if (tempfrags > starfrags[1])
				{
					swapfrags = starfrags[1];
					swapid = starid[1];
					starfrags[1] = tempfrags;
					starid[1] = id;
					starfrags[0] = swapfrags;
					starid[0] = swapid;
					cod_set_user_xp(starid[1], cod_get_user_xp(starid[1])+600);
					
					if ( tempfrags > starfrags[2] )
					{
						swapfrags = starfrags[2];
						swapid = starid[2];
						starfrags[2] = tempfrags;
						starid[2] = id;
						starfrags[1] = swapfrags;
						starid[1] = swapid;
						cod_set_user_xp(starid[2], cod_get_user_xp(starid[2])+300);

					}
				}
			}
		}
	
		PrintToChatAll("Najlepsi Gracze na Mapie:");
		PrintToChatAll("1. %i Fragow (+900 dosw.)", starfrags[2]);
		PrintToChatAll("2. %i Fragow (+600 dosw.)", starfrags[1]);
		PrintToChatAll("3. %i Fragow (+300 dosw.)", starfrags[0]);
	}
	
	return 0;
}
Currently it looks like this and still does not work, not even print an announcement if naa hut function timeleft = 0 did not work
maniok112 is offline
Dr. Api
BANNED
Join Date: Mar 2015
Location: France
Old 04-09-2015 , 05:03   Re: Problems
Reply With Quote #4

tempfrags = GetClientFrags(id);

id = players[i]; for what is that ? You really complicate your code

tempfrags[i] = GetClientFrags(i); If you don't assign each client frags for each player It will not works. same for all, starfrags, swapfrags....

new tempfrags[MAXPLAYERS+1],..... not declare them on your function "EndEvent" declare them as globals.

Last edited by Dr. Api; 04-09-2015 at 05:07.
Dr. Api is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 04-09-2015 , 05:52   Re: Problems
Reply With Quote #5

Quote:
Originally Posted by maniok112 View Post
Currently it looks like this and still does not work, not even print an announcement if naa hut function timeleft = 0 did not work
It looks like you're not using #pragma semicolon. The for loop is a one-liner/empty.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
maniok112
Junior Member
Join Date: Mar 2015
Old 04-09-2015 , 10:03   Re: Problems
Reply With Quote #6

HTML Code:
public EndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
	for(new i = 1, max = GetMaxClients(); i <= max; ++ i)
	{
		if (IsClientInGame(i) && !IsFakeClient(i))
		{
			new timeleft;
			GetMapTimeLeft(timeleft);
			if(timeleft <= 0)
			{
				new tempfrags;
				new swapfrags, swapid;
				new starfrags[3]; //0 - 3 miejsce / 1 - 2 miejsce / 2 - 1 miejsce
				new starid[3];

				tempfrags = GetClientFrags(i);
				if(tempfrags > starfrags[0])
				{
					starfrags[0] = tempfrags;
					starid[0] = i;
					PrintToChatAll("Siemanie");
					cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+300);

					if(tempfrags > starfrags[1])
					{
						swapfrags = starfrags[1];
						swapid = starid[1];
						starfrags[1] = tempfrags;
						starid[1] = i;
						starfrags[0] = swapfrags;
						starid[0] = swapid;
						PrintToChatAll("Eloszka");
						cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+600);
						
						if(tempfrags > starfrags[2])
						{
							swapfrags = starfrags[2];
							swapid = starid[2];
							starfrags[2] = tempfrags;
							starid[2] = i;
							PrintToChatAll("Kurczaki");
							starfrags[1] = swapfrags;
							starid[1] = swapid;
							cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+900);
						}
					}
				}

				PrintToChatAll("Nudam");
				new winner = starid[2];
				if(!winner)
				return;

				PrintToChat(i, "\x0B \x04Najlepsi Gracze na tej mapie:");
				PrintToChat(i, "\x0B \x041. %i Fragow (+900 Dosw.)", starfrags[2]);
				PrintToChat(i, "\x0B \x042. %i Fragow (+600 Dosw.)", starfrags[1]);
				PrintToChat(i, "\x0B \x043. %i Fragow (+300 Dosw.)", starfrags[0]);
				PrintToChatAll("Siemanie");
				PrintToChatAll("Co tam CS");
			}

		}
	}
}
I changed some code and it currently looks as counting function frags but still does not work and does not display messages in chat
prints only messages:
PrintToChatAll ("whats not");
PrintToChatAll ("Eloszka");
the rest does not work or do not print them

Last edited by maniok112; 04-09-2015 at 10:13.
maniok112 is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-09-2015 , 10:11   Re: Problems
Reply With Quote #7

Try some debug prints (before and after ifs) to see where your code is wrong.
KissLick is offline
maniok112
Junior Member
Join Date: Mar 2015
Old 04-09-2015 , 10:14   Re: Problems
Reply With Quote #8

prints only messages:
PrintToChatAll ("Siemanie");
PrintToChatAll ("Eloszka");
the rest does not work or do not print them

Last edited by maniok112; 04-09-2015 at 10:16.
maniok112 is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-09-2015 , 10:31   Re: Problems
Reply With Quote #9

PHP Code:
PrintToChatAll("Eloszka");
cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+600);

if(
tempfrags starfrags[2]) 
to
PHP Code:
PrintToChatAll("Eloszka");
cod_set_user_xp(starid[0], cod_get_user_xp(starid[0])+600);
PrintToChatAll("'%d' and '%d'"tempfragsstarfrags[2]);
if(
tempfrags starfrags[2]) 
and see what it prints
KissLick is offline
maniok112
Junior Member
Join Date: Mar 2015
Old 04-09-2015 , 10:52   Re: Problems
Reply With Quote #10

Unfortunately, he does not write anything in the chat associated with what you said so I added the :CC
maniok112 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 10:18.


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