2019-04-22 18:02:50 +02:00
//====================================================================================================
//
// Name: [entWatch] Tools
// Author: zaCade & Prometheum
// Description: Handle the tools of [entWatch]
//
//====================================================================================================
# include <multicolors>
# pragma newdecls required
# include <sourcemod>
# include <sdkhooks>
# include <sdktools>
# include <entWatch_core>
# include <entWatch_helpers>
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = " [entWatch] Tools " ,
author = " zaCade & Prometheum " ,
description = " Handle the tools of [entWatch] " ,
version = " 4.0.0 "
} ;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart ( )
{
LoadTranslations ( " common.phrases " ) ;
LoadTranslations ( " entWatch.tools.phrases " ) ;
RegAdminCmd ( " sm_etransfer " , Command_TransferItem , ADMFLAG_BAN ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_TransferItem ( int client , int args )
{
if ( GetCmdArgs ( ) < 2 )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sUsage: sm_etransfer <#userid/name> <#userid/name> " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
char sTarget1 [ 32 ] ;
char sTarget2 [ 32 ] ;
GetCmdArg ( 1 , sTarget1 , sizeof ( sTarget1 ) ) ;
GetCmdArg ( 2 , sTarget2 , sizeof ( sTarget2 ) ) ;
int target1 ;
if ( ( target1 = FindTarget ( client , sTarget1 , true ) ) = = - 1 )
return Plugin_Handled ;
int target2 ;
if ( ( target2 = FindTarget ( client , sTarget2 , true ) ) = = - 1 )
return Plugin_Handled ;
if ( GetClientTeam ( target1 ) ! = GetClientTeam ( target2 ) )
{
2019-04-22 21:22:19 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sError: client teams dont match! " , " E01B5D " , " F16767 " ) ;
2019-04-22 18:02:50 +02:00
return Plugin_Handled ;
}
bool bTransfered ;
for ( int index ; index < EW_GetItemCount ( ) ; index + + )
{
CItem item = EW_GetItemData ( index ) ;
if ( item . bClient & & item . iClient = = target1 )
{
if ( item . bWeapon & & ! ( item . dConfig . iSlot = = SLOT_NONE | | item . dConfig . iSlot = = SLOT_KNIFE ) )
{
2019-04-25 17:44:51 +02:00
Client_DropWeapon ( item . iClient , item . iWeapon ) ;
2019-04-22 18:02:50 +02:00
char sWeaponClass [ 32 ] ;
GetEntityClassname ( item . iWeapon , sWeaponClass , sizeof ( sWeaponClass ) ) ;
GivePlayerItem ( item . iClient , sWeaponClass ) ;
int iDisplay = item . dConfig . iDisplay ;
item . dConfig . iDisplay & = ~ ( 1 < < 0 ) ;
EquipPlayerWeapon ( target2 , item . iWeapon ) ;
item . dConfig . iDisplay & = iDisplay ;
bTransfered = true ;
}
}
}
2019-04-22 18:06:13 +02:00
if ( ! bTransfered )
2019-04-22 18:02:50 +02:00
{
2019-04-22 21:22:19 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sError: no transferable items found! " , " E01B5D " , " F16767 " ) ;
2019-04-22 18:06:13 +02:00
return Plugin_Handled ;
2019-04-22 18:02:50 +02:00
}
2019-04-22 18:06:13 +02:00
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s transfered all items from \x07 %s%N \x07 %s to \x07 %s%N \x07 %s. " , " E01B5D " , " EDEDED " , client , " F16767 " , " EDEDED " , target1 , " F16767 " , " EDEDED " , target2 , " F16767 " ) ;
LogAction ( client , target1 , " %L transfered all items from %L to %L. " , client , target1 , target2 ) ;
2019-04-22 18:02:50 +02:00
return Plugin_Handled ;
}