/*
*	Created:			15.03.09
*	Author:				009
*	Last Modifed:		29.12.09
*	Description:		Стриммер пикапов, изменение любого параметра 
*
*	29.12.09:
*	1.Добавлен дебаг
*
*	27.12.09:
*	1.Добавлена проверка на ошибки и вывод их в консоль
*	2.Natives list
*
*	24.12.09:
*	1.Вернут стриммер ибо 2048 пикапов оказалось недостаточно(благодаря системе помещений)
*	2.Привязка к modeinterior и virtual world
*
*	15.11.09:
*	1.Привязка пикапа не к modeinterior а к помещению
*
*	25.09.09:
*	1.Стриммер убран,использованы возможности SA-MP 0.3(2048 пикапов и поддержка виртуальных миров)
*
*	22.09.09:
*	1.Добавлен параметр Type
*	2.Добавлен параметр AddedParam
*	3.Добавлена функция IsPlayerOnPickupType(playerid,type)
*	4.Добавлена функция GetPlayerPickupParam(playerid)
*
*	20.09.09:
*	1.Стриммер основан на OnPlayerUpdate а не на Check
*	2.Инклуд полностью автономный и не связан переменными с другими инклудами
*
*	17.09.09:
*	1.MAX_PLAYERS в циклах заменён на GetMaxPlayer()
*	2.Уменьшен лимит пикапов до 500
*/

#if defined _mode_pickups_included
	#endinput
#endif

#define _mode_pickups_included
#pragma library mode_pickups

// --------------------------------------------------
// includes
// --------------------------------------------------
#include "mode_debug"
#include "mode_interiors"
#include "mode_core"

// --------------------------------------------------
// defines
// --------------------------------------------------
#define PICKUPS_TAKE_DISTANCE 2.0
#define MAX_MODE_PICKUPS 3000
#define PICKUPS_DISTANCE 500.0
#if !defined INVALID_PICKUP_ID
	#define INVALID_PICKUP_ID -1
#endif
#define INVALID_MODE_PICKUP_ID -1

// --------------------------------------------------
// enums
// --------------------------------------------------
enum ModePickupsPickupInfo {
	pModel,
	pType
};
enum ModePickupsCoordInfo {
	Float:cPos[3],
	cModeInteriorId,
	cVirtualWorldId
};
enum ModePickupsTypeExInfo {
	tTypeId,
	tTypeParam
};
enum ModePickupsInfo {
	bool:pActive,
	pGameId,
	pSeeCount,
	pPickup[ModePickupsPickupInfo],
	pCoordinates[ModePickupsCoordInfo],
	pTypeEx[ModePickupsTypeExInfo]
};
enum ModePickupsPlayerInfo {
	pOnPickupId,
	bool:pShowedPickups[MAX_MODE_PICKUPS]
};

// --------------------------------------------------
// news
// --------------------------------------------------
new ModePickups[MAX_MODE_PICKUPS][ModePickupsInfo],
	ModePickups_Player[MAX_PLAYERS][ModePickupsPlayerInfo],
	ServerPickupsOffset[MAX_PICKUPS],
	ModePickupsOffset,
	ModePickupsCount;

// --------------------------------------------------
// natives list (for pawno functions list)
// --------------------------------------------------
/*
native CreateModePickup(Model,Type,Float:X,Float:Y,Float:Z,ModeInterior,VirtualWorld,TypeEx,TypeExParam);
native DestroyModePickup(pickupid);
native GetModePickupPos(pickupid,&Float:X,&Float:Y,&Float:Z);
native SetModePickupPos(pickupid,Float:X,Float:Y,Float:Z);
native GetModePickupModeInterior(pickupid);
native SetModePickupModeInterior(pickupid,modeinterior);
native GetModePickupVirtualWorld(pickupid);
native SetModePickupVirtualWorld(pickupid,virtualworld);
native GetModePickupModel(pickupid);
native GetModePickupType(pickupid);
native SetModePickupType(pickupid,type);
native GetModePickupTypeEx(pickupid);
native SetModePickupTypeEx(pickupid,type);
native GetModePickupTypeExParam(pickupid);
native SetModePickupTypeExParam(pickupid,typeparam);
native GetPlayerPickupOn(playerid);
native IsModePickupNeedToShow(playerid,pickupid);
*/

// --------------------------------------------------
// forwards
// --------------------------------------------------
forward OnPlayerModePickupPickUp(playerid,pickupid);

// --------------------------------------------------
// publics
// --------------------------------------------------
/* Paul_Norck: это пока не нужно, т. к. конфликтует со стримером от Incognito
public OnPlayerPickUpPickup(playerid,pickupid)
{
	Debug(DEBUG_START,"OnPlayerPickUpPickup(%d,%d)",playerid,pickupid);
	if(ModePickups_Player[playerid][pOnPickupId] == ServerPickupsOffset[pickupid])
	{
		Debug(DEBUG_END,"OnPlayerPickUpPickup(reason: player on last pickup)");
		return 0;
	}
	
	ModePickups_Player[playerid][pOnPickupId] = ServerPickupsOffset[pickupid];
	OnPlayerModePickupPickUp(playerid,ServerPickupsOffset[pickupid]);
	Debug(DEBUG_END,"OnPlayerPickUpPickup(reason: complete)");
	return 1;
}
*/
// --------------------------------------------------
// stocks
// --------------------------------------------------
stock CreateModePickup(Model,Type,Float:X,Float:Y,Float:Z,ModeInterior,VirtualWorld,TypeEx,TypeExParam)
{
	Debug(DEBUG_START,"CreateModePickup(%d,%d,%f,%f,%f,%d,%d,%d,%d)",Model,Type,X,Y,Z,ModeInterior,VirtualWorld,TypeEx,TypeExParam);
	for(new pickupid = ModePickupsOffset;pickupid < MAX_MODE_PICKUPS;pickupid++)
	{
	    if(ModePickups[pickupid][pActive] == true) continue;
		Debug(DEBUG_ACTION,"Finded free slot,id = %d , set main data",pickupid);
		ModePickups[pickupid][pActive] = true;
		ModePickups[pickupid][pSeeCount] = 0;
		ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
		Debug(DEBUG_ACTION,"Pickup info set");
		ModePickups[pickupid][pPickup][pModel] = Model;
		ModePickups[pickupid][pPickup][pType] = Type;
		Debug(DEBUG_ACTION,"Coordinates info set");
		ModePickups[pickupid][pCoordinates][cPos][0] = X;
		ModePickups[pickupid][pCoordinates][cPos][1] = Y;
		ModePickups[pickupid][pCoordinates][cPos][2] = Z;		
		ModePickups[pickupid][pCoordinates][cModeInteriorId] = ModeInterior;
		ModePickups[pickupid][pCoordinates][cVirtualWorldId] = VirtualWorld;
		Debug(DEBUG_ACTION,"Type Ex info set");
		ModePickups[pickupid][pTypeEx][tTypeId] = TypeEx;
		ModePickups[pickupid][pTypeEx][tTypeParam] = TypeExParam;
		Debug(DEBUG_ACTION,"Players info set");
		for(new playerid = 0;playerid < MAX_PLAYERS;playerid++) ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
		Debug(DEBUG_ACTION,"Set offset data(old: %d,%d)",ModePickupsOffset,ModePickupsCount);
		ModePickupsOffset = pickupid;
		if(ModePickupsCount < pickupid) ModePickupsCount = pickupid;
		Debug(DEBUG_END,"CreateModePickup(reason: complete)");
		return pickupid;
	}
	Debug(DEBUG_END,"CreateModePickup(reason: all slots used)");
	print("[WARNING] Mode pickups -> CreateModePickup (all slots used)");
	return 0;
}

stock DestroyModePickup(pickupid)
{
	Debug(DEBUG_START,"DestroyModePickup(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"DestroyModePickup(reason: error)");
		printf("[ERROR] Mode pickups -> DestroyModePickup (try destroy not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	ModePickups[pickupid][pActive] = false;
	ModePickups[pickupid][pSeeCount] = 0;
	ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
	Debug(DEBUG_ACTION,"Pickup info reset");
	ModePickups[pickupid][pPickup][pModel] = 0;
	ModePickups[pickupid][pPickup][pType] = 0;
	Debug(DEBUG_ACTION,"Coordinates info reset");
	for(new i = 0;i < 3;i++) ModePickups[pickupid][pCoordinates][cPos][i] = 0.0;
	ModePickups[pickupid][pCoordinates][cModeInteriorId] = 0;
	ModePickups[pickupid][pCoordinates][cVirtualWorldId] = 0;
	Debug(DEBUG_ACTION,"TypeEx info reset");
	ModePickups[pickupid][pTypeEx][tTypeId] = 0;
	ModePickups[pickupid][pTypeEx][tTypeParam] = 0;
	Debug(DEBUG_ACTION,"Players info reset and destroy pickup");
	for(new playerid = 0;playerid < MAX_PLAYERS;playerid++) 
	{
		ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
		if(ModePickups_Player[playerid][pOnPickupId] == pickupid) ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
	}
	Debug(DEBUG_ACTION,"Counter reset");
	if(ModePickupsOffset > pickupid) ModePickupsOffset = pickupid;
	if(ModePickupsCount == pickupid) 
	{
		do ModePickupsCount--;
		while((ModePickups[ ModePickupsCount ][pActive] == false) && (ModePickupsCount > 0));
	}
	Debug(DEBUG_END,"DestroyModePickup(reason: complete)");
	return 1;
}

stock GetModePickupPos(pickupid,&Float:X,&Float:Y,&Float:Z)
{
	Debug(DEBUG_START,"GetModePickupPos(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupPos(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupPos (try get pos not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	X = ModePickups[pickupid][pCoordinates][cPos][0];
	Y = ModePickups[pickupid][pCoordinates][cPos][1];
	Z = ModePickups[pickupid][pCoordinates][cPos][2];
	Debug(DEBUG_END,"GetModePickupPos(reason: complete)");
	return 1;
}

stock SetModePickupPos(pickupid,Float:X,Float:Y,Float:Z)
{
	Debug(DEBUG_START,"SetModePickupPos(%d,%f,%f,%f)",pickupid,X,Y,Z);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupPos(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupPos (try set pos not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_ACTION,"set new coords info");
	ModePickups[pickupid][pCoordinates][cPos][0] = X;
	ModePickups[pickupid][pCoordinates][cPos][1] = Y;
	ModePickups[pickupid][pCoordinates][cPos][2] = Z;
	Debug(DEBUG_ACTION,"destroy pickup");
	if(ModePickups[pickupid][pSeeCount] != 0)
	{
		DestroyPickup(ModePickups[pickupid][pGameId]);
		ModePickups[pickupid][pSeeCount] = 0;
		ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
		for(new playerid = 0;playerid <= GetMaxPlayer();playerid++) 
		{
			ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
			if(ModePickups_Player[playerid][pOnPickupId] == pickupid) ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
		}
	}
	Debug(DEBUG_END,"SetModePickupPos(reason: complete)");
	return 1;
}

stock GetModePickupModeInterior(pickupid)
{
	Debug(DEBUG_START,"GetModePickupModeInterior(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupModeInterior(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupModeInterior (try get mode interior not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupModeInterior(reason: complete)");
	return ModePickups[pickupid][pCoordinates][cModeInteriorId];
}

stock SetModePickupModeInterior(pickupid,modeinterior)
{
	Debug(DEBUG_START,"SetModePickupModeInterior(%d,%d)",pickupid,modeinterior);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupModeInterior(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupModeInterior (try set mode interior not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_ACTION,"set new data and destroy pickup");
	ModePickups[pickupid][pCoordinates][cModeInteriorId] = modeinterior;
	if(ModePickups[pickupid][pSeeCount] != 0)
	{
		DestroyPickup(ModePickups[pickupid][pGameId]);
		ModePickups[pickupid][pSeeCount] = 0;
		ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
		for(new playerid = 0;playerid <= GetMaxPlayer();playerid++) 
		{
			ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
			if(ModePickups_Player[playerid][pOnPickupId] == pickupid) ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
		}
	}
	Debug(DEBUG_END,"SetModePickupModeInterior(reason: complete)");
	return 1;
}

stock GetModePickupVirtualWorld(pickupid)
{
	Debug(DEBUG_START,"GetModePickupVirtualWorld(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupVirtualWorld(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupVirtualWorld (try get virtual world not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupVirtualWorld(reason: complete)");
	return ModePickups[pickupid][pCoordinates][cVirtualWorldId];
}

stock SetModePickupVirtualWorld(pickupid,virtualworld)
{
	Debug(DEBUG_START,"SetModePickupVirtualWorld(%d,%d)",pickupid,virtualworld);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupVirtualWorld(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupVirtualWorld (try set virtual world not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_ACTION,"set new data and destroy pickup");
	ModePickups[pickupid][pCoordinates][cVirtualWorldId] = virtualworld;
	if(ModePickups[pickupid][pSeeCount] != 0)
	{
		DestroyPickup(ModePickups[pickupid][pGameId]);
		ModePickups[pickupid][pSeeCount] = 0;
		ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
		for(new playerid = 0;playerid <= GetMaxPlayer();playerid++) 
		{
			ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
			if(ModePickups_Player[playerid][pOnPickupId] == pickupid) ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
		}
	}
	Debug(DEBUG_END,"SetModePickupVirtualWorld(reason: complete)");
	return 1;
}

stock GetModePickupModel(pickupid)
{
	Debug(DEBUG_START,"GetModePickupModel(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupModel(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupModel (try get model not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupModel(reason: complete)");
	return ModePickups[pickupid][pPickup][pModel];
}

stock GetModePickupType(pickupid)
{
	Debug(DEBUG_START,"GetModePickupType(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupType(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupType (try get type not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupType(reason: complete)");
	return ModePickups[pickupid][pPickup][pType];
}

stock SetModePickupType(pickupid,type)
{
	Debug(DEBUG_START,"SetModePickupType(%d,%d)",pickupid,type);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupType(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupType (try set type not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_ACTION,"set new data and destroy pickup");
	ModePickups[pickupid][pPickup][pType] = type;
	if(ModePickups[pickupid][pSeeCount] != 0)
	{
		DestroyPickup(ModePickups[pickupid][pGameId]);
		ModePickups[pickupid][pSeeCount] = 0;
		ModePickups[pickupid][pGameId] = INVALID_PICKUP_ID;
		for(new playerid = 0;playerid <= GetMaxPlayer();playerid++) 
		{
			ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
			if(ModePickups_Player[playerid][pOnPickupId] == pickupid) ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
		}
	}
	Debug(DEBUG_END,"SetModePickupType(reason: complete)");
	return 1;
}

stock GetModePickupTypeEx(pickupid)
{
	Debug(DEBUG_START,"GetModePickupTypeEx(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupTypeEx(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupTypeEx (try get typeex not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupTypeEx(reason: complete)");
	return ModePickups[pickupid][pTypeEx][tTypeId];
}

stock SetModePickupTypeEx(pickupid,type)
{
	Debug(DEBUG_START,"SetModePickupTypeEx(%d,%d)",pickupid,type);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupTypeEx(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupTypeEx (try set typeex not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	ModePickups[pickupid][pTypeEx][tTypeId] = type;
	Debug(DEBUG_END,"SetModePickupTypeEx(reason: complete)");
	return 1;
}

stock GetModePickupTypeExParam(pickupid)
{
	Debug(DEBUG_START,"GetModePickupTypeExParam(%d)",pickupid);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"GetModePickupTypeExParam(reason: error)");
		printf("[ERROR] Mode pickups -> GetModePickupTypeExParam (try get typeex parameter not created pickup's, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"GetModePickupTypeExParam(reason: complete)");
	return ModePickups[pickupid][pTypeEx][tTypeParam];
}

stock SetModePickupTypeExParam(pickupid,typeparam)
{
	Debug(DEBUG_START,"SetModePickupTypeExParam(%d,%d)",pickupid,typeparam);
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"SetModePickupTypeExParam(reason: error)");
		printf("[ERROR] Mode pickups -> SetModePickupTypeExParam (try set typeex parameter not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	ModePickups[pickupid][pTypeEx][tTypeParam] = typeparam;
	Debug(DEBUG_END,"SetModePickupTypeExParam(reason: complete)");
	return 1;
}

stock GetPlayerPickupOn(playerid)
{
	Debug(DEBUG_START,"GetPlayerPickupOn(%d)",playerid);
	if(!IsPlayerConnected(playerid))
	{
		Debug(DEBUG_END,"GetPlayerPickupOn(reason: error)");
		printf("[ERROR] Mode pickups -> GetPlayerPickupOn (try get pickup offline player's, playerid = %d)",playerid);
		return 0;
	}
	Debug(DEBUG_END,"GetPlayerPickupOn(reason: complete)");
	return ModePickups_Player[playerid][pOnPickupId];
}

stock IsModePickupNeedToShow(playerid,pickupid)
{
	Debug(DEBUG_START,"IsModePickupNeedToShow(%d,%d)",playerid,pickupid);
	if(!IsPlayerConnected(playerid))
	{
		Debug(DEBUG_END,"IsModePickupNeedToShow(reason: error)");
		printf("[ERROR] Mode pickups -> IsModePickupNeedToShow (try check pickup for offline player, playerid = %d)",playerid);
		return 0;
	}
	if(ModePickups[pickupid][pActive] == false)
	{
		Debug(DEBUG_END,"IsModePickupNeedToShow(reason: error)");
		printf("[ERROR] Mode pickups -> IsModePickupNeedToShow (try check not created pickup, pickupid = %d)",pickupid);
		return 0;
	}
	Debug(DEBUG_END,"IsModePickupNeedToShow(reason: complete)");
	if(!IsPlayerInRangeOfPoint(playerid,PICKUPS_DISTANCE,ModePickups[pickupid][pCoordinates][cPos][0],ModePickups[pickupid][pCoordinates][cPos][1],ModePickups[pickupid][pCoordinates][cPos][2])) return 0;
	if((GetPlayerModeInterior(playerid) != ModePickups[pickupid][pCoordinates][cModeInteriorId]) && (ModePickups[pickupid][pCoordinates][cModeInteriorId] != -1)) return 0;
	if((GetPlayerVirtualWorld(playerid) != ModePickups[pickupid][pCoordinates][cVirtualWorldId]) && (ModePickups[pickupid][pCoordinates][cVirtualWorldId] != -1)) return 0;
	return 1;
}

// --------------------------------------------------
// Obligatory functions
// --------------------------------------------------
ModePickups_OnGameModeInit()
{
	Debug(DEBUG_START,"ModePickups_OnGameModeInit");
	print("Mode pickups system loaded.");
	Debug(DEBUG_END,"ModePickups_OnGameModeInit");
}

ModePickups_ResetStat(playerid)
{
	Debug(DEBUG_START,"ModePickups_ResetStat(%d)",playerid);
	for(new pickupid = 0;pickupid < MAX_MODE_PICKUPS;pickupid++) ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
	ModePickups_Player[playerid][pOnPickupId] = INVALID_PICKUP_ID;
	Debug(DEBUG_END,"ModePickups_ResetStat");
}

ModePickups_OnPlayerUpdate(playerid)
{
	Debug(DEBUG_START,"ModePickups_OnPlayerUpdate(%d)",playerid);
	if(ModePickups_Player[playerid][pOnPickupId] != INVALID_PICKUP_ID)
	{
		if(!IsPlayerInRangeOfPoint(playerid,PICKUPS_TAKE_DISTANCE,ModePickups[ ModePickups_Player[playerid][pOnPickupId] ][pCoordinates][cPos][0],ModePickups[ ModePickups_Player[playerid][pOnPickupId] ][pCoordinates][cPos][1],ModePickups[ ModePickups_Player[playerid][pOnPickupId] ][pCoordinates][cPos][2])) ModePickups_Player[playerid] = INVALID_MODE_PICKUP_ID;
	}
	for(new pickupid = 0;pickupid < ModePickupsCount;pickupid++)
	{
		if(ModePickups[pickupid][pActive] == false) continue;
		if(ModePickups_Player[playerid][pShowedPickups][pickupid] == false)
		{
			if(!IsModePickupNeedToShow(playerid,pickupid)) continue;
			ModePickups_Player[playerid][pShowedPickups][pickupid] = true;
			ModePickups[pickupid][pSeeCount]++;
			if(ModePickups[pickupid][pSeeCount] == 1)
			{
				ModePickups[pickupid][pGameId] = CreatePickup(ModePickups[pickupid][pPickup][pModel],ModePickups[pickupid][pPickup][pType],ModePickups[pickupid][pCoordinates][cPos][0],ModePickups[pickupid][pCoordinates][cPos][1],ModePickups[pickupid][pCoordinates][cPos][2],GetPlayerVirtualWorld(playerid));
				ServerPickupsOffset[ ModePickups[pickupid][pGameId] ] = pickupid;
			}
		}
		else
		{
			if(IsModePickupNeedToShow(playerid,pickupid)) continue;
			ModePickups_Player[playerid][pShowedPickups][pickupid] = false;
			ModePickups[pickupid][pSeeCount]--;
			if(ModePickups[pickupid][pSeeCount] == 0)
			{
				DestroyPickup(ModePickups[pickupid][pGameId]);
				ServerPickupsOffset[ ModePickups[pickupid][pGameId] ] = INVALID_PICKUP_ID;
			}
		}
	}
	Debug(DEBUG_END,"ModePickups_OnPlayerUpdate");
}