示例#1
0
void sampFakeKill()
{
	if(GetTickCount() - dwLastFakeKill >= settings.uiFakeKillInterval)
	{
		int randkillerid = 0xFFFF + 1;
		int randreason = rand() % 46;

		while(!(randkillerid >= 0 && randkillerid < MAX_PLAYERS && randkillerid != g_myPlayerID && playerInfo[randkillerid].iIsConnected))
		{
			if(getPlayerCount() < 2)
			{
				randkillerid = 0xFFFF;
				break;
			}

			randkillerid = rand() % MAX_PLAYERS;
		}

		if(randkillerid != 0xFFFF + 1)
			SendWastedNotification(randreason, randkillerid);

		dwLastFakeKill = GetTickCount();
	}
}
示例#2
0
void SendOnFootFullSyncData(ONFOOT_SYNC_DATA *pofSync, int sendDeathNoti, PLAYERID followPlayerID)
{
	if(pofSync == NULL)
		return;

	RakNet::BitStream bsPlayerSync;

	if(dwLastOnFootDataSentTick && dwLastOnFootDataSentTick < (GetTickCount() - iNetModeNormalOnfootSendRate))
	{
		if(followPlayerID != (PLAYERID)-1)
		{
			if(!playerInfo[followPlayerID].iIsConnected)
				return;
			if(iFollowingPassenger || iFollowingDriver)
				return;

			pofSync->lrAnalog = playerInfo[followPlayerID].onfootData.lrAnalog;
			pofSync->udAnalog = playerInfo[followPlayerID].onfootData.udAnalog;
			pofSync->wKeys = playerInfo[followPlayerID].onfootData.wKeys;

			float inFrontX, inFrontY;
			inFrontX = playerInfo[followPlayerID].onfootData.vecPos[0];
			inFrontY = playerInfo[followPlayerID].onfootData.vecPos[1];
			getXYInFrontOfPlayer(followPlayerID, &inFrontX, &inFrontY, settings.fFollowDistance);

			pofSync->vecPos[0] = inFrontX;
			pofSync->vecPos[1] = inFrontY;
			pofSync->vecPos[2] = playerInfo[followPlayerID].onfootData.vecPos[2] + settings.fFollowZOffset;

			pofSync->fQuaternion[0] = playerInfo[followPlayerID].onfootData.fQuaternion[0];
			pofSync->fQuaternion[1] = playerInfo[followPlayerID].onfootData.fQuaternion[1];
			pofSync->fQuaternion[2] = playerInfo[followPlayerID].onfootData.fQuaternion[2];
			pofSync->fQuaternion[3] = playerInfo[followPlayerID].onfootData.fQuaternion[3];

			pofSync->byteHealth = playerInfo[followPlayerID].onfootData.byteHealth;
			pofSync->byteArmour = playerInfo[followPlayerID].onfootData.byteArmour;
			pofSync->byteCurrentWeapon = playerInfo[followPlayerID].onfootData.byteCurrentWeapon;
			pofSync->byteSpecialAction = playerInfo[followPlayerID].onfootData.byteSpecialAction;

			pofSync->vecMoveSpeed[0] = playerInfo[followPlayerID].onfootData.vecMoveSpeed[0];
			pofSync->vecMoveSpeed[1] = playerInfo[followPlayerID].onfootData.vecMoveSpeed[1];
			pofSync->vecMoveSpeed[2] = playerInfo[followPlayerID].onfootData.vecMoveSpeed[2];

			pofSync->iCurrentAnimationID = playerInfo[followPlayerID].onfootData.iCurrentAnimationID;

			bsPlayerSync.Write((BYTE)ID_PLAYER_SYNC);
			bsPlayerSync.Write((PCHAR)pofSync, sizeof(ONFOOT_SYNC_DATA));
			pRakClient->Send(&bsPlayerSync, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);

			if(sendDeathNoti && pofSync->byteHealth == 0)
				SendWastedNotification(0, -1);

			dwLastOnFootDataSentTick = GetTickCount();
		}
		else
		{
			bsPlayerSync.Write((BYTE)ID_PLAYER_SYNC);
			bsPlayerSync.Write((PCHAR)pofSync, sizeof(ONFOOT_SYNC_DATA));
			pRakClient->Send(&bsPlayerSync, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);

			if(sendDeathNoti && pofSync->byteHealth == 0)
				SendWastedNotification(0, -1);

			dwLastOnFootDataSentTick = GetTickCount();
		}
	}
}