/*
 *
 * Cannon
 * Natives
 *
*/

#if defined _cannon_natives_included
 #endinput
#endif

#define _cannon_natives_included

#if !defined MAX_MAPNAME_LENGTH
 #define MAX_MAPNAME_LENGTH 64
#endif

#define MULTI_DESC(%0) fmt("%L", LANG_SERVER, %0)

#define pev_cannon pev_iuser2

//The max value of uniq IDs (also long for the array, i.e. 1 gun is equal to 1 uniq id; depends on the number of guns)
#define UNIQUE_ID_COUNT 500

//A number for substitution in the formation of a unique ID for each created gun.
#define UNIQUE_ID_ENT 200

enum _:FLOAT_COORD_DATA
{
	Float:X,
	Float:Y,
	Float:Z
};

enum _:INTEGER_COORD_DATA
{
	CD_X,
	CD_Y,
	CD_Z
};

/*
 * Getting global count Entity
 *
 * @returns (count) value
 *
 * @Data acquisition count Entity
*/
native get_global_count();

/*
 * Obtaining information about the integer settings of the gun
 *
 * @returns (speed, up, replay, time, render) int value
 *
 * @Data acquisition settings
*/
native get_saved_integer_data(uid, const data[], len);

/*
 * Getting information about floating gun settings
 *
 * @returns (Origin, Angles) string with coordinates
 *
 * @Getting data for parsing coordinates
*/
native get_saved_float_data(uid, const data[], len);

/*
 * Getting string access data
 *
 * @returns (default access Or access flags) value
 *
 * @Data acquisition access
*/
native get_saved_access_data(uid, check, const data[], len);

stock SendAudio(id, const audio[], pitch)
{
	static MsgSendAudio;

	if(!MsgSendAudio)
	{
		MsgSendAudio = get_user_msgid("SendAudio");
	}

	message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, MsgSendAudio, _, id);

	write_byte(id);
	write_string(audio);
	write_short(pitch);

	message_end();
}

stock ProcessingColorStrings(const Str[], Color[3])
{
	new R[4], G[4], B[4];
	parse(Str, R, charsmax(R), G, charsmax(G), B, charsmax(B));

	Color[0] = str_to_num(R);
	Color[1] = str_to_num(G);
	Color[2] = str_to_num(B);
}

stock ScreenShake(id, Amplitude, Duration, Frequency, Reliable = 0)
{
	message_begin(Reliable ? MSG_ONE : MSG_ONE_UNRELIABLE, 97, { 0.0, 0.0, 0.0 }, id);

	write_short(Amplitude);
	write_short(Duration);
	write_short(Frequency);

	message_end();
}