Raised This Month: $ Target: $400
 0% 

duel shot by shot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
b0R3sT
Junior Member
Join Date: Jan 2011
Old 08-01-2011 , 16:50   duel shot by shot
Reply With Quote #1

would like a small example of a plugin for jb shot by shot

good can also be just the code from the shot by shot

thanks

here an example that I did

sorry for my English, I am Brazilian.

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[MaXJailBreak] TR Duelo"
#define VERSION "1.0"
#define AUTHOR "Dias"

new g_iMaxPlayers

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
	register_clcmd("say /duelo", "duelo_menu");
	register_clcmd("say !duelo", "duelo_menu");
	RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_primary_attack", 1 );     
	register_clcmd("say_team /duelo", "duelo_menu");
	register_clcmd("say_team !duelo", "duelo_menu");
	g_iMaxPlayers = get_maxplayers()
}

public event_round_start()
{
	for (new id; id <= g_iMaxPlayers; id++)
	{    
		fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 20)
	}
}

public duelo_menu(id)
{    
	if (cs_get_user_team(id) != CS_TEAM_T || !is_user_alive(id))
	{
		return PLUGIN_HANDLED;
	}
	
	new ctCount, trCount;
	
	for (new i = 1; i <= g_iMaxPlayers; i++)
	{
		if (!is_user_alive(i))
		{
			continue;
		}
		
		switch (cs_get_user_team(i))
		{
			case CS_TEAM_CT:
			{
				ctCount++;
			}
			
			case CS_TEAM_T:
			{
				trCount++;
			}
		}
	}
	
	if (trCount > 1)
	{
		return PLUGIN_HANDLED;
	}
	
	if (ctCount == 0)
	{
		return PLUGIN_HANDLED;
	}
	if(get_user_team(id) == 1 )
	{
		new duelomenu = menu_create("\r[MaXJailBreak] Escolha Seu \yDuelo:", "sub_duelo_menu")
		
		menu_additem(duelomenu, "\wDuelo de Facas", "1", 0);
		menu_additem(duelomenu, "\wDuelo de Deagle", "2", 0);
		menu_additem(duelomenu, "\wDuelo de Granadas", "3", 0);
		menu_additem(duelomenu, "\wDuelo de Scout (Tiro Por Tiro)", "4", 0);
		menu_additem(duelomenu, "\wDuelo de AWP (Tiro Por Tiro)", "5", 0);
		
		menu_setprop(duelomenu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, duelomenu, 0);
	}
	
	return PLUGIN_HANDLED;
}

public sub_duelo_menu(id, duelomenu, item)
{
	
	if (item == MENU_EXIT)
	{
		menu_destroy(duelomenu);
		return PLUGIN_HANDLED;
	}
	
	new Data[6], Name[64];
	new Access, Callback;
	menu_item_getinfo(duelomenu, item, Access, Data,5, Name, 63, Callback);
	
	new Key = str_to_num(Data);
	
	switch (Key)
	{
		case 1:
		{
			menu(id)
		}
		case 2: 
		{
			menu2(id)
		}
		case 3: 
		{
			menu3(id)
		}
		case 4: 
		{
			new tempid
			menu4(id, tempid)
		}
		case 5:
		{
			//
		}
	}
	
	menu_destroy(duelomenu);
	
	return PLUGIN_HANDLED;
}

public menu(id)
{
	
	new menu = menu_create("\r[JB]\yQuem voce quer Desafiar?:", "submenu");
	
	new players[32], pnum, tempid;
	new szName[32], szTempid[10];
	
	get_players(players, pnum, "a");
	
	for( new i; i<pnum; i++ )
	{
		tempid = players[i];
		
		if (cs_get_user_team(tempid) != CS_TEAM_CT)
		{
			continue;
		}
		
		get_user_name(tempid, szName, 31);
		num_to_str(tempid, szTempid, 9);
		menu_additem(menu, szName, szTempid, 0);
	}
	
	menu_display(id, menu);
	return PLUGIN_HANDLED;
}

public submenu(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 tempid = str_to_num(data);
	strip_user_weapons(tempid);
	give_item(tempid, "weapon_knife");
	fm_set_rendering(tempid, kRenderFxGlowShell, 0, 0, 250, kRenderNormal, 20);
	
	strip_user_weapons(id);
	set_user_health(id, 100);
	give_item(id, "weapon_knife");
	fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20);        
	
	new szName[32], szName2[32];
	get_user_name(id, szName, 31);
	get_user_name(tempid, szName2, 31);
	set_hudmessage( 0, 255, 0, -1.0, 0.40, 2, 5.0, 8.0, 0.0, 0.0, 10);
	show_hudmessage(0, "%s Foi Desafiado por %s^n a um Duelo de Facas", szName, szName2);
	
	if( is_user_alive(tempid) )
		set_user_health(tempid, 100);
	
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public menu2(id)
{
	new menu = menu_create("\r[JB]\yQuem voce quer Desafiar?:", "submenu2");
	
	new players[32], pnum, tempid;
	new szName[32], szTempid[10];
	
	get_players(players, pnum, "a");
	
	for( new i; i<pnum; i++ )
	{
		tempid = players[i];
		
		if (cs_get_user_team(tempid) != CS_TEAM_CT)
		{
			continue;
		}
		
		get_user_name(tempid, szName, 31);
		num_to_str(tempid, szTempid, 9);
		menu_additem(menu, szName, szTempid, 0);
	}
	
	menu_display(id, menu);
	return PLUGIN_HANDLED;
}

public submenu2(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 tempid = str_to_num(data);
	strip_user_weapons(tempid);
	give_item(tempid, "weapon_deagle");
	cs_set_user_bpammo(tempid,CSW_DEAGLE,7)
	fm_set_rendering(tempid, kRenderFxGlowShell, 0, 0, 250, kRenderNormal, 20)
	
	strip_user_weapons(id)
	set_user_health(id, 100)
	give_item(id, "weapon_deagle")
	cs_set_user_bpammo(id,CSW_DEAGLE,7)
	fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20)
	
	new szName[32], szName2[32]
	get_user_name(id, szName, 31);
	get_user_name(tempid, szName2, 31);
	set_hudmessage( 0, 255, 0, -1.0, 0.40, 2, 5.0, 8.0, 0.0, 0.0, 10)
	show_hudmessage(0, "%s Foi Desafiado por %s^n a um Duelo de Deagle",szName, szName2)   
	
	if( is_user_alive(tempid) )
		set_user_health(tempid, 100);
	
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public menu3(id)
{
	
	new menu = menu_create("\r[JB]\yQuem voce quer Desafiar?:", "submenu3");
	
	new players[32], pnum, tempid;
	new szName[32], szTempid[10];
	
	get_players(players, pnum, "a");
	
	for( new i; i<pnum; i++ )
	{
		tempid = players[i];
		
		if (cs_get_user_team(tempid) != CS_TEAM_CT)
		{
			continue;
		}
		
		get_user_name(tempid, szName, 31);
		num_to_str(tempid, szTempid, 9);
		menu_additem(menu, szName, szTempid, 0);
	}
	
	menu_display(id, menu);
	return PLUGIN_HANDLED;
}

public submenu3(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 tempid = str_to_num(data);
	strip_user_weapons(tempid);
	give_item(tempid, "weapon_hegrenade");
	cs_set_user_bpammo(tempid,CSW_HEGRENADE,8)
	fm_set_rendering(tempid, kRenderFxGlowShell, 0, 0, 250, kRenderNormal, 20)
	
	strip_user_weapons(id)
	set_user_health(id, 100)
	give_item(id, "weapon_hegrenade")
	cs_set_user_bpammo(id,CSW_HEGRENADE,8)
	fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20)
	
	new szName[32], szName2[32]
	get_user_name(id, szName, 31);
	get_user_name(tempid, szName2, 31);
	set_hudmessage( 0, 255, 0, -1.0, 0.40, 2, 5.0, 8.0, 0.0, 0.0, 10)
	show_hudmessage(0, "%s Foi Desafiado por %s^n a um Duelo de Granadas",szName, szName2) 
	
	
	if( is_user_alive(tempid) )
		set_user_health(tempid, 100);
	
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public fw_primary_attack(ent)
{
	//Get owner of entity
	
	new id = pev(ent,pev_owner)
	
	//if he's not alive
	if(!is_user_alive(id))
	{
		return HAM_IGNORED
	}
	
	//If player is in lr and can shoot deagle
	//Search enemy
	new players[32], pnum, tempid
	get_players(players, pnum, "a")
	for(new i; i < pnum; i++)
	{
		tempid = players[i]
		//if he's in lr and can't shoot deagle and is alive
		
		if(is_user_alive(tempid) && (id !=tempid))
		{
			menu4(id, tempid)
			return PLUGIN_CONTINUE
		}
	}
	return HAM_HANDLED
}

public menu4(id, tempid)
{
	new menu = menu_create("\r[MaX JailBreak]\yQuem voce quer Desafiar?:", "gun_switch");
	
	new players[32], pnum, tempid;
	new szName[32], szTempid[10];
	
	get_players(players, pnum, "a");
	
	for( new i; i<pnum; i++ )
	{
		tempid = players[i];
		
		if (cs_get_user_team(tempid) != CS_TEAM_CT)
		{
			continue;
		}
		
		get_user_name(tempid, szName, 31);
		num_to_str(tempid, szTempid, 9);
		menu_additem(menu, szName, szTempid, 0);
	}
	
	menu_display(id, menu);
	return PLUGIN_HANDLED;
}

public gun_switch(id, tempid, menu, item)
{
	if( item == MENU_EXIT )
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	if(is_user_alive(tempid) && (id !=tempid) && !shot_deagle[id])
	{
		
		new data[6], iName[64];
		new access, callback;
		menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
		
		strip_user_weapons(tempid)
		set_user_health ( id, 250 )
		new scout = give_item(tempid, "weapon_scout")
		cs_set_weapon_ammo(scout, 1)
		cs_set_user_bpammo(tempid, CSW_SCOUT, 0)
		shot_deagle[id] = true
		shot_deagle[tempid] = false
		
		fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20)            
		
		new szName[32], szName2[32]
		get_user_name(id, szName, 31);
		get_user_name(tempid, szName2, 31);
		set_hudmessage( 0, 255, 0, -1.0, 0.40, 2, 5.0, 8.0, 0.0, 0.0, 10)
		show_hudmessage(0, "%s Foi Desafiado por %s^n a um Duelo de Scouts (Tiro Por Tiro)",szName, szName2)    
		
		if( is_user_alive(tempid) )
			set_user_health(tempid, 250);
		
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
return PLUGIN_HANDLED
}

Last edited by b0R3sT; 08-01-2011 at 16:59.
b0R3sT is offline
Reply


Thread Tools
Display Modes

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 03:31.


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