Raised This Month: $12 Target: $400
 3% 

Player out of range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
davidto1995
Member
Join Date: Jul 2010
Location: hong kong
Old 03-02-2021 , 08:39   Player out of range
Reply With Quote #1

Code:
new const SHOWHUD_ID = 200;

public client_connect(id)
{
	get_user_name(id, gPlayerName[id], charsmax(gPlayerName[]));
	set_task(0.5, "ShowHUD", id+SHOWHUD_ID, _, _, "b");
}

public ShowHUD(taskid) //call after client connect
{

	new id = taskid - SHOWHUD_ID;

	if(cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
	{

		if(!is_user_alive(id))
			id = pev(id, pev_iuser2);


		if(cs_get_user_team(id) == CS_TEAM_CT)
		{
			if(equal(gPlayerType[id], "Leader"))
				set_hudmessage(255, 255, 255, 0.7, 0.7, 0, 0.1, 1.0, 0.1, 0.1, 1);
			if(equal(gPlayerType[id], "Supporter"))
				set_hudmessage(0, 204, 255, 0.7, 0.7, 0, 0.1, 1.0, 0.1, 0.1, 1);
			else
				set_hudmessage(0, 255, 0, 0.7, 0.7, 0, 0.1, 1.0, 0.1, 0.1, 1);
		}
		if(cs_get_user_team(id) == CS_TEAM_T)
		{
			if(equal(gPlayerType[id], "G-Virus Monster"))
				set_hudmessage(153, 0, 204, 0.7, 0.7, 0, 0.1, 1.0, 0.1, 0.1, 1);
			else
				set_hudmessage(255, 0, 0, 0.7, 0.7, 0, 0.1, 1.0, 0.1, 0.1, 1);
		}

		ShowSyncHudMsg(id, gMsgSyncObj, "帳號: %s | 生命: %i | 血清量: %i | 等級: %i^n經驗值: %i/%i | 金幣: %i | 種族: %s | ID: %i", gPlayerName[id], get_user_health(id), get_user_armor(id), gPlayerLevel[id], gPlayerExp[id], gPlayerNextLevel[id], gPlayerPoints[id], gPlayerType[id], id);
	}
}
Keep having errors as below:
L 03/02/2021 - 218:22: [AMXX] [0] zm.sma::ShowHUD (line 1127)
L 03/02/2021 - 218:23: [CSTRIKE] Invalid player 12
L 03/02/2021 - 218:23: [AMXX] Displaying debug trace (plugin "zm.amxx")
L 03/02/2021 - 218:23: [AMXX] Run time error 10: native error (native "cs_get_user_team")

I have this error once I connect to the server. Which part has gone wrong? Thank you!

Last edited by davidto1995; 03-02-2021 at 08:42.
davidto1995 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2021 , 08:50   Re: Player out of range
Reply With Quote #2

Check if the user is connected before getting his team.
You shouldn't be using "client_connect" because the user isn't connected yet. Use "client_putinserver".
__________________

Last edited by OciXCrom; 03-02-2021 at 08:51.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
davidto1995
Member
Join Date: Jul 2010
Location: hong kong
Old 03-02-2021 , 09:18   Re: Player out of range
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Check if the user is connected before getting his team.
You shouldn't be using "client_connect" because the user isn't connected yet. Use "client_putinserver".
Thank you so much. The problem is solved.
davidto1995 is offline
Reply


Thread Tools
Display Modes

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 09:23.


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