/*  Custom Functions
 *
 *  Author: Venom
 *
 */

#if defined _custom_included
	#endinput
#endif
#define _custom_included
#pragma library custom

#include <a_samp>

#define COLOR_SPECIAL 0x9ACD32AA

forward Float:GetDistanceBetweenPlayers(p1,p2);
forward PrintFileMissing(type, string[]);

// ===[Functions]===
public Float:GetDistanceBetweenPlayers(p1,p2){
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));

}

public PrintFileMissing(type, string[])
{
	new str[256];
	switch(type) {
	case 0: { format(str,sizeof(str),"\n\nWARNING: The Folder \"%s\" Is Missing!\n\n",string); }
	case 1: { format(str,sizeof(str),"\n\nERROR: The Required Folder \"%s\" Is Missing!\n>> Create this folder and start server again!\n\n",string); SetTimer("Shutdown",10000,0); }
	}
	print(str);
	return 1;
}

stock SystemMsg(playerid, msg[])
{
	if(IsPlayerConnected(playerid)&&strlen(msg)>0)
	{
	    SendClientMessage(playerid,COLOR_SPECIAL,msg);
	}
	return 1;
}

stock SendClientMessageToOthers(playerid, color, const message[])
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(playerid != i)
        {
            SendClientMessage(playerid, color, const message[]);
        }
    }
    return 1;
}

stock GetServerName()
{
    new str[256];
    GetServerVarAsString("hostname",str,sizeof(str));
    return str;
}

stock SetServerName(name[])
{
    if(name[0] == 0) return 0;
    new tmp[256];
    format(tmp,sizeof(tmp),"hostname %s",name);
    SendRconCommand(tmp);
    return 1;
}
