All pastes #84503 Raw Edit

Hawk552

public text v1 · immutable
·published 2006-07-11 00:10 UTC
rendered paste body
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta>

// whether they're gods of war or not
new bool:g_bGod[33]
// whether they have their knives out or not
new bool:g_bKnife[33]
// what they last were pointing at if they attacked
//new Float:g_vPoint[33][2][3]
// what the ent ids are for each player, since they have 2 swords
new g_iEnts[33][2]

// blade model
new g_szModel[] = "models/w_knife.mdl"

// rope sprite
new g_szSprite[] = "sprites/rope.spr"

new g_iRope

public plugin_init()
{
	register_plugin("God of War","1.0","Hawk552")
	
	register_concmd("amx_godofwar","fnCmdGodOfWar",ADMIN_KICK,"<user> - toggles god of war on user")
	
	register_event("CurWeapon","fnEventCurWeapon","be","1=1")
}

public plugin_precache()
{
	precache_model(g_szModel)
	g_iRope = precache_model(g_szSprite)
}

public fnCmdGodOfWar(id,level,cid)
{
	if(!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED
		
	static szArg[33],szName[33],szAdminName[33],szAuthid[36]
	read_argv(1,szArg,32)
	
	new iTarget = cmd_target(id,szArg,0)
	if(!iTarget)
		return PLUGIN_HANDLED
		
	g_bGod[iTarget] = g_bGod[iTarget] ? false : true
	
	get_user_name(id,szAdminName,32)
	get_user_authid(id,szAuthid,35)
	
	get_user_name(iTarget,szName,32)
	
	client_print(id,print_console,"Set God of War succesfully.")
	
	log_amx("Cmd: ^"%s<%i><%s>^" %s god of war on %s",szAdminName,get_user_userid(id),szAuthid,g_bGod[iTarget] ? "enable" : "disable",szName)
	
	switch(get_cvar_num("amx_show_activity"))
	{
		case 1 : 
			client_print(0,print_chat,"ADMIN: %s God of War mode on %s",g_bGod[iTarget] ? "enable" : "disable",szName)
		case 2 : 
			client_print(0,print_chat,"ADMIN %s: %s God of War mode on %s",szAdminName,g_bGod[iTarget] ? "enable" : "disable",szName)
	}
	
	fnEventCurWeapon(iTarget)
	
	return PLUGIN_HANDLED
}

public fnEventCurWeapon(id)
{
	if(!g_bGod[id])
		return PLUGIN_CONTINUE
		
	new iAmmo,iClip,iWeap = get_user_weapon(id,iClip,iAmmo)
	if(iWeap != CSW_KNIFE)
	{
		g_bKnife[id] = false
		return PLUGIN_CONTINUE
	}
	
	g_bKnife[id] = true
		
	entity_set_string(id,EV_SZ_viewmodel,"")
	entity_set_string(id,EV_SZ_weaponmodel,"")
	
	return PLUGIN_CONTINUE
}

public client_PreThink(id)
{
	if(!g_bKnife[id])
		return PLUGIN_CONTINUE
		
	static Float:vOrigin[3],Float:vAngle[3]
	entity_get_vector(id,EV_VEC_origin,vOrigin)
	entity_get_vector(id,EV_VEC_v_angle,vAngle)
	
	engfunc(EngFunc_MakeVectors,vAngle)
		
	if(get_user_button(id) & IN_ATTACK && !(get_user_oldbutton(id) & IN_ATTACK))
	{
		if(!g_iEnts[id][0])
		{
			new iEnt = (g_iEnts[id][0] = create_entity("info_target"))
			
			entity_set_string(iEnt,EV_SZ_model,g_szModel)
			
			new Float:vRight[3]
			global_get(glb_v_right,vRight)
			
			for(new iCount;iCount <= 2;iCount++)
				vOrigin[iCount] += vRight[iCount] * 20
			
			entity_set_vector(iEnt,EV_VEC_origin,vOrigin)
			
			message_begin(MSG_ALL,SVC_TEMPENTITY)
			write_byte(8)
			write_short(id)
			write_short(iEnt)
			write_short(g_iRope)
			write_byte(0)
			write_byte(1)
			write_byte(100)
			write_byte(10)
			write_byte(10)
			write_byte(255)
			write_byte(0)
			write_byte(0)
			write_byte(100)
			write_byte(10)
			message_end()
			
			new ids[3]
			ids[0] = id
			ids[1] = iEnt
			ids[2] = 0
			
			set_task(10.0,"fnDestroyEnt",_,ids,3)
		}
		else if(!g_iEnts[id][1])
		{
			new iEnt = (g_iEnts[id][0] = create_entity("info_target"))
			
			entity_set_string(iEnt,EV_SZ_model,g_szModel)
			
			new Float:vRight[3]
			global_get(glb_v_right,vRight)
			
			for(new iCount;iCount <= 2;iCount++)
				vOrigin[iCount] += vRight[iCount] * 20
			
			entity_set_vector(iEnt,EV_VEC_origin,vOrigin)
			
			message_begin(MSG_ALL,SVC_TEMPENTITY)
			write_byte(8)
			write_short(id)
			write_short(iEnt)
			write_short(g_iRope)
			write_byte(0)
			write_byte(1)
			write_byte(100)
			write_byte(10)
			write_byte(10)
			write_byte(255)
			write_byte(0)
			write_byte(0)
			write_byte(100)
			write_byte(10)
			message_end()
			
			new ids[3]
			ids[0] = id
			ids[1] = iEnt
			ids[2] = 1
			
			set_task(10.0,"fnDestroyEnt",_,ids,3)
		}
	}	
	
	return PLUGIN_CONTINUE
}

public fnDestroyEnt(ids[3])
{
	remove_entity(ids[1])
	
	g_iEnts[ids[0]][ids[2]] = 0
}