|
AMX Mod X Moderator
|

10-22-2009
, 15:10
Re: [help] SPRITE laser
|
#1
|
PHP Code:
#include <amxmodx> #include <engine> #include <hamsandwich>
new gWeapons[] = { -1, CSW_P228, -1, CSW_SCOUT, /*CSW_HEGRENADE*/ -1, CSW_XM1014, /*CSW_C4*/ -1, CSW_MAC10, CSW_AUG, /*CSW_SMOKEGRENADE*/ -1, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_SG550, CSW_GALIL, CSW_FAMAS, CSW_USP, CSW_GLOCK18, CSW_AWP, CSW_MP5NAVY, CSW_M249, CSW_M3, CSW_M4A1, CSW_TMP, CSW_G3SG1, /*CSW_FLASHBANG*/ -1, CSW_DEAGLE, CSW_SG552, CSW_AK47, /*CSW_KNIFE*/ -1, CSW_P90, /*CSW_VEST*/ -1, /*CSW_VESTHELM*/ -1, }
public plugin_init() { register_plugin( "Detect Shot Fired", "1.0", "Hawk552" )
for ( new i, weaponName[32]; i < sizeof gWeapons; i++ ) { if ( gWeapons[i] == -1 ) continue
get_weaponname( gWeapons[i], weaponName, charsmax( weaponName ) )
RegisterHam( Ham_Weapon_PrimaryAttack, weaponName, "HamWeaponPrimaryAttack" ) } }
public HamWeaponPrimaryAttack( weapon ) { new id = entity_get_edict( weapon, EV_ENT_owner ) // your code...
// block the original shot return HAM_SUPERCEDE
// or let it through return HAM_IGNORED }
PHP Code:
#include <amxmodx> #include <engine> #include <hamsandwich>
const gSpeedMul = 100
new gSpriteId new gSpriteModel[] = "sprites/bullshit.spr"
public plugin_init() { register_plugin( "Laser", "1.0", "Hawk552" )
// Hook from previous plugin. }
public plugin_precache() gSpriteId = precache_model( gSpriteModel )
//#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) // write_byte(TE_PROJECTILE) // write_coord(position.x) // write_coord(position.y) // write_coord(position.z) // write_coord(velocity.x) // write_coord(velocity.y) // write_coord(velocity.z) // write_short(modelindex) // write_byte(life) // write_byte(owner) projectile won't collide with owner (if owner == 0, projectile will hit any client).
// Assumed to be called by something else. public ShotFired( id ) { new origin[3], Float:lookNormal[3], velocity[3]
get_user_origin( id, origin, 1 )
velocity_by_aim( id, gSpeedMul, lookNormal ) FVecIVec( lookNormal, velocity )
message_begin( MSG_PVS, SVC_TEMPENTITY, origin ) write_byte( TE_PROJECTILE ) write_coord( origin[0] ) write_coord( origin[1] ) write_coord( origin[2] ) write_coord( velocity[0] ) write_coord( velocity[1] ) write_coord( velocity[2] ) write_short( gSpriteId ) write_byte( 100 ) // might have to adjust this write_byte( id ) message_end() }
PHP Code:
#include <amxmodx> #include <engine> #include <hamsandwich>
const gSpeedMul = 100
new gSpriteId new gSpriteModel[] = "sprites/bullshit.spr"
new gWeapons[] = { -1, CSW_P228, -1, CSW_SCOUT, /*CSW_HEGRENADE*/ -1, CSW_XM1014, /*CSW_C4*/ -1, CSW_MAC10, CSW_AUG, /*CSW_SMOKEGRENADE*/ -1, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_SG550, CSW_GALIL, CSW_FAMAS, CSW_USP, CSW_GLOCK18, CSW_AWP, CSW_MP5NAVY, CSW_M249, CSW_M3, CSW_M4A1, CSW_TMP, CSW_G3SG1, /*CSW_FLASHBANG*/ -1, CSW_DEAGLE, CSW_SG552, CSW_AK47, /*CSW_KNIFE*/ -1, CSW_P90, /*CSW_VEST*/ -1, /*CSW_VESTHELM*/ -1, }
public plugin_init() { register_plugin( "Laser Weapon Replacement", "1.0", "Hawk552" )
for ( new i, weaponName[32]; i < sizeof gWeapons; i++ ) { if ( gWeapons[i] == -1 ) continue
get_weaponname( gWeapons[i], weaponName, charsmax( weaponName ) )
RegisterHam( Ham_Weapon_PrimaryAttack, weaponName, "HamWeaponPrimaryAttack" ) } }
public plugin_precache() gSpriteId = precache_model( gSpriteModel )
public HamWeaponPrimaryAttack( weapon ) { new id = entity_get_edict( weapon, EV_ENT_owner ), origin[3], Float:lookNormal[3], velocity[3]
get_user_origin( id, origin, 1 )
velocity_by_aim( id, gSpeedMul, lookNormal ) FVecIVec( lookNormal, velocity )
message_begin( MSG_PVS, SVC_TEMPENTITY, origin ) write_byte( TE_PROJECTILE ) write_coord( origin[0] ) write_coord( origin[1] ) write_coord( origin[2] ) write_coord( velocity[0] ) write_coord( velocity[1] ) write_coord( velocity[2] ) write_short( gSpriteId ) write_byte( 100 ) // might have to adjust this write_byte( id ) message_end()
// block the original shot return HAM_SUPERCEDE }
All of this is untested. I only tried compiling the final plugin. You'll need plenty more checks, handles and changes but this should get you started.
__________________
Last edited by Hawk552; 10-22-2009 at 15:17.
Reason: corrected typo in my last sentence
|
|