Raised This Month: $ Target: $400
 0% 

Hook in Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 03-20-2010 , 08:50   Hook in Menu
Reply With Quote #1

hello. I made a plugin with menu. 1 godmode -it work 2.noclip-it work 3 hook and it work only 1 time because:

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>

new hookspr
new bool:hook[33];
new hook_to[33][3];


public plugin_init() {
	register_plugin("Turnaj","0.1","Miko")
    
	register_clcmd("say /menu", "cmd_menu")
    
	register_concmd("+hook","hook_on",ADMIN_LEVEL_C)
	register_concmd("-hook","hook_off")
}
public plugin_precache()
{
	hookspr = precache_model("sprites/dot.spr")
}

public cmd_menu(id)
{
	if(get_user_flags(id) & ADMIN_KICK)
		show_amenu(id)
}

public show_amenu(id)
{
	new menu = menu_create("\r*** Admin Menu KZSK ***", "Menu");
    
	switch(fm_get_user_godmode(id))
	{
		case 0:menu_additem(menu, "\rGodmode Off", "1", 0);
		case 1:menu_additem(menu, "\rGodmode On", "1", 0);
	}
    
	switch(get_user_noclip(id))
	    {
		case 0:menu_additem(menu, "\rNoclip Off", "2", 0);
		case 1:menu_additem(menu, "\rNoclip On", "2", 0);
	    }
	
	switch(hook[id])
	{
		case 0:menu_additem(menu, "\rHook Off", "3", 0);
		case 1:menu_additem(menu, "\rHook On", "3", 0);
	}

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
}

public Menu(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
    
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
    
	new key = str_to_num(data);
	switch(key)
{
	case 1:
	{
		switch(fm_get_user_godmode(id))
		{
			case 0:
			{
			fm_set_user_godmode(id,1)
			show_amenu(id)
			}
			case 1:
			{
			fm_set_user_godmode(id,0)
			show_amenu(id)
			}
		}
	
	}
	
	
	case 2:
	{
		switch(get_user_noclip(id))
		{
			case 0:
			{
			set_user_noclip(id,1)
			show_amenu(id)
			}
			case 1:
			{
			set_user_noclip(id,0)
			show_amenu(id)
		}
            }
	
	
	
	}
	
	
	case 3:
	{
		switch(hook[id])
		{
			case 0:
			{
			hook[id]=true
			show_amenu(id)
			}
			case 1:
			{
			hook[id]=false
			show_amenu(id)
			}
			

	
		}
	
	
	
	
	}	
}
	return PLUGIN_CONTINUE;
}

public hook_on(id,level,cid)
{
	if(!cmd_access(id,level,cid,1))
	{
		return PLUGIN_HANDLED
	}
	if(hook[id] == false)
	{
		return PLUGIN_HANDLED
	}
	fm_set_user_gravity(id,0.0)
	set_task(0.1,"hook_prethink",id+10000,"",0,"b")
	hook[id]=true
	hook_to[id][0]=999999
	hook_prethink(id+10000)
	return PLUGIN_HANDLED
}

public hook_off(id)
{
	if(is_user_alive(id)) fm_set_user_gravity(id)
	hook[id]=false 
	return PLUGIN_HANDLED
}

public hook_prethink(id)
{
	id -= 10000
	if(!is_user_alive(id))
	{
		hook[id]=false
	}
	if(!hook[id])
	{
		remove_task(id+10000)
		return PLUGIN_HANDLED
	}

	static origin1[3]
	get_user_origin(id,origin1)

	if(hook_to[id][0]==999999)
	{
		static origin2[3]
		get_user_origin(id,origin2,3)
		hook_to[id][0]=origin2[0]
		hook_to[id][1]=origin2[1]
		hook_to[id][2]=origin2[2]
	}

	//Create blue beam
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(1)		
	write_short(id)		
	write_coord(hook_to[id][0])
	write_coord(hook_to[id][1])
	write_coord(hook_to[id][2])
	write_short(hookspr)
	write_byte(1)		
	write_byte(1)		
	write_byte(2)		
	write_byte(5)		// width
	write_byte(0)		// noise
	write_byte(131)		// red
	write_byte(60)		// green
	write_byte(255)		// blue
	write_byte(200)		// brightness
	write_byte(0)		// speed
	message_end()

	//Calculate Velocity
	static Float:velocity[3]
	velocity[0] = (float(hook_to[id][0]) - float(origin1[0])) * 3.0
	velocity[1] = (float(hook_to[id][1]) - float(origin1[1])) * 3.0
	velocity[2] = (float(hook_to[id][2]) - float(origin1[2])) * 3.0

	static Float:y
	y = velocity[0]*velocity[0] + velocity[1]*velocity[1] + velocity[2]*velocity[2]

	static Float:x
	x = (8 * 120.0) / floatsqroot(y)

	velocity[0] *= x
	velocity[1] *= x
	velocity[2] *= x

	set_velo(id,velocity)

	return PLUGIN_CONTINUE
}

public set_velo(id,Float:velocity[3])
{
	return set_pev(id,pev_velocity,velocity)

}

public get_velo(id,Float:velocity[3])
{
	return pev(id,pev_velocity,velocity)

}

public is_valid_ent2(ent)
{

	return pev_valid(ent)

}

public get_solidity(ent)
{
	return pev(ent,pev_solid)
}

stock set_rendering2(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
{
	set_pev(index, pev_renderfx, fx);
	new Float:RenderColor[3];
	RenderColor[0] = float(r);
	RenderColor[1] = float(g);
	RenderColor[2] = float(b);
	set_pev(index, pev_rendercolor, RenderColor);
	set_pev(index, pev_rendermode, render);
	set_pev(index, pev_renderamt, float(amount));
	return 1;
}

i donīt know how to fix it. Hook works only 1 time. I know why but i donīt know how sorry for my bad english thx you for help
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode