Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Is it possible to send player tag updates to select players
Is it possible to send player tag updates to select players [message #474093] Sat, 08 September 2012 06:43 Go to next message
BillieJoe67 is currently offline  BillieJoe67
Messages: 35
Registered: March 2012
Karma: 0
Recruit
What I'm trying to do is create an improved spectate mode, and I had this idea where players who are scoped have the tag Scoping or whatever. Obviously, the tag should only be sent to players that are in spectate mode, but would it be possible to do a select update? Send_Object_Update doesn't work.

This is the basic code I have so far, but it sends the tag to all players

DynamicVectorClass<int> SpectatingPlayers;

void ExamplePlugin::OnThink()
{
	for(SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
	{
		cPlayer* cP = PlayerIter->Data();
		if(cP && cP->IsActive)
		{
			GameObject* PlayerObj = Get_GameObj(cP->PlayerId);
			if(PlayerObj)
			{
				if(PlayerObj->As_SoldierGameObj()->Is_Sniping() == true)
				{
					cP->customTag.Format(L"Sniping");
					cP->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_CREATION, true); //remove this line
					for(int i = 0; i < SpectatingPlayers.Length(); i++)
					{
						//Do the update here
					}
				}
				else
				{
					cP->customTag.Format(L"");
					cP->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_CREATION, true); //remove this line
					for(int i = 0; i < SpectatingPlayers.Length(); i++)
					{
						//Do the update here
					}
				}
			}
		}
	}
}

[Updated on: Sat, 08 September 2012 06:50]

Report message to a moderator

Re: Is it possible to send player tag updates to select players [message #474104 is a reply to message #474093] Sat, 08 September 2012 08:58 Go to previous messageGo to next message
Ethenal is currently offline  Ethenal
Messages: 2532
Registered: January 2007
Location: US of A
Karma: 0
General (2 Stars)

That's actually quite a neat idea. I'm curious as to see if you can pull that off. I do not know the answer to your question, however - I would presume it's unlikely that you can do this, but obviously a TT developer would be able to answer this better. Smile

-TLS-DJ-EYE-K wrote on Mon, 18 March 2013 07:29

Instead of showing us that u aren't more inteligent than a Toast, maybe you should start becomming good in renegade Thumbs Up

Re: Is it possible to send player tag updates to select players [message #474105 is a reply to message #474093] Sat, 08 September 2012 09:02 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Simplify it first so it runs for only one guy in spectate.

Try:

cP->customTag.Format(L"Sniping");
Send_Object_Update(obj, PlayerID);
cP->customTag.Format(L"");


Or:

cP->customTag.Format(L"Sniping");
cP->Set_Object_Dirty_Bits(PlayerID, NetworkObjectClass::BIT_CREATION);
Send_Object_Update(obj, PlayerID);
cP->customTag.Format(L"");


Otherwise you can attach an object or float an object above sniping players for one second and only have these shown for spectating players. I recommend you add a simple check at the start of OnThink() to make the code only run every second or so. Use GetTickCount64().


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Sat, 08 September 2012 09:12]

Report message to a moderator

Re: Is it possible to send player tag updates to select players [message #474109 is a reply to message #474093] Sat, 08 September 2012 13:49 Go to previous messageGo to next message
BillieJoe67 is currently offline  BillieJoe67
Messages: 35
Registered: March 2012
Karma: 0
Recruit
Thanks Ethenal

Iran, the second code works, thanks so much

For anyone interested, this is the current, working code.

DynamicVectorClass<int> SpectatingPlayers;
bool IsSniping[128];
int LastCheck = 0;

int Seconds_Difference(int time1, int time2)
{
	time_t Time1(time1);
	time_t Time2(time2);

	return (int)difftime(Time1, Time2);
}

ExamplePlugin::ExamplePlugin()
{
	RegisterEvent(EVENT_THINK_HOOK,this);

	for(int i = 0; i < 127; i++)
	{
		IsSniping[i] = false;
	}
}

ExamplePlugin::~ExamplePlugin()
{
	UnregisterEvent(EVENT_THINK_HOOK,this);
}

void ExamplePlugin::OnThink()
{
	int Seconds = Seconds_Difference((int)time(NULL), LastCheck);
	if(Seconds >= 1)
	{
		LastCheck = (int)time(NULL);
		for(SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
		{
			cPlayer* cP = PlayerIter->Data();
			if(cP && cP->IsActive)
			{
				GameObject* PlayerObj = Get_GameObj(cP->PlayerId);
				if(PlayerObj)
				{
					if(PlayerObj->As_SoldierGameObj()->Is_Sniping() == true)
					{
						if(!IsSniping[cP->PlayerId])
						{
							IsSniping[cP->PlayerId] = true;
							cP->customTag.Format(L"Scoped");
							for (int i = 0;i < SpectatingPlayers.Count();i++)
							{
								int id = SpectatingPlayers[i];
								cP->Set_Object_Dirty_Bit(id, NetworkObjectClass::BIT_CREATION, true);
								Send_Object_Update(cP, id);							
							}
							cP->customTag.Format(L"");
						}
					}
					else
					{
						if(IsSniping[cP->PlayerId])
						{
							IsSniping[cP->PlayerId] = false;
							cP->customTag.Format(L"");
							cP->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_CREATION, true);
						}
					}
				}
			}
		}
	}
}

[Updated on: Sat, 08 September 2012 13:55]

Report message to a moderator

Re: Is it possible to send player tag updates to select players [message #474111 is a reply to message #474093] Sat, 08 September 2012 14:19 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
You should modify this for-loop from:

for (int i = 0;i < SpectatingPlayers.Count();i++)


To:

for (int i = 0, e = SpectatingPlayers.Count();i < e;i++)


The latter is more efficient, the ::Count() function gets called for every iteration of the loop. This is the reason why this is done in the clang compiler source code.

Also you should use GetTickCount64(), it's a more efficient (the engine uses GetTickCount() in a few places, but that one rolls around every 45 days or so, GetTickCount64() rolls around every 5 million years).


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Is it possible to send player tag updates to select players [message #474118 is a reply to message #474093] Sat, 08 September 2012 17:16 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Be aware that GetTickCount64 is NOT supported on Windows XP.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Is it possible to send player tag updates to select players [message #474216 is a reply to message #474093] Tue, 11 September 2012 05:06 Go to previous messageGo to next message
Sir Kane
Messages: 1701
Registered: March 2003
Location: Angerville
Karma: 0
General (1 Star)
Be aware that only a retard would still use Windows XP.

Proud N9500 and proud N6270 user. Creator of the IEE libraries (original bhs.dll) and the RB series software.
http://n00bstories.com/image.fetch.php?id=1189992501http://www.n00bstories.com/image.fetch.php?id=1257492907
Re: Is it possible to send player tag updates to select players [message #475006 is a reply to message #474093] Sat, 22 September 2012 17:25 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Its free though.... Check your local trash for serial numbers... I have like 50... AND IT STILL IS STABLE...so worth it.

But yes, if you don't have a copy of Win7 on your main machine, your mentally retarded.


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: Is it possible to send player tag updates to select players [message #475042 is a reply to message #474093] Sun, 23 September 2012 01:28 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
the same could be said about windows 95

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Previous Topic: SP Character Voices to Online
Next Topic: Feel like making something
Goto Forum:
  


Current Time: Fri Nov 08 16:50:57 MST 2024

Total time taken to generate the page: 0.00729 seconds