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
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 previous message
BillieJoe67 is currently offline  BillieJoe67
Messages: 35
Registered: March 2012
Karma:
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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SP Character Voices to Online
Next Topic: Feel like making something
Goto Forum:
  


Current Time: Sun Dec 22 04:30:51 MST 2024

Total time taken to generate the page: 0.00838 seconds