PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
new const VERSION[] = "0.1.1"
const MAX_OFFSET_TO_PRINT = 15
const MAX_MSG_LENGTH = 128 * MAX_OFFSET_TO_PRINT
enum _:Types {
Type_Int,
Type_Float,
Type_String,
Type_Cbase,
Type_Char,
Type_Bit
}
new g_iOffSet = 1
new g_Type = Type_Int
public plugin_init()
{
register_plugin("Players Offset Test", VERSION, "ConnorMcLeod" )
register_clcmd("rest", "reset")
register_clcmd("augm", "augm")
register_clcmd("dimi", "dimi")
register_clcmd("goto", "_goto")
register_clcmd("say /int", "intType")
register_clcmd("say /float", "floatType")
register_clcmd("say /str", "stringType")
register_clcmd("say /cbase", "cbaseType")
register_clcmd("say /char", "charType")
register_clcmd("say /bit", "bitType")
}
public intType( id )
{
g_Type = Type_Int
}
public floatType( id )
{
g_Type = Type_Float
}
public stringType( id )
{
g_Type = Type_String
}
public cbaseType( id )
{
g_Type = Type_Cbase
}
public charType( id )
{
g_Type = Type_Char
}
public bitType( id )
{
g_Type = Type_Bit
}
public client_PreThink(id)
{
if( pev_valid(id) != 2 || is_user_bot(id) )
{
return
}
static Float:flOffset//[MAX_OFFSET_TO_PRINT]
static i, iOffset//[MAX_OFFSET_TO_PRINT]
static szOffSet[128]
static szMsg[MAX_MSG_LENGTH]
static n ; n = 0
for(i=0; i<MAX_OFFSET_TO_PRINT; i++)
{
switch( g_Type )
{
case Type_Int:
{
iOffset = get_pdata_int(id, g_iOffSet+i)
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: %d", g_iOffSet + i, iOffset)
}
case Type_Float:
{
flOffset = get_pdata_float(id, g_iOffSet+i)
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: %.3f", g_iOffSet + i, flOffset)
}
case Type_String:
{
szOffSet[0] = 0
get_pdata_string(id, g_iOffSet+i, szOffSet, charsmax(szOffSet), 1, 5)
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: %s", g_iOffSet + i, szOffSet)
}
case Type_Cbase:
{
iOffset = get_pdata_cbase_safe(id, g_iOffSet+i, 5)
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: %d", g_iOffSet + i, iOffset)
}
case Type_Char:
{
iOffset = get_pdata_int(id, g_iOffSet+i)
if( 33 <= iOffset <= 126 )
{
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: %c", g_iOffSet + i, iOffset)
}
else
{
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%d: NULL", g_iOffSet + i)
}
}
case Type_Bit:
{
// new szFlags[128] = "00000000000000000000000000000000"
iOffset = get_pdata_int(id, g_iOffSet+i)
if( iOffset )
{
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%i %i (", g_iOffSet + i, iOffset)
for(new j = 31; j >= 0; j--)
{
if(iOffset & (1<<(j)))
{
n += formatex(szMsg[n], charsmax(szMsg)-n, "%i ", j)
// szFlags[j] = '1'
}
}
szMsg[n-1] = ')'
// server_print("pev_weapons = %u (%s)", iOffset, szFlags)
// n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%i (%s)", g_iOffSet + i, szFlags)
}
else
{
n += formatex(szMsg[n], charsmax(szMsg)-n, "^n%i %i", g_iOffSet + i, iOffset)
}
}
}
}
client_print_center(id, "%s^n%f", szMsg, get_gametime())
}
client_print_center(id, msg[], any:...)
{
static szMsg[MAX_MSG_LENGTH]
vformat(szMsg, charsmax(szMsg), msg, 3)
engfunc(EngFunc_ClientPrintf, id, 1, szMsg)
}
public _goto(id)
{
new arg[32]
read_argv(1, arg, 31)
g_iOffSet = str_to_num(arg)
return PLUGIN_HANDLED
}
public reset(id)
{
g_iOffSet = 0
return PLUGIN_HANDLED
}
public augm(id)
{
g_iOffSet += MAX_OFFSET_TO_PRINT
return PLUGIN_HANDLED
}
public dimi(id)
{
if( g_iOffSet > 0 )
--g_iOffSet
return PLUGIN_HANDLED
}