/*
* Empires API
* 
* Created By Theowningone
* Version: 1.1
* http://www.theowningone.info/
* http://www.borgamers.com/
*/


/******************
* --> Defines <-- *
******************/

#if defined _empires_is_stocks_included
#endinput
#endif
#define _empires_is_stocks_included


/*******************
* --> Includes <-- *
*******************/

#include <sourcemod>
#include <sdktools>


/********************
* --> Is Stocks <-- *
********************/

/**
* Is Player Squad Leader
*
* @param client			Client Index
* @return				true if leader, false if other
*/
stock bool:IsSquadLeader(client)
{
	decl String:classname[64];
	new ent;
	for(new i=0;i<=GetMaxEntities();i++){
        if(IsValidEntity(i)){
            GetEntityNetClass(i,classname,sizeof(classname));
            if(StrEqual(classname,"CPlayerResource")){
                ent=i;
                break;
            }
        }
    }
	new out=GetEntData(ent,FindSendPropOffs("CPlayerResource","m_bSquadLeader")+(client*4),4);
	return bool:out;
}


/**
* Is Player Commander
*
* @param client			Client Index
* @return				true if comm, false if other
*/
stock bool:IsCommander(client)
{
	decl String:classname[64];
	new ent;
	for(new i=0; i<=GetMaxEntities();i++){
        if(IsValidEntity(i)){
            GetEntityNetClass(i,classname,sizeof(classname));
            if(StrEqual(classname,"CPlayerResource")){
                ent=i;
                break;
            }
        }
    }
	new out=GetEntData(ent,FindSendPropOffs("CPlayerResource","m_bCommander")+(client*4),4);
	return bool:out;
}


/**
* Is Player In Vehicle
*
* @param client			Client Index
* @return				true if in vehicle, false if not
*/
stock bool:IsInVehicle(client)
{
	new team=GetClientTeam(client);
	decl String:classname[64];
	new ent;
	new out=0;
	if(team==2){
		for(new i=0;i<=GetMaxEntities();i++){
			if(IsValidEntity(i)){
				GetEntityNetClass(i,classname,sizeof(classname));
				if(StrEqual(classname,"CPlayerResource_NF")){
					ent=i;
					break;
				}
			}
		}
		out = GetEntData(ent,FindSendPropOffs("CPlayerResource_NF","m_iVehicle_NF")+(client*4),4);
	}else if(team==3){
		for(new i=0;i<=GetMaxEntities();i++){
			if(IsValidEntity(i)){
				GetEntityNetClass(i,classname,sizeof(classname));
				if(StrEqual(classname,"CPlayerResource_IMP")){
					ent=i;
					break;
				}
			}
		}
		out=GetEntData(ent,FindSendPropOffs("CPlayerResource_IMP","m_iVehicle_IMP")+(client*4),4);
	}
	if(IsCommander(client))out=1;
	return bool:out;
} 


/**
* Is Sabotaged
*
* @param ent			Entity Index
* @return				true if sabotaged, false if other
*/
stock bool:IsSabotaged(ent)
{
	if(!IsValidEntity(ent)) return false;
	new out=GetEntData(ent,FindSendPropOffs("CEmpBuilding","m_bSabotaged"),4);
	return bool:out;
}