Veteran Member
Join Date: Jun 2011
Location: Denver, CO
|
11-13-2013
, 13:38
Re: want to learn scripting
|
#43
|
Quote:
Originally Posted by Kia
Stop discussing now, it's annoying to see the messages when I open Tapatalk on my phone..
Lazy shits these days...
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta>
#define PLUGIN "Firework Hook"
#define VERSION "1.0.0"
#define AUTHOR "Kia"
// ===============================================================================
// Editing begins here
// ===============================================================================
// Flag required for using the Firework Hook
#define HOOK_FLAG ADMIN_ALL
// ===============================================================================
// and stops here. DO NOT MODIFY BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
// ===============================================================================
// ===============================================================================
// Variables
// ===============================================================================
/* Defines */
#define TASK_ID_HOOK 1821
#define DUMMY_VAR 1787569
#define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
#define write_coord_f(%1) ( engfunc ( EngFunc_WriteCoord, %1 ) )
/* Booleans */
new bool:g_bIsHooking[33]
/* Integer */
new g_iDestOrigin[33][3]
/* Consts */
const NULL_ENT = 0;
/* Ressources */
new szSprite
new szFlare3, szFlare6, szBlueFlare, szRedFlare
// ===============================================================================
// plugin_precache
// ===============================================================================
public plugin_precache()
{
szSprite = precache_model("sprites/laserbeam.spr")
szFlare3 = precache_model("sprites/flare3.spr")
szFlare6 = precache_model("sprites/flare6.spr")
szBlueFlare = precache_model("sprites/fwh/bflare.spr")
szRedFlare = precache_model("sprites/fwh/rflare.spr")
precache_sound("weapons/xbow_hit2.wav")
}
// ===============================================================================
// plugin_init
// ===============================================================================
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
/* Concmds */
register_concmd("+hook","ConCMD_HookOn", ADMIN_BAN," - Usage : +hook")
register_concmd("-hook","ConCMD_HookOff")
}
// ===============================================================================
// ConCMD_HookOn - Called when someone presses +hook
// ===============================================================================
public ConCMD_HookOn(id, level, cid)
{
// If user has no access, abort
if(!cmd_access(id, level, cid, 1) || g_bIsHooking[id])
return PLUGIN_HANDLED
// Removing Gravity so player can fly
set_user_gravity(id, 0.0)
// Creating Task for the Hook making the Person moving to the aimed direction
set_task(0.1,"Env_HookThink", id + TASK_ID_HOOK, "", 0, "b")
// Telling the plugin that the player is using the hook right now
g_bIsHooking[id]=true
g_iDestOrigin[id][0] = DUMMY_VAR
// Starting the Function
Env_HookThink(id + TASK_ID_HOOK)
// Playing the hook Sound
emit_sound(id,CHAN_VOICE, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
// ===============================================================================
// Env_HookThink - Brain for Hook
// ===============================================================================
public Env_HookThink(id)
{
// Since we've used id + TASK_ID_HOOK, we need to remove TASK_ID_HOOK to get the id
id -= TASK_ID_HOOK
// If the playier isn't hooking or if he isn't alive, abort
if(!g_bIsHooking[id] || !is_user_alive(id))
{
remove_task(id + TASK_ID_HOOK)
return PLUGIN_HANDLED
}
// Getting players Position
new iOrigin[3]
get_user_origin(id, iOrigin)
// If he just started to use the hook, get the position where he wants to go
if(g_iDestOrigin[id][0] == DUMMY_VAR)
{
new iOrigin2[3]
get_user_origin(id, iOrigin2,3)
g_iDestOrigin[id][0] = iOrigin2[0]
g_iDestOrigin[id][1] = iOrigin2[1]
g_iDestOrigin[id][2] = iOrigin2[2]
}
// Making a random number for the effects
new iDirection[3]
iDirection[0] = random_num(0, 255)
iDirection[1] = random_num(0, 255)
iDirection[2] = random_num(0, 255)
// Effects
_fx_TE_BEAMENTPOINT(id, g_iDestOrigin[id][0], g_iDestOrigin[id][1], g_iDestOrigin[id][2], szSprite, 0, 20, 1, 100, 10, random_num(0, 255),random_num(0, 255),random_num(0, 255), 100, 255)
_fx_TE_STREAK_SPLASH(g_iDestOrigin[id], iDirection, random_num(0, 255), 15, 5, 5)
_fx_TE_PARTICLEBURST(g_iDestOrigin[id], 500, random_num(0, 255), 150)
// Making random number for choosing random sprite for the effects
new iSprite
new iChooser = random_num(0,3)
switch(iChooser)
{
case 0: iSprite = szFlare3
case 1: iSprite = szBlueFlare
case 2: iSprite = szFlare6
case 3: iSprite = szRedFlare
}
// Creating Sprite Trail
_fx_TE_SPRITETRAIL(g_iDestOrigin[id], g_iDestOrigin[id], iSprite, 25, 10, 15, 100, 10)
// Calculating Velocity
new Float:flVelocity[3]
flVelocity[0] = (float(g_iDestOrigin[id][0]) - float(iOrigin[0])) * 3.0
flVelocity[1] = (float(g_iDestOrigin[id][1]) - float(iOrigin[1])) * 3.0
flVelocity[2] = (float(g_iDestOrigin[id][2]) - float(iOrigin[2])) * 3.0
new Float:y
y = flVelocity[0] * flVelocity[0] + flVelocity[1] * flVelocity[1] + flVelocity [2] * flVelocity[2]
new Float:x
x = (600 / floatsqroot(y))
flVelocity[0] *= x
flVelocity[1] *= x
flVelocity[2] *= x
// Setting new Velocity
set_pev(id, pev_velocity, flVelocity)
return PLUGIN_CONTINUE
}
// ===============================================================================
// ConCMD_HookOff - Called when someone presses -hook
// ===============================================================================
public ConCMD_HookOff(id)
{
// If the player stopped using the Hook, reset his gravity to normal
if(is_user_alive(id))
set_user_gravity(id)
// Tell the plugin that the player isn't using the hook now
g_bIsHooking[id] = false
return PLUGIN_HANDLED
}
// ===============================================================================
// Stocks
// ===============================================================================
public _fx_TE_STREAK_SPLASH ( const Origin[3], const Direction[3], const Color, const Count, const Speed, const VelocityRange )
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte( TE_STREAK_SPLASH )
write_coord( Origin[ 0 ] )
write_coord( Origin[ 1 ] )
write_coord( Origin[ 2 ] )
write_coord( Direction[ 0 ] )
write_coord( Direction[ 1 ] )
write_coord( Direction[ 2 ] )
write_byte( min( Color, 255 ) )
write_short( Count )
write_short( Speed )
write_short( VelocityRange )
message_end();
}
// ===============================================================================
// _fx_TE_BEAMENTPOINT
// ===============================================================================
public _fx_TE_BEAMENTPOINT(iEntity, const iEndX, const iEndY, const iEndZ, const iSpriteIndex, const iStartFrame, const iFrameRate, const iLifeTime, const iTrailWidth, const iAmplitude, const iColorR, const iColorG, const iColorB, const iBrightness, const iScrollSpeed)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMENTPOINT)
write_short(iEntity) // start entity
write_coord(iEndX) // end position
write_coord(iEndY)
write_coord(iEndZ)
write_short(iSpriteIndex) // sprite index
write_byte(iStartFrame) // starting frame
write_byte(iFrameRate) // frame rate in 0.1's
write_byte(iLifeTime) // life in 0.1's
write_byte(iTrailWidth) // line width in 0.1's
write_byte(iAmplitude) // noise amplitude in 0.01's
write_byte(iColorR) // Red
write_byte(iColorG) // Green
write_byte(iColorB) // Blue
write_byte(iBrightness) // brightness
write_byte(iScrollSpeed) // scroll speed in 0.1's
message_end()
}
// ===============================================================================
// _fx_TE_PARTICLEBURST
// ===============================================================================
public _fx_TE_PARTICLEBURST(const iOrigin[3], const iRadius, const iColor, const iDuration)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_PARTICLEBURST)
write_coord(iOrigin[0])
write_coord(iOrigin[1])
write_coord(iOrigin[2])
write_short(iRadius)
write_byte(iColor)
write_byte(iDuration)
message_end()
}
// ===============================================================================
// _fx_TE_SPRITETRAIL
// ===============================================================================
public _fx_TE_SPRITETRAIL(const iOrigin[3], const iDest[3], const iSpriteIndex, const iCount, const iLife, const iScale, const iVelocity, const iRandomFactor)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_SPRITETRAIL) // line of moving glow sprites with gravity, fadeout, and collisions
write_coord(iOrigin[0]) // coord, coord, coord (start)
write_coord(iOrigin[1])
write_coord(iOrigin[2])
write_coord(iDest[0]) // coord, coord, coord (start)
write_coord(iDest[1])
write_coord(iDest[2] - 80)
write_short(iSpriteIndex) // (sprite index)
write_byte(50 * iCount) // (count)
write_byte(iLife) // (life in 0.1's)
write_byte(iScale) // byte (scale in 0.1's)
write_byte(iVelocity) // (velocity along vector in 10's)
write_byte(iRandomFactor) // (randomness of velocity in 10's)
message_end()
}
|
__________________
|
|