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 " ) ;
2019-06-11 19:19:14 +02:00
RegAdminCmd ( " sm_etransfer " , Command_TransferItem , ADMFLAG_BAN ) ;
2019-04-22 18:02:50 +02:00
}
//----------------------------------------------------------------------------------------------------
// 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 ;
}
2019-05-03 18:19:53 +02:00
char sArguments [ 2 ] [ 32 ] ;
GetCmdArg ( 1 , sArguments [ 0 ] , sizeof ( sArguments [ ] ) ) ;
GetCmdArg ( 2 , sArguments [ 1 ] , sizeof ( sArguments [ ] ) ) ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
if ( strncmp ( sArguments [ 0 ] , " $ " , 1 , false ) = = 0 )
{
strcopy ( sArguments [ 0 ] , sizeof ( sArguments [ ] ) , sArguments [ 0 ] [ 1 ] ) ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
int reciever ;
if ( ( reciever = FindTarget ( client , sArguments [ 1 ] , true ) ) = = - 1 )
return Plugin_Handled ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
char sName [ 32 ] ;
char sShort [ 32 ] ;
char sColor [ 32 ] ;
bool bTransfered ;
for ( int index ; index < EW_GetItemCount ( ) ; index + + )
{
CItem item = EW_GetItemData ( index ) ;
item . dConfig . GetName ( sName , sizeof ( sName ) ) ;
item . dConfig . GetShort ( sShort , sizeof ( sShort ) ) ;
item . dConfig . GetColor ( sColor , sizeof ( sColor ) ) ;
if ( StrContains ( sName , sArguments [ 0 ] , false ) ! = - 1 | | StrContains ( sShort , sArguments [ 0 ] , false ) ! = - 1 )
{
if ( item . bWeapon & & ! ( item . dConfig . iSlot = = SLOT_NONE | | item . dConfig . iSlot = = SLOT_KNIFE ) )
{
int iDisplay = item . dConfig . iDisplay ;
if ( item . bClient )
{
SDKHooks_DropWeapon ( item . iClient , item . iWeapon , NULL_VECTOR , NULL_VECTOR ) ;
char sWeaponClass [ 32 ] ;
GetEntityClassname ( item . iWeapon , sWeaponClass , sizeof ( sWeaponClass ) ) ;
GivePlayerItem ( item . iClient , sWeaponClass ) ;
}
item . dConfig . iDisplay & = ~ ( 1 < < 0 ) ;
EquipPlayerWeapon ( reciever , item . iWeapon ) ;
2019-06-15 15:45:09 +02:00
item . dConfig . iDisplay = iDisplay ;
2019-05-03 18:19:53 +02:00
bTransfered = true ;
break ;
}
}
}
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
if ( ! bTransfered )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sError: no transferable items found! " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s transfered \x07 %s%s \x07 %s to \x07 %s%N \x07 %s. " , " E01B5D " , " EDEDED " , client , " F16767 " , sColor , sName , " F16767 " , " EDEDED " , reciever , " F16767 " ) ;
LogAction ( client , - 1 , " %L transfered %s to %L. " , client , sName , reciever ) ;
}
else
2019-04-22 18:02:50 +02:00
{
2019-05-03 18:19:53 +02:00
int target ;
if ( ( target = FindTarget ( client , sArguments [ 0 ] , true ) ) = = - 1 )
return Plugin_Handled ;
int reciever ;
if ( ( reciever = FindTarget ( client , sArguments [ 1 ] , true ) ) = = - 1 )
return Plugin_Handled ;
if ( GetClientTeam ( target ) ! = GetClientTeam ( reciever ) )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sError: teams dont match! " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
bool bTransfered ;
for ( int index ; index < EW_GetItemCount ( ) ; index + + )
2019-04-22 18:02:50 +02:00
{
2019-05-03 18:19:53 +02:00
CItem item = EW_GetItemData ( index ) ;
if ( item . bClient & & item . iClient = = target )
2019-04-22 18:02:50 +02:00
{
2019-05-03 18:19:53 +02:00
if ( item . bWeapon & & ! ( item . dConfig . iSlot = = SLOT_NONE | | item . dConfig . iSlot = = SLOT_KNIFE ) )
{
int iDisplay = item . dConfig . iDisplay ;
SDKHooks_DropWeapon ( item . iClient , item . iWeapon , NULL_VECTOR , NULL_VECTOR ) ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
char sWeaponClass [ 32 ] ;
GetEntityClassname ( item . iWeapon , sWeaponClass , sizeof ( sWeaponClass ) ) ;
GivePlayerItem ( item . iClient , sWeaponClass ) ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
item . dConfig . iDisplay & = ~ ( 1 < < 0 ) ;
2019-04-22 18:02:50 +02:00
2019-05-03 18:19:53 +02:00
EquipPlayerWeapon ( reciever , item . iWeapon ) ;
2019-04-22 18:02:50 +02:00
2019-06-15 15:45:09 +02:00
item . dConfig . iDisplay = iDisplay ;
2019-05-03 18:19:53 +02:00
bTransfered = true ;
}
2019-04-22 18:02:50 +02:00
}
}
2019-05-03 18:19:53 +02:00
if ( ! bTransfered )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sError: target has no transferable items! " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
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 " , target , " F16767 " , " EDEDED " , reciever , " F16767 " ) ;
LogAction ( client , target , " %L transfered all items from %L to %L. " , client , target , reciever ) ;
2019-04-22 18:02:50 +02:00
}
return Plugin_Handled ;
}