View Single Post
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-21-2011 , 22:51   Re: Setting a client's maxspeed permanently and efficiently
#5

Here goes a stupid example. When you scream in pain it also shows gibs. Also it shows how you can write more concise and efficient code when more functions are exposed:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_stocks>
#include <hamsandwich>
#include <xs>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Unknown"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_PainSound,"player","painSound",0)
}

public 
painSound(id)
{
    new 
Float:eyes[3]
    
    
ExecuteHam(Ham_EyePosition,id,eyes)
    
    
// Equivalent to:
    
new Float:origin[3], Float:view_ofs[3]
    
pev(id,pev_origin,origin)
    
pev(id,pev_view_ofs,view_ofs)
    
xs_vec_add(origin,view_ofs,origin)
    
//
    
    
ExecuteHam(Ham_GibMonster,id)
    
    
client_print(0,print_chat,"These vectors should be equal [%f][%f][%f] - [%f][%f][%f]",origin[0],origin[1],origin[2],eyes[0],eyes[1],eyes[2])

joaquimandrade is offline