/*
	Fixing some SA:MP functions
	Author:	NeoPhoenix
	Date:	22.08.2012
*/
#if defined samp_fixed
	#endinput
#endif
#define samp_fixed

#undef MAX_PLAYERS
#define MAX_PLAYERS 								(200)
#pragma dynamic 									(2<<13)//16384 (8192<<1)
//#define KEY_AIM									(128)
#define MIN_PLAYER_NAME								(3)
#define floatrandom(%0) 							floatmul(floatdiv(float(random(cellmax)),float(cellmax - 1)),%0)
#define fixed_PlayerTextDrawHide(%0,%1) 			if(%1 != PlayerText:INVALID_TEXT_DRAW) PlayerTextDrawHide(%0,%1)
#define fixed_TextDrawHideForPlayer(%0,%1) 			if(%1 != Text:INVALID_TEXT_DRAW) TextDrawHideForPlayer(%0,%1)
#define fixed_PlayerTextDrawShow(%0,%1) 			if(%1 != PlayerText:INVALID_TEXT_DRAW) PlayerTextDrawShow(%0,%1)
#define fixed_TextDrawShowForPlayer(%0,%1) 			if(%1 != Text:INVALID_TEXT_DRAW) TextDrawShowForPlayer(%0,%1)
#define fixed_TextDrawDestroy(%0); 					if(%0 != Text:INVALID_TEXT_DRAW) { TextDrawDestroy(%0); %0 = Text:INVALID_TEXT_DRAW; }
#define fixed_PlayerTextDrawDestroy(%0,%1);			if(%1 != PlayerText:INVALID_TEXT_DRAW) { PlayerTextDrawHide(%0,%1); PlayerTextDrawDestroy(%0,%1); %1 = PlayerText:INVALID_TEXT_DRAW; }
#define fixed_SetPlayerWorldBounds(%0,%1,%2,%3,%4)	SetPlayerWorldBounds(%0,%2,%1,%4,%3)
new MAX_PLAYER_ID = MAX_PLAYERS;

stock fixed_SetPlayerMapIcon(playerid,Float:ix,Float:iy,Float:iz,icon_id,style=MAPICON_LOCAL,color=0)
{
	new istr[11];
	for(new i; i<100; i++)
	{
		format(istr,sizeof(istr),"picon_%d",i);
		if(GetPVarInt(playerid,istr) == 1) continue;
		if(SetPlayerMapIcon(playerid,i,ix,iy,iz,icon_id,color,style))
		{
			SetPVarInt(playerid,istr,1);
			return i;
		}
		else return -1;
	}
	return -1;
}

stock fixed_SendClientMessage(playerid,color,const message[])
{
	SetPVarInt(playerid,"fixed_scm_last",gettime(_,_,_));
	return SendClientMessage(playerid,color,message);
}
native BAD_SendClientMessage(playerid, color, const message[]) = SendClientMessage;
#define SendClientMessage fixed_SendClientMessage

stock fixed_SendClientMessageToAll(color,const message[])
{
	new time = gettime(_,_,_);
	for(new playerid; playerid<MAX_PLAYERS; playerid++)
	{
		if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) continue;
		SetPVarInt(playerid,"fixed_scm_last",time);
		SendClientMessage(playerid,color,message);
	}
	return ;
}
native BAD_SendClientMessageToAll(color, const message[]) = SendClientMessageToAll;
#define SendClientMessageToAll fixed_SendClientMessageToAll







