sm-plugins/_entWatch4/scripting/entWatch-tools.sp

103 lines
3.2 KiB
SourcePawn
Raw Normal View History

//====================================================================================================
//
// 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))
{
CReplyToCommand(client, "\x07[entWatch] \x07%sError: client teams dont match!", "E01B5D", "F16767");
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))
{
SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR);
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;
}
}
}
if (bTransfered)
{
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);
}
return Plugin_Handled;
}