Raised This Month: $ Target: $400
 0% 

[TF2] broblem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
superchat
Junior Member
Join Date: Sep 2012
Old 11-06-2012 , 12:44   [TF2] broblem
Reply With Quote #1

Why this code work all palyers?

Code:
public Action:Timer_Cloak(Handle:hTimer, any:client)
{
	if(cEnable && cInfCloak && IsClientInGame(client) && IsValidEntity(client) && IsClientConnected(client))
	{
		new cond = GetEntProp(client, Prop_Send, "m_nPlayerCond");
		if(cond & 16)
			SetEntPropFloat(client, Prop_Send, "m_flCloakMeter", 100.0);
	}
	tCloak[client] = CreateTimer(0.1, Timer_Cloak, client);
}

public Action:Timer_Cloak_Regen(Handle:hTimer, any:client)
{
	if(cEnable && cRegenCloak && IsClientInGame(client) && IsValidEntity(client) && IsClientConnected(client))
	{
		new cond = GetEntProp(client, Prop_Send, "m_nPlayerCond");
		new health = GetClientHealth(client);
		if(cond & 16 && health < 125)
			SetEntityHealth(client, health + cRegenCloakAmount);
	}
	tCloak2[client] = CreateTimer(cRegenCloakRate, Timer_Cloak_Regen, client);
}
superchat is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-06-2012 , 14:46   Re: [TF2] broblem
Reply With Quote #2

Not quite sure what you're trying to do with that. But out of IsClientInGame(client) && IsValidEntity(client) && IsClientConnected(client)...you only need one of those, IsClientInGame(client). IsClientConnected is always true if the client is in-game, and IsValidEntity returns true if the client is connected (I think).

Also, instead of creating the same timer from within a timer, you should be using the flag TIMER_REPEAT.

Finally, you should probably be using user IDs to check if players disconnect while their timer is ticking...not sure about repeating timers that are assigned to each client, though.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
superchat
Junior Member
Join Date: Sep 2012
Old 11-07-2012 , 00:11   Re: [TF2] broblem
Reply With Quote #3

More code:

Code:
public OnClientPostAdminCheck(client)
{
	if(cEnable && GetUserFlagBits(client) & PREMIUMFLAG)
	{
		LogMessage("VIP %N connected", client);
	}
}

CreateVIPTimers(client)
{
	tCloak[client] = CreateTimer(0.1, Timer_Cloak, client);
	tCloak2[client] = CreateTimer(0.1, Timer_Cloak_Regen, client);
}
superchat 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 09:05.


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