//Author -Ali Ahmed
// =========================================== S E R V E R   E V E N T S ==============================================
const RED 			= "[#FF0000]";
const SKY 			= "[#77FFCB]";
const SKYD 			= "[#00FF7C]";
const PINK 			= "[#FF1493]";
const LPINK 		= "[#FF00C0]";
const LPURPLE		= "[#C400FF]";
const LGREEEN		= "[#00FFBC]";
const LCUSTOM 		= "[#00FCFF]";
const ORANGE 		= "[#FF8C00]";
const YELLOW 		= "[#FFD700]";
const PURPLE 		= "[#9400D3]";
const LGREEN 		= "[#32CD32]";
const GREEN			= "[#008000]";
const DGREEN		= "[#006400]";
const BLUE			= "[#0000FF]";
const DBLUE 		= "[#00008B]";
const LBLUE 		= "[#1A6EFF]";
const BROWN 		= "[#8B4513]";
const WHITE			= "[#FFFFFF]";
const BLACK 		= "[#000000]";
const GREY			= "[#BDBDBD]";
const MSG 			= "[#AFFF00]";
const FORUM               	= "vcw-vcmp.boards.net";
const SCRIPTER			= "[VF]4L14HM3D";
const SCRIPT			= "VCW v1.5";
const AdminPassword = "03423008556";

const PROTECTION_TIME = 5;

class PlayerInfo
{
	admin = false;
}

function onServerStart()
{
}

function onServerStop()
{
}

function onScriptLoad()
{
db <- ConnectSQL( "scripts/locations.sqlite" );
dofile( "scripts/commands.nut" );
dofile( "scripts/markers.nut" );
dofile( "scripts/pick.nut" );
dofile( "scripts/msg.nut" );
dofile( "scripts/egypt.nut" );
dofile( "scripts/functions.nut" );
dofile( "scripts/hunt.nut" );
   dofile( "IPtoCountry.nut" );
    secondarydb <- ConnectSQL( "IpToCountry.db" );
pinfo <- array(GetMaxPlayers(), null);
LoadMarks()
print( "Loaded Server by Ali Ahmed" );
}

function onScriptUnload()
{
 DisconnectSQL( secondarydb );
}
//------------------------------------------------------------------------------------------------------------------------
function PlayerIsAdmin(player)
{
	if(pinfo[player.ID].admin == true) return 1;
	else return 0;
}
// =========================================== P L A Y E R   E V E N T S ==============================================

function onPlayerJoin( player )
{
pinfo[player.ID] = PlayerInfo();
local country = IpToCountry( player.IP );
Message( YELLOW + " Player " + player.Name + " has Joined the Server from " +RED + country );
}

function onPlayerPart( player, reason )
{
}

function onPlayerRequestClass( player, classID, team, skin )
{
	return 1;
}

function onPlayerRequestSpawn( player )
{

 	 return 1;
}

function onPlayerSpawn( player )
{
}

function onPlayerDeath( player, reason )
{
}

function onPlayerKill( player, killer, reason, bodypart )
{
Message( RED + "Player " + PINK + killer.Name + " has been killed by " + PURPLE + player.Name );
}

function onPlayerTeamKill( player, killer, reason, bodypart )
{
}

function onPlayerChat( player, text )
{
	print( player.Name + ": " + text );
	return 1;
}

function onPlayerPM( player, playerTo, message )
{
	return 1;
}

function onPlayerBeginTyping( player )
{
}

function onPlayerEndTyping( player )
{
}

/*
function onLoginAttempt( player )
{
	return 1;
}
*/

function onNameChangeable( player )
{
}

function onPlayerSpectate( player, target )
{
}

function onPlayerCrashDump( player, crash )
{
}

function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
{
}

function onPlayerHealthChange( player, lastHP, newHP )
{
}

function onPlayerArmourChange( player, lastArmour, newArmour )
{
}

function onPlayerWeaponChange( player, oldWep, newWep )
{
}

function onPlayerAwayChange( player, status )
{
}

function onPlayerNameChange( player, oldName, newName )
{
}

function onPlayerActionChange( player, oldAction, newAction )
{
}

function onPlayerStateChange( player, oldState, newState )
{
}

function onPlayerOnFireChange( player, IsOnFireNow )
{
}

function onPlayerCrouchChange( player, IsCrouchingNow )
{
}

function onPlayerGameKeysChange( player, oldKeys, newKeys )
{
}

// ========================================== V E H I C L E   E V E N T S =============================================

function onPlayerEnteringVehicle( player, vehicle, door )
{
	return 1;
}

function onPlayerEnterVehicle( player, vehicle, door )
{
}

function onPlayerExitVehicle( player, vehicle )
{
}

function onVehicleExplode( vehicle )
{
}

function onVehicleRespawn( vehicle )
{
}

function onVehicleHealthChange( vehicle, oldHP, newHP )
{
}

function onVehicleMove( vehicle, lastX, lastY, lastZ, newX, newY, newZ )
{
}

// =========================================== P I C K U P   E V E N T S ==============================================

function onPickupClaimPicked( player, pickup )
{
	return 1;
}

function onPickupPickedUp( player, pickup )
{
    if ( pickup.Model == 365 )
      {
	  MessagePlayer( RED + "Welcome to this server",player );
	  player.PlaySound(63);
	  pickup.RespawnTime = 3000;
	  }
	  if ( pickup.Model == 376 )
      {
	  MessagePlayer( "You have been disarmed",player );
	  player.Disarm();
	  player.PlaySound(48);
	  pickup.RespawnTime = 2000;
	  }
	  	  if ( pickup.Model == 287)
		  {
		  if (PlayerIsAdmin(player))
		  player.SetWeapon( 30,99999);
		  else MessagePlayer( "This is not a Public Weapon",player );
		  pickup.RespawnTime = 1000;
		  }
		  
}

function onPickupRespawn( pickup )
{
}

// ========================================== O B J E C T   E V E N T S ==============================================

function onObjectShot( object, player, weapon )
{
}

function onObjectBump( object, player )
{
}

// =========================================== B I N D   E V E N T S ==============================================

function onKeyDown( player, key )
{
}

function onKeyUp( player, key )
{
}

// ================================== E N D   OF   O F F I C I A L   E V E N T S =====================================