Exemple #1
0
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerSpawn(int playerid)
{
	if(!pServer)
		return true;

	if (IsPlayerConnectedEx(playerid))
	{
		pPlayerData[playerid]->bControllable = true;
	}
	return true;
}
void OnVehWrecked(RPCParameters *rpcParams)
{
	if (pRakServer && pGameModeAmx)
	{
		int iPlayer;
		USHORT usVehicle;

		iPlayer = pRakServer->GetIndexFromPlayerID(rpcParams->sender);
		
		if (!IsPlayerConnectedEx(iPlayer)) return;

		RakNet::BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);

		bsData.Read(usVehicle);

		if (!IsValidVehicleEx(usVehicle)) return;

		CPlayerPool *pPlayerPool = pNetGame->pPlayerPool;
		CVehicle *pVehicle = pNetGame->pVehiclePool->pVehicle[usVehicle];

		if (!pVehicle) return;

		if (!pPlayerPool->pPlayer[iPlayer]->byteVehicleStreamedIn[pVehicle->wVehicleID]) return;

		int idx;
		cell ret = 0;

		if (!amx_FindPublic(pGameModeAmx, "OnVehicleRequestDeath", &idx))
		{
			amx_Push(pGameModeAmx, iPlayer);
			amx_Push(pGameModeAmx, usVehicle);
			amx_Exec(pGameModeAmx, &ret, idx);

			if ((cell)ret)
			{
				pVehicle->bDead = true;
				pVehicle->bDeathNotification = 0;
				pVehicle->wKillerID = iPlayer;
			}

			return;
		}
		else
		{
			pVehicle->bDead = true;
			pVehicle->bDeathNotification = 0;
			pVehicle->wKillerID = iPlayer;
		}

		return;

	}
}