BANNED
|
10-19-2016
, 12:53
[CS:GO] PTaH - V1.0.8
|
#1
|
PTaH - P Tools and Hooks
include
Example/Test Plugin
Weapon Info
PHP Code:
#pragma semicolon 1
#include <PTaH>
public void OnPluginStart()
{
PTaH(PTaH_ExecuteStringCommand, Hook, ExecuteStringCommand);
PTaH(PTaH_OnClientConnect, Hook, OnClientConnectPre);
PTaH(PTaH_GiveNamedItemPre, Hook, GiveNamedItemPre);
PTaH(PTaH_MapContentList, Hook, MapContentList);
PTaH(PTaH_WeaponCanUse, Hook, WeaponCanUse);
PTaH(PTaH_ConsolePrint, Hook, ConsolePrint);
PTaH(PTaH_SetPlayerModel, Hook, SetPlayerModel);
PTaH(PTaH_ServerConsolePrint, Hook, ServerConsolePrint);
RegConsoleCmd("ptah", ptah_);
RegConsoleCmd("ptah2", ptah_2);
}
public Action ptah_(int iClient, int args)
{
char buf[64];
AddrInfo addr;
int res = PTaH_GetAddrInfo("forums.alliedmods.net", AF_UNSPEC, addr);
if(res == 0)
{
PrintToChatAll("GetAddrInfo - forums.alliedmods.net");
AddrInfo p;
for(p = addr; p; p = p.NextIP)
{
p.GetIP(buf, sizeof(buf));
PrintToChatAll("%s %s", p.Family == 2 ? "IP":"IP6", buf);
}
addr.ClearMem();
}
else
{
PTaH_Gai_StrError(res, buf, sizeof(buf));
PrintToChatAll("GetAddrInfo - %d %s", res, buf);
}
PTaH_MD5File("addons/metamod.vdf", buf, sizeof(buf));
PrintToChatAll("HASH - addons/metamod.vdf - %s", buf);
return Plugin_Handled;
}
public Action ptah_2(int iClient, int args)
{
char sBuf[32];
GetCmdArgString(sBuf, sizeof(sBuf));
float origin[3];
GetClientAbsOrigin(iClient, origin);
int iEnt = PTaH_SpawnItemFromDefIndex(StringToInt(sBuf), origin);
PrintToChat(iClient, "%d", iEnt);
}
public Action ExecuteStringCommand(int iClient, char sMessage[512])
{
//Blocking command status
static char sMessage2[512];
sMessage2 = sMessage;
//Remove space and tabs (commands its passed in the original form without a slew of front space and tab and etc) " status "
TrimString(sMessage2);
//*Client could write "status 3453 4534 5456 2354"
if(StrContains(sMessage2, "status") == 0)
{
PrintToChatAll("%N Introduced command status", iClient);
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action OnClientConnectPre(const char[] sName, char sPassword[128], const char[] sIp, const char[] sSteamID, char rejectReason[512])
{
LogMessage("OnClientConnectPre %s %s %s", sName, sIp, sSteamID);
return Plugin_Continue;
}
//We are doing the same thing as https://forums.alliedmods.net/showthread.php?t=236199 (do not forget say thank you to Dr!fter)
public Action GiveNamedItemPre(int iClient, char sClassname[64], CEconItemView &Item)
{
if(!Item || !Item.IsCustomItemView())
{
CEconItemDefinition ItemDefinition = PTaH_GetItemDefinitionByName(sClassname);
if(ItemDefinition)
{
int iTeam = GetClientTeam(iClient);
int iLoadoutSlot = ItemDefinition.GetLoadoutSlot();
CEconItemView Item2 = PTaH_GetItemInLoadout(iClient, iTeam, iLoadoutSlot);
if(!Item2.IsCustomItemView())
{
Item2 = PTaH_GetItemInLoadout(iClient, iTeam == 2 ? 3:2, iLoadoutSlot);
// Fix the problem when its gave tec9 instead five-seven
if(Item2.IsCustomItemView() && ItemDefinition.GetDefinitionIndex() == Item2.GetItemDefinition().GetDefinitionIndex())
{
Item = Item2;
return Plugin_Changed;
}
}
}
}
return Plugin_Continue;
}
//Blocking loading .nav files
public Action MapContentList(char sFile[128])
{
if(StrContains(sFile, ".nav") != -1) return Plugin_Handled;
return Plugin_Continue;
}
//Allowing Counter-terrorist pick up C4
public bool WeaponCanUse(int iClient, int iEnt, bool CanUse)
{
static char sClassname[64];
GetEdictClassname(iEnt, sClassname, sizeof(sClassname));
if(StrEqual(sClassname, "weapon_c4")) return true;
return CanUse;
}
//Withdraw in the chat client that writes to the console
public Action ConsolePrint(int iClient, char sMessage[1024])
{
PrintToChat(iClient, sMessage);
return Plugin_Continue;
}
public void SetPlayerModel(int iClient, const char[] sModel)
{
PrintToChatAll("%N Set Model %s", iClient, sModel);
}
//Block out messages that contain DataTable warning
public Action ServerConsolePrint(const char[] sMessage, LoggingSeverity severity)
{
if (StrContains(sMessage, "DataTable warning") != -1) return Plugin_Handled;
return Plugin_Continue;
}
Thanks to: Dr!fter, Peace-Maker, GoD-Tony, rom4s
Links
Source
Builds
Gamedata
Changelog
1.0.1 - Added hook ServerConsolePrint
- Fixed PTaH_GetEconItemViewFromWeapon for Windows (Thank you GoD-Tony)
- PTaH_GetHostByName substituted for PTaH_GetAddrInfo
1.0.2 - Fix after update CSGO. Thank you Peace-Maker, GoD-Tony, rom4s
1.0.3
1.0.4 - Adding LoggingSeverity to ServerConsolePrint
1.0.5
1.0.6 - Fix GetDefinitionIndex on windows
- PTaH_GetEconItemViewFromWeapon now works without gamedata
- Add PTaH_SpawnItemFromDefIndex - allows you to create objects by their DefinitionIndex with a valid CEconItemView
Update 1.0.7 - Add native
- PTaH_GetItemDefinitionByDefIndex
- CEconItemDefinition.GetClassName
- CEconItemDefinition.GetCCSWeaponData
- PTaH_GiveNamedItemPre function changed
function Action (int iClient, char sClassname[64], CEconItemView &Item, bool &IgnoredCEconItemView)
- Removed native GetStatTrakKill
- Updated gamedata
Update 1.0.8 - Add
- PTaH_Version - allows you to check the current version of PTaH
- Restored
- GetStatTrakKill - thank you Kailo
- Removed
- PTaH_SpawnItemFromDefIndex - this function is no longer needed, since the weapon created with the CreateEntityByName function is working fine
- GetCCSWeaponData - are not used anywhere
- Fix
- GetDefinitionIndex - a bug that always returned 0
- IsCustomItemView - bug
- ServerConsolePrint - when messages from another thread crash server (this is a temporary solution, since those messages are skipped)
Last edited by komashchenko; 11-10-2017 at 12:51.
Reason: Update V1.0.8
|
|