Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[Paintball] Pomoc przy edycji Kodu.


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 xWangan

    Zaawansowany

  • Użytkownik

Reputacja: 53
Pomocny

  • Postów:149
  • Lokalizacja:Polska
Offline

Napisano 19.01.2014 17:37

Jestem początkującą osobą, nie mam pojęcia co odpowiada czemu. Prosiłbym o pomoc przy edycji kodu/kodów tak, aby pozbyć się rozrzutu kulek, tzw. Zacinania się broni, sprintu itp. Chce tylko czyste bronie. Bez żadnych menu itp. Chodzi mi o to, aby jeśli ktoś np podniesie/kupi/dostanie scouta, to dostawał jego PaintBallowy odpowiednik z odpowiednim modelem, kulkami jak i soundem.

 

Kody:

paintbalmod.sma

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "R Paintball Mod"
#define VERSION "5.8b"

#define TASK_DELAY 0.1 // The delay between model changing tasks
#define MODELSET_TASK 3000 // offset for the models task
#define MENU_TASK 3500

new onoff, cmodel, money, strip, death, protc, pbgun, pbnade, pbsnade, randomgun, maxplayers, vendetta, vendetta_cant;
new g_team_select[33], g_plyr_skin[33], g_has_kill[33];
new MenuState[33]
new ShowMenu[33]
new g_has_custom_model[33] // whether the player is using a custom model
new g_team[33]
new got_killed_by[33], vendetta_bonus[33], got_killed_times[33], in_vendetta[33]
new pbslauncher, got_slauncher;
new Float:g_models_counter // counter used to set task durations

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("rpaintballmod", VERSION, FCVAR_SERVER|FCVAR_UNLOGGED);
	set_cvar_string("rpaintballmod", VERSION)
	if (get_pcvar_num(onoff))
	{
		
		register_logevent("new_round", 2, "0=World triggered", "1=Round_Start");
		register_event("ResetHUD", "ev_resethud", "be");
		register_event("DeathMsg", "ev_death", "a")
		register_event("Money", "ev_money", "be");
		register_clcmd("say /respawn", "say_respawn", _, "<Respawns you if enabled>");

		register_clcmd("say pbguns", "enableMenu")
		register_clcmd("say /pbguns", "enableMenu")

		register_forward(FM_GetGameDescription, "fw_gamedesc");
		register_forward(FM_SetModel, "fw_setmodel", 1);
		if (get_pcvar_num(cmodel))
		{
			register_forward(FM_ClientUserInfoChanged, "fw_clientuserinfochanged");
			register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
			//register_message(get_user_msgid("ClCorpse"), "spawn_clcorpse")
			//set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
		}

		maxplayers = get_maxplayers();
		
		//initialize the menu
		for (new a = 0; a < 33; a++)
		{
			ShowMenu[a] = 1;
			in_vendetta[a] = 0
			got_killed_by[a] = -1
			got_killed_times[a] = 0
		}
		//load the config
		new file[64]
		get_configsdir(file, 63)
		format(file, 63, "%s/rpaintball.cfg", file)
		
		if(file_exists(file)) 
			server_cmd("exec %s", file)
	}

}

public plugin_precache()
{
	onoff = register_cvar("amx_pbmod", "1");
	pbgun = register_cvar("amx_pbgun", "1");
	pbnade = register_cvar("amx_pbnade", "1");
	pbsnade = register_cvar("amx_pbsnade", "1");
	if (get_pcvar_num(onoff)){
		cmodel = register_cvar("amx_pbmodel", "1");
		money = register_cvar("amx_pbmoney", "1");
		strip = register_cvar("amx_pbstrip", "1");
		death = register_cvar("amx_pbdm", "0");
		protc = register_cvar("amx_pbspawnprotect", "5");
		randomgun = register_cvar("pbgun_selectmode", "1");
		vendetta = register_cvar("pbgun_vendetta_enabled", "1");
		vendetta_cant = register_cvar("pbgun_vendetta_cant", "3");
		pbslauncher = register_cvar("pbgun_pbslauncher", "1");
	
		if (get_pcvar_num(cmodel))
			precache_model("models/player/paintballer/paintballer.mdl");
	}
}

public fw_gamedesc()
{
	if (get_pcvar_num(onoff))
	{
		forward_return(FMV_STRING, PLUGIN);
		return FMRES_SUPERCEDE;
	}
	return FMRES_IGNORED;
}

public new_round()
{
	if (get_pcvar_num(onoff) && get_pcvar_num(strip))
	{
		new ent;
		while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "armoury_entity")) != 0)
			engfunc(EngFunc_RemoveEntity, ent);
		
	}

	// Reset the models task counter			
	g_models_counter = 0.0
	
	select_new_slauncher()
	
}

public select_new_slauncher()
{
	
	new original = got_slauncher
	
	got_slauncher++
	
	while((!is_user_connected(got_slauncher) && !is_user_bot(got_slauncher) && got_slauncher != original))
	{
		got_slauncher++

		if (got_slauncher > 32)
			got_slauncher = 0
	}
	
	//client_print(0, print_chat, "%d got it", got_slauncher)
			
}

public ev_resethud(id)
{
	if (get_pcvar_num(onoff))
	{
		if (!task_exists(id))
			set_task(0.3, "player_spawn", id);		
	}
}
public player_spawn(id)
	if (is_user_alive(id))
	{
		if (get_pcvar_num(protc))
		{
			set_pev(id, pev_takedamage, DAMAGE_NO);
			set_task(float(get_pcvar_num(protc)), "player_godmodeoff", id+100);
		}

		if (get_pcvar_num(strip)) //&& !user_has_mp5(id))
		{
			if (pev(id, pev_weapons) & (1 << CSW_C4))
				engclient_cmd(id, "drop", "weapon_c4")
			fm_strip_user_weapons(id);
		}

		if (get_pcvar_num(money))
		{
			message_begin(MSG_ONE_UNRELIABLE, 94, _, id); 
			write_byte(1 << 5);
			message_end();
		}

		if (get_pcvar_num(cmodel))
		{
			set_task(0.1 + g_models_counter, "task_set_model", id+MODELSET_TASK)
			g_models_counter += TASK_DELAY
		}

		remove_task(id);
		set_task(random_float(0.9, 1.3), "player_weapons", id);
		set_task(2.0, "clear_moneyhud", id + 300);		
		
	}

public client_command(id)
	if (get_pcvar_num(cmodel))
	{		
		new command[10], speech[2];
		read_argv(0, command, 9);
		read_argv(1, speech, 1);
		if (containi(command, "join") != -1)
			if (equali(command, "jointeam"))
				g_team_select[id] = str_to_num(speech);
			else if (equali(command, "joinclass"))
				g_plyr_skin[id] = (g_team_select[id] == 1) ? str_to_num(speech) - 1: str_to_num(speech) + 3;
	}

public player_weapons(id)
	if (is_user_alive(id))
	{
	
		menu_cancel(id)
		
		if(in_vendetta[id])
		{
			new kname[32]; get_user_name(got_killed_by[id],kname,31);
			set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 5.0, 5.0);
			show_hudmessage(id, "You took %s's gow** poraz ostatni.. to jest wandeta!!!", kname);
		}

		
		set_pdata_int(id, 386, 120, 5);
		fm_give_item(id, "weapon_knife");
		if (get_user_team(id) == 1)
			fm_give_item(id, "weapon_glock18");
		else 
		{
			set_pdata_int(id, 382, 48, 5);
			fm_give_item(id, "weapon_usp");
		}
		if (get_pcvar_num(pbgun) && !vendetta_bonus[id]){

			if (get_pcvar_num(randomgun)==1){

				if(is_user_bot(id))
				{
					ShowMenu[id] = false;
					MenuState[id] = random(4);
				}
				
				if (ShowMenu[id])
					launchMenu(id);
				else
				{	
					give_menu_weapon(id, MenuState[id]);
					client_print(id, print_chat, "[RPaintballMod] nie masz menu broni ? wpisz /pbguns i poczekaj runde!.")	
				}

			}
			else
			{
				new choose;
				if (get_pcvar_num(randomgun)==2){
					choose = random(4);
					
					if (random(20)==0){
						fm_give_item(id, "weapon_p90");
						cs_set_user_bpammo(id, CSW_P90, 300);
						set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 5.0, 5.0);
						show_hudmessage(id, "Masz Szczescie ! masz a SUPER MARKER!!!!");
					}
					else
					switch (choose)
					{
						case 0: fm_give_item(id, "weapon_mp5navy");
						case 1: fm_give_item(id, "weapon_scout");
						case 2: fm_give_item(id, "weapon_m3");
						case 3: fm_give_item(id, "weapon_xm1014");
						default: fm_give_item(id, "weapon_mp5navy");
					}
					cs_set_user_bpammo(id, CSW_MP5NAVY, 150);
					cs_set_user_bpammo(id, CSW_SCOUT, 20);
					cs_set_user_bpammo(id, CSW_M3, 16);
					cs_set_user_bpammo(id, CSW_XM1014, 80);
					cs_set_user_bpammo(id, CSW_P90, 300);
				}else
				{
					//always gets a marker
					fm_give_item(id, "weapon_mp5navy");
					cs_set_user_bpammo(id, CSW_MP5NAVY, 150);
	
					//did not kill someone, has a chance of getting a shotgun
					choose = random(3);					
					if (!g_has_kill[id] && !choose){
							fm_give_item(id, "weapon_xm1014");
							cs_set_user_bpammo(id, CSW_XM1014, 80);
						}
						
					//killed 2 or more, gets a sniper or a launcher
					choose = random(2);					
					if (g_has_kill[id]>2)
						if (g_has_kill[id]>4){
							fm_give_item(id, "weapon_p90");
							cs_set_user_bpammo(id, CSW_P90, 300);
							set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 5.0, 5.0);
							show_hudmessage(id, "o Kur**! masz SUPER MARKER!!!!");
						}	
						else
							if (choose){
								fm_give_item(id, "weapon_scout");
								cs_set_user_bpammo(id, CSW_SCOUT, 20);
							}else
							{
								fm_give_item(id, "weapon_m3");
								cs_set_user_bpammo(id, CSW_M3, 16);
							}
					g_has_kill[id] = 0;
				}
			}	
		}
		
		if(vendetta_bonus[id] == 1)
		{
			fm_give_item(id, "weapon_p90");
			cs_set_user_bpammo(id, CSW_P90, 300);
			set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 5.0, 5.0);
			show_hudmessage(id, "Niemozliwe! dostal  SUPER MARKER!!!!");
		}

		if(vendetta_bonus[id] == -1)
		{
			vendetta_bonus[id] = 0
			set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 5.0, 5.0);
			show_hudmessage(id, "Haha! You got punk'd and didn't get a main gun this round!!!!");
		}

		
		if (get_pcvar_num(pbnade))
			fm_give_item(id, "weapon_hegrenade");
	
		if (get_pcvar_num(pbsnade))
			fm_give_item(id, "weapon_smokegrenade");

		if (get_pcvar_num(pbslauncher) && id == got_slauncher)
		{
			new kname[32]; get_user_name(id,kname,31);
			new teamname[3][] = {"None", "Red Team", "Blue Team"};
			set_hudmessage(255, 255, 255, -1.0, 0.7, 0, 5.0, 5.0);
			show_hudmessage(0, "%s: %s dostal Super Launchera (Flesh), UWAGA!!!!", teamname[get_user_team(id)], kname);
			//client_print(0, print_chat, "%s: %s dostal Super Launchera (Flesh), UWAGA!!!!", teamname[get_user_team(id)], kname)
			fm_give_item(id, "weapon_flashbang");
			//fm_give_item(id, "weapon_flashbang");
			
			if (get_pcvar_num(death))
				select_new_slauncher()
	
		}
		
		remove_task(id);
	}

public clear_moneyhud(id)
	if (get_pcvar_num(money))
	{
		message_begin(MSG_ONE_UNRELIABLE, 94, _, id - 300); //HideWeapon
		write_byte(1 << 5);
		message_end();
	}
	
public ev_death()
{

	new killer = read_data(1);
	new victim = read_data(2);
	
	g_has_kill[killer] += 1;
	if (get_pcvar_num(death))
	{
		new id = victim + 200;
		set_task(3.0, "player_spawner", id);
		set_task(3.2, "player_spawner", id);
	}

	if (get_pcvar_num(vendetta) && killer != victim)
	{

		vendetta_bonus[victim] = 0
	
		if (got_killed_by[victim] == killer)
		{
			got_killed_times[victim] += 1;
		}
		else
		{
			got_killed_by[victim] = killer;
			got_killed_times[victim] = 1;
		}
	
		if (got_killed_times[victim] < get_pcvar_num(vendetta_cant))
			in_vendetta[victim] = 0;
		else
			in_vendetta[victim] = 1;

		if (got_killed_by[killer] == victim)
			if (in_vendetta[killer])
			{
				in_vendetta[killer] = 0
				vendetta_bonus[killer] = 1
				vendetta_bonus[victim] = -1
				got_killed_times[killer] = 0
				got_killed_by[killer] = -1
				
				new kname[32]; get_user_name(killer,kname,31);
				
				set_hudmessage(255, 255, 255, -1.0, 0.4, 0, 5.0, 5.0);
				show_hudmessage(0, "%s got VENDETTA!!!!", kname);
			}
			else
				got_killed_times[killer] = 0
			
	}

}

public ev_money(id)
	if (get_pcvar_num(money))
		if (get_pdata_int(id, 115, 5) > 0)
			set_pdata_int(id, 115, 0, 5);

public say_respawn(id)
	if (get_pcvar_num(death))
		if (!is_user_alive(id))
			if (get_user_team(id) == 1 || get_user_team(id) == 2)
			{
				set_task(1.5, "player_spawner", id + 200);
				set_task(1.7, "player_spawner", id + 200);
			}

public player_godmodeoff(id)
	set_pev(id-100, pev_takedamage, DAMAGE_AIM);

public player_spawner(id)
	if (is_user_connected(id - 200))
		if (get_user_team(id - 200) == 1 || get_user_team(id - 200) == 2)
			dllfunc(DLLFunc_Spawn, id - 200);

stock user_has_mp5(id)
{
	new weapons[32], num;
	get_user_weapons(id, weapons, num);
	for (new i = 0; i < num; i++)
		if (weapons[i] == CSW_MP5NAVY)
			return 1;
	return 0;
}

public fw_setmodel(ent, model[])
{
	if (get_pcvar_num(death) && pev_valid(ent))
	{
		new id = pev(ent, pev_owner);
		if ((!is_user_alive(id) || task_exists(id + 200)) && equali(model, "models/w_", 9) && !equali(model, "models/w_weaponbox.mdl"))
		{
			new classname[16];
			pev(ent, pev_classname, classname, 15);
			if (equal(classname, "weaponbox") && !equal(model, "models/w_backpack.mdl"))
				for (new i = maxplayers + 1; i < engfunc(EngFunc_NumberOfEntities) + 5; i++)
					if (pev_valid(i))
						if (ent == pev(i, pev_owner))
						{
							dllfunc(DLLFunc_Think, ent);
							return FMRES_IGNORED;
						}
		}
	}
	return FMRES_IGNORED;
}

public fw_clientuserinfochanged(id, infobuffer)
{
	
//	return (get_pcvar_num(cmodel) && pev(id, pev_deadflag) == DEAD_NO) ? FMRES_SUPERCEDE : FMRES_IGNORED;
		
	if (get_pcvar_num(cmodel) && (g_has_custom_model[id]))
	{

		if (g_team[id] != get_user_team(id))
			g_has_custom_model[id] = 0;
		
		// Get current model
		static currentmodel[32]
		
		engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", currentmodel, 31)
		
		// Check whether it matches the custom model - if not, set it again
		if (!equal(currentmodel, "paintballer") || g_has_custom_model[id] == 0)
		{
			set_task(0.1 + g_models_counter, "task_set_model", id+MODELSET_TASK)
			g_models_counter += TASK_DELAY
		}
		
		return FMRES_SUPERCEDE;
	}
	return FMRES_IGNORED
}

public fw_SetClientKeyValue(id, const infobuffer[], const key[])
{   
    // Block CS model changes
    if (g_has_custom_model[id] && equal(key, "model"))
        return FMRES_SUPERCEDE;
        
    return FMRES_IGNORED;
}	

////////*****************VEN STOCKS START*****************////////
stock fm_strip_user_weapons(index)
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"));
	if (!pev_valid(ent))
		return 0;
	dllfunc(DLLFunc_Spawn, ent);
	dllfunc(DLLFunc_Use, ent, index);
	engfunc(EngFunc_RemoveEntity, ent);
	return 1;
}

stock fm_give_item(index, const item[])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
	if (!pev_valid(ent))
		return 0;
	new Float:origin[3];
	pev(index, pev_origin, origin);
	engfunc(EngFunc_SetOrigin, ent, origin);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);
	new save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, index);
	if (pev(ent, pev_solid) != save)
		return ent;
	engfunc(EngFunc_RemoveEntity, ent);
	return -1;
}
////////*****************VEN STOCKS END*****************////////

public enableMenu(id)
{
	ShowMenu[id] = 1
	client_print(id, print_chat, "[PaintballMod] Your equip menu has been re-enabled.")
	return PLUGIN_HANDLED

}

public launchMenu(id)
 {
	new menu = menu_create("\rChoose your main Paintball Gun:", "menu_handler")
	
	menu_additem(menu, "\wMarker", "0", 0)
	menu_additem(menu, "\wShotgun", "1", 0)
	menu_additem(menu, "\wLauncher", "2", 0)
	menu_additem(menu, "\wSniper", "3", 0)
	menu_additem(menu, "Ostatnio brana bron", "4", 0, -1)
	menu_additem(menu, "Ostatnia bron + nie pokazuje menu", "5", 0, -1)

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

public menu_handler(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);
	
	if (key==4)
		key = MenuState[id]

	if(key == 5)
	{
		ShowMenu[id] = 0;
		client_print(id, print_chat, "[RPaintballMod] Nie masz menu broni? wpisz /pbguns i poczekaj Runde.")	
		key = MenuState[id]
	}
	
	MenuState[id] = key

	give_menu_weapon(id, MenuState[id]);
		
	menu_destroy(menu)
	return PLUGIN_HANDLED
 }

public give_menu_weapon(id,key)
{
	switch (key)
	{
		case 0: fm_give_item(id, "weapon_mp5navy");
		case 1: fm_give_item(id, "weapon_xm1014");
		case 2: fm_give_item(id, "weapon_m3");
		case 3: fm_give_item(id, "weapon_scout");
		default: fm_give_item(id, "weapon_mp5navy");
	}
	
	cs_set_user_bpammo(id, CSW_MP5NAVY, 150);
	cs_set_user_bpammo(id, CSW_SCOUT, 20);
	cs_set_user_bpammo(id, CSW_M3, 16);
	cs_set_user_bpammo(id, CSW_XM1014, 80);

}

public task_set_model(id)
{
    remove_task(id)
    
    // Get player id
    id -= MODELSET_TASK
    
    // Actually set the player's model
    set_user_model(id, "paintballer")
}

public set_user_model(player, const modelname[])
{
	// Set new model
	engfunc(EngFunc_SetClientKeyValue, player, engfunc(EngFunc_GetInfoKeyBuffer, player), "model", modelname)
	
	g_team[player] = get_user_team(player)

	//if (!g_has_custom_model[player])
	if (g_team[player] == 1)
	{
		g_plyr_skin[player] = 0//random(4);
	}
	else
	{
		g_plyr_skin[player] = 4 // + random(4);
	}

		
	set_pev(player, pev_skin, g_plyr_skin[player]);
	
	g_has_custom_model[player] = 1	
}

public spawn_clcorpse()
{
    // Get player id
    static id
    id = get_msg_arg_int(12)
    
    new entCorpse = read_data(2);
    set_pev(entCorpse, pev_skin, g_plyr_skin[id]);
    
    
    // Check if the player is using a custom player model
    if (false && g_has_custom_model[id])
    {
        //client_print(0, print_chat, "spawning corpse for %d", id);

	set_msg_arg_string(1, "")
	
	new entCorpse = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(entCorpse > 0)
	{
		new Float:modelOrigin[3], Float:modelAngle[3]
		pev(id, pev_origin, modelOrigin)
		pev(id, pev_angles, modelAngle)

		client_print(0, print_chat, "corpse coords %f %f %f", float(get_msg_arg_int(2)), float(get_msg_arg_int(3)), float(get_msg_arg_int(4)));		
		client_print(0, print_chat, "corpse coords %i %i %i", get_msg_arg_int(2), get_msg_arg_int(3), get_msg_arg_int(4));		
		//client_print(0, print_chat, "corpse string %f %f %f", float(get_msg_arg_string(2)), float(get_msg_arg_string(3)), float(get_msg_arg_string(4)));		
		client_print(0, print_chat, "player coords %f %f %f", modelOrigin[0], modelOrigin[1], modelOrigin[2]);		
//		client_print(0, print_chat, "player %f %f %f", modelAngle[0], modelAngle[1], modelAngle[2]);		
	
		modelAngle[0] += 90.0
		
		modelOrigin[2] -= 35.0
		
		set_pev(entCorpse, pev_owner, id)
		set_pev(entCorpse, pev_classname, "clcorpse")
		engfunc(EngFunc_SetSize, entCorpse, Float:{-6.0,-12.0,-6.0},Float:{6.0,12.0,6.0})
		engfunc(EngFunc_SetModel, entCorpse, "models/player/paintballer/paintballer.mdl");
		set_pev(entCorpse, pev_skin, g_plyr_skin[id]);
		set_pev(entCorpse, pev_solid, SOLID_NOT)
		set_pev(entCorpse, pev_movetype, MOVETYPE_TOSS)
		set_pev(entCorpse, pev_sequence, 103)
		set_pev(entCorpse, pev_origin, modelOrigin)
		set_pev(entCorpse, pev_angles, modelAngle)
		set_pev(entCorpse, pev_v_angle, pev(id, pev_v_angle))
		set_pev(entCorpse, pev_nextthink, 1.0)
		
		}

	return PLUGIN_HANDLED;
	}
    return PLUGIN_CONTINUE;
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
*/

paintballgun.sma

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <fun>

#define PLUGIN "R Paintball Gun"
#define VERSION "5.10"


#define MAX_PAINTBALLS	200
#define TASK_PB_RESET	1000
#define TASK_RELOAD	2000
#define TASK_NADE	5000
#define CROSSHAIR_REMOVED ( 1<<6 )

#define PB_MARKER 1
#define PB_USP 2
#define PB_GLOCK 3
#define PB_SNIPER 4
#define PB_LAUNCHER 5
#define PB_SHOTGUN 6
#define PB_SUPERMARKER 7

new g_msgHideWeapon;
new g_paintballs[MAX_PAINTBALLS], g_pbstatus[MAX_PAINTBALLS], g_pbcount, Float:lastshot[33], Float:nextattack[33], freezetime;
new pbgun, color, shots, blife, sound, bglow, damage, friendlyfire, beamspr;
new blood1, blood2, knife_ohk, jamon, pellets_real, pbslauncher;

new fire_rate_low, fire_rate_medium, fire_rate_high, jam_prob_low, jam_prob_high, gravity, speed_marker, speed_pistol, speed_shotgun, speed_sniper, dispersion, removecrosshair, speed_launcher, speed_smarker ;

static const g_shot_anim[8] = {0, 3, 9, 5, 1, 1, 1, 3};
static const g_pbgun_models[11][] = {"models/v_pbgun.mdl", "models/v_pbgun1.mdl", "models/v_pbgun2.mdl", "models/v_pbgun3.mdl", "models/v_pbgun4.mdl", "models/v_pbgun5.mdl", "models/v_pbgun6.mdl", "models/v_pbgun7.mdl", "models/v_pbgun8.mdl", "models/v_pbgun9.mdl", "models/v_pbgun10.mdl"};

new g_Jammed[33];

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("rpaintballgun", VERSION, FCVAR_SERVER|FCVAR_UNLOGGED);
	set_cvar_string("rpaintballgun", VERSION)
	register_clcmd("say /ent", "ent_info", ADMIN_SLAY);
	g_msgHideWeapon  = get_user_msgid( "HideWeapon" );
			
	if (get_pcvar_num(pbgun))
	{
		register_event("CurWeapon", "ev_curweapon", "be");
		register_logevent("ev_roundstart", 2, "0=World triggered", "1=Round_Start");
		if (get_cvar_num("mp_freezetime") > 0)
			register_event("HLTV", "ev_freezetime", "a", "1=0", "2=0");

		register_forward(FM_Touch, "fw_touch");
		register_forward(FM_SetModel, "fw_setmodel");
		register_forward(FM_CmdStart, "fw_cmdstart");
		register_forward(FM_UpdateClientData, "fw_updateclientdata",1);
		if (get_pcvar_num(pbslauncher)) 
			register_forward(FM_Think, "fw_think");

		RegisterHam ( Ham_TakeDamage, "player", "fwd_TakeDamage" );
		
		RegisterHam (Ham_Weapon_Reload, "weapon_m3", "fw_reload", 1);
		RegisterHam (Ham_Weapon_Reload, "weapon_xm1014", "fw_reload", 1);
		RegisterHam (Ham_Weapon_Reload, "weapon_scout", "fw_reload", 1);
		
		set_cvar_num ("sv_maxvelocity", 4000);
		
		new a, max_ents_allow = global_get(glb_maxEntities) - 5;
		for (a = 1; a <= get_pcvar_num(shots); a++)
			if (a < MAX_PAINTBALLS)
				if (engfunc(EngFunc_NumberOfEntities) < max_ents_allow)
				{
					g_paintballs[a] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
					if (pev_valid(g_paintballs[a]))
					{
						set_pev(g_paintballs[a], pev_effects, pev(g_paintballs[a], pev_effects) | EF_NODRAW);
						g_pbcount++;
					}
				}
		if (g_pbcount < 1)
			set_fail_state("[AMXX] Failed to load Realism for Paintball Gun (unable to create ents)");

		server_print("*** %s v%s by %s Enabled ***", PLUGIN, VERSION, AUTHOR);
	}
}

public plugin_precache()
{
	pbgun = register_cvar("amx_pbgun", "1");
	knife_ohk = register_cvar("amx_knifeonehitkill", "1");
	jamon = register_cvar("amx_pbgun_jam","1");

	friendlyfire = get_cvar_pointer("mp_friendlyfire");
	
	if (get_pcvar_num(pbgun)) {
		
		color = register_cvar("pbgun_color", "1");
		shots = register_cvar("pbgun_shots", "100");
		blife = register_cvar("pbgun_life", "15");
		sound = register_cvar("pbgun_sound", "1");
		bglow = register_cvar("pbgun_glow", "c");
		damage = register_cvar("pbgun_damage", "100");
		
		fire_rate_low = register_cvar("pbgun_fireratelow", "1.1");
		fire_rate_high = register_cvar("pbgun_fireratehigh", "0.16");
		fire_rate_medium = register_cvar("pbgun_fireratemedium", "0.7");
		jam_prob_low = register_cvar("pbgun_jamproblow", "30");
		jam_prob_high = register_cvar("pbgun_jamprobhigh", "100");
		gravity = register_cvar("pbgun_gravity", "1");
		speed_marker = register_cvar("pbgun_velocity_marker", "2000");
		speed_smarker = register_cvar("pbgun_velocity_super_marker", "2500");
		speed_pistol = register_cvar("pbgun_velocity_pistol", "1500");
		speed_launcher = register_cvar("pbgun_velocity_launcher", "1500");
		speed_shotgun = register_cvar("pbgun_velocity_shotgun", "1500");
		speed_sniper = register_cvar("pbgun_velocity_sniper", "4000");
		dispersion = register_cvar("pbgun_dispersion", "100");
		removecrosshair = register_cvar("pbgun_nocrosshair", "1");
		pellets_real = register_cvar("pbgun_real_pellets", "1");
		pbslauncher = register_cvar("pbgun_pbslauncher", "1");

		precache_model(g_pbgun_models[3]);
		precache_model(g_pbgun_models[7]);
		precache_model("models/v_pbgun1.mdl");
		precache_model("models/v_pbgun6.mdl");
		precache_model("models/p_pbgun.mdl");
		precache_model("models/p_pbgun1.mdl");
		precache_model("models/w_pbgun.mdl");
		precache_model("models/v_pb_sniper.mdl");
		precache_model("models/p_pb_sniper.mdl");
		precache_model("models/w_pb_sniper.mdl");
		precache_model("models/v_pb_shotgun.mdl");
		precache_model("models/p_pb_shotgun.mdl");
		precache_model("models/w_pb_shotgun.mdl");
		precache_model("models/v_pb_launcher.mdl");
		precache_model("models/w_pb_launcher.mdl");
		precache_model("models/p_pb_launcher.mdl");
		precache_model("models/w_pb_launch_he.mdl");
		precache_model("models/p_pb_knife.mdl");
		precache_model("models/v_pb_knife.mdl");
		precache_model("models/v_pb_superlauncher.mdl");
		precache_model("models/w_pb_supernade.mdl");
		blood1 = precache_model("sprites/blood.spr");
		blood2 = precache_model("sprites/bloodspray.spr");
		precache_model("models/v_pbusp.mdl");
		precache_model("models/p_pbusp.mdl");
		precache_model("models/v_pbglock.mdl");
		precache_model("models/p_pbglock.mdl");

		precache_sound("misc/pb1.wav");
		precache_sound("misc/pb2.wav");
		precache_sound("misc/pb3.wav");
		precache_sound("misc/pb4.wav");
		precache_sound("misc/pbg.wav");
		precache_sound("misc/pb_launcher.wav");
		precache_model("models/w_paintball.mdl");
		precache_model("sprites/paintball.spr");
		precache_sound("weapons/scout_fire-1.wav");
		precache_sound("weapons/dryfire_pistol.wav");
		precache_sound("weapons/scout_bolt.wav");
		precache_sound("weapons/draw.wav");
		precache_sound("weapons/insert.wav");
		precache_sound("weapons/magin.wav");
		precache_sound("weapons/magout.wav");
		precache_sound("weapons/magrel.wav");
		precache_sound("weapons/pullout.wav");
		precache_sound("weapons/roll.wav");
	}
	beamspr = precache_model("sprites/laserbeam.spr");
}

public ent_info(id)
	client_print(id, print_chat, "[AMXX] [Ent Info (Current/Max)] Paintballs: (%d/%d)   Entities: (%d/%d)", g_pbcount, get_pcvar_num(shots), engfunc(EngFunc_NumberOfEntities), global_get(glb_maxEntities));

public ev_curweapon(id)
{
	//replace the weapon model with the PB model
	new model[25];
	pev(id, pev_viewmodel2, model, 24);
	if (equali(model, "models/v_mp5.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, (get_user_team(id) == 1) ? g_pbgun_models[3] : g_pbgun_models[7]);
		set_pev(id, pev_weaponmodel2, "models/p_pbgun1.mdl");
	}
	else if (equali(model, "models/v_usp.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pbusp.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pbusp.mdl");
	}
	else if (equali(model, "models/v_glock18.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pbglock.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pbglock.mdl");
	}else if (equali(model, "models/v_scout.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pb_sniper.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pb_sniper.mdl");
	}else if (equali(model, "models/v_m3.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pb_launcher.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pb_launcher.mdl");
	}else if (equali(model, "models/v_knife.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pb_knife.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pb_knife.mdl");
	}else if (equali(model, "models/v_p90.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, (get_user_team(id) == 1) ? "models/v_pbgun1.mdl" : "models/v_pbgun6.mdl" );
		
		set_pev(id, pev_weaponmodel2, "models/p_pbgun1.mdl");
	}else if (equali(model, "models/v_xm1014.mdl") && get_pcvar_num(pbgun))
	{
		set_pev(id, pev_viewmodel2, "models/v_pb_shotgun.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pb_shotgun.mdl");
	}else if (equali(model, "models/v_flashbang.mdl") && get_pcvar_num(pbgun) && get_pcvar_num(pbslauncher))
	{
		set_pev(id, pev_viewmodel2, "models/v_pb_superlauncher.mdl");
		set_pev(id, pev_weaponmodel2, "models/p_pb_shotgun.mdl");
	}
	
	new my_pbgun = user_has_pbgun(id);
	if (my_pbgun){
		
		if (get_pcvar_num(removecrosshair))
		{
			//Remove the crosshair
			message_begin( MSG_ONE_UNRELIABLE, g_msgHideWeapon, _, id );
			write_byte( CROSSHAIR_REMOVED );
			message_end();
		}
		
	}
}

public fw_setmodel(ent, model[]) 
{
	//replace dropped models with PB models
 	if (equali(model, "models/w_mp5.mdl") || equali(model, "models/w_p90.mdl")) 
		if (get_pcvar_num(pbgun))
		{
			engfunc(EngFunc_SetModel, ent, "models/w_pbgun.mdl");
							
			return FMRES_SUPERCEDE;
		}
	if (equali(model, "models/w_scout.mdl")) 
		if (get_pcvar_num(pbgun))
		{
			engfunc(EngFunc_SetModel, ent, "models/w_pb_sniper.mdl");

			return FMRES_SUPERCEDE;
		}
	if (equali(model, "models/w_m3.mdl")) 
		if (get_pcvar_num(pbgun))
		{
			engfunc(EngFunc_SetModel, ent, "models/w_pb_launcher.mdl");

			return FMRES_SUPERCEDE;
		}
	if (equali(model, "models/w_xm1014.mdl")) 
		if (get_pcvar_num(pbgun))
		{
			engfunc(EngFunc_SetModel, ent, "models/w_pb_shotgun.mdl");
		
			return FMRES_SUPERCEDE;
		}
	if (equali(model, "models/w_flashbang.mdl") && get_pcvar_num(pbslauncher)) 
		if (get_pcvar_num(pbgun))
		{
			engfunc(EngFunc_SetModel, ent, "models/w_pb_supernade.mdl");
		
			return FMRES_SUPERCEDE;
		}

	return FMRES_IGNORED;
}

public fw_updateclientdata(id, sw, cd_handle)
{
	//this function overrides the client side sounds and stuff
	if (user_has_pbgun(id) && cd_handle)
	{

		set_cd(cd_handle, CD_ID, 1);
		get_cd(cd_handle, CD_flNextAttack, nextattack[id]);
		
		return FMRES_HANDLED;

	}
	return FMRES_IGNORED;
}

public fw_reload(weapon)
{
	new id = pev(weapon, pev_owner)	
	new ammo, null = get_user_weapon(id, ammo, null);
	new my_pbgun = user_has_pbgun(id)
	
	if ((my_pbgun == PB_LAUNCHER && ammo < 8) || (my_pbgun == PB_SHOTGUN && ammo < 7) || (my_pbgun == PB_SNIPER && ammo < 10))
	{
		lastshot[id] = get_gametime();
		set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 1.0, 1.0);
		show_hudmessage(id, "Przeladowywanie...");

		message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id);
		write_byte(3);
		write_byte(0);
		message_end();
	}
}

public try_to_jam(id, my_pbgun){

	//chance of jamming the current weapon
	if(get_pcvar_num(jamon) && !g_Jammed[id] && my_pbgun != PB_GLOCK && my_pbgun != PB_USP && !is_user_bot(id))
	{			
		new average_usage_jam;
		
		switch (my_pbgun)
		{
			case PB_MARKER: average_usage_jam = get_pcvar_num(jam_prob_high);
			case PB_GLOCK: average_usage_jam = get_pcvar_num(jam_prob_high);
			case PB_USP: average_usage_jam = get_pcvar_num(jam_prob_high);
			case PB_SNIPER: average_usage_jam = get_pcvar_num(jam_prob_low);
			case PB_LAUNCHER: average_usage_jam = get_pcvar_num(jam_prob_low);
			case PB_SHOTGUN: average_usage_jam = get_pcvar_num(jam_prob_low);
			case PB_SUPERMARKER: average_usage_jam = get_pcvar_num(jam_prob_high) * 2;
			default: average_usage_jam = get_pcvar_num(jam_prob_high);
		}

		new jam = (random(average_usage_jam)==0);
		if(jam)
		{
			emit_sound(id,CHAN_AUTO, "weapons/dryfire_pistol.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
			g_Jammed[id] = my_pbgun;
		}
	}
	
}

public fw_cmdstart( id, uc_handle, random_seed )
{
    if ( !is_user_alive( id ) )
        return FMRES_IGNORED
    
    static buttons; buttons = get_uc( uc_handle, UC_Buttons )
    new my_pbgun = user_has_pbgun(id);

    //if jammed, clear the chamber
    if ( buttons & IN_USE && my_pbgun == g_Jammed[id] && my_pbgun && get_pcvar_num(jamon))
    	clear_chamber(id);

//if he is shooting with a PBGUN
    if ( buttons & IN_ATTACK && my_pbgun)
    {	
	//check if weapon is jammed
	if(g_Jammed[id] == my_pbgun && !is_user_bot(id) && get_pcvar_num(jamon))
	{
		weapon_jam(id, uc_handle);
		return FMRES_IGNORED;
	}
	
	set_uc (uc_handle, UC_Buttons, buttons & ~IN_ATTACK);

	new ammo, null = get_user_weapon(id, ammo, null);
	if (ammo)
	{
		new Float:gametime = get_gametime(), Float:g_speed;	
					
		switch (my_pbgun)
		{
			case PB_MARKER: g_speed = get_pcvar_float(fire_rate_high);
			case PB_GLOCK: g_speed = get_pcvar_float(fire_rate_high);
			case PB_USP: g_speed = get_pcvar_float(fire_rate_high);
			case PB_SNIPER: g_speed = get_pcvar_float(fire_rate_low);
			case PB_LAUNCHER: g_speed = get_pcvar_float(fire_rate_low);
			case PB_SHOTGUN: g_speed = get_pcvar_float(fire_rate_medium);
			case PB_SUPERMARKER: g_speed = get_pcvar_float(fire_rate_high)/2.0;
			default: g_speed = get_pcvar_float(fire_rate_high);
		}
		
		new cangofull = (my_pbgun == PB_MARKER || my_pbgun == PB_LAUNCHER || my_pbgun == PB_SHOTGUN || my_pbgun == PB_SUPERMARKER);
		
		//check that the button was not pressed before or that the weapon can go full-auto
		new auto = !(pev(id, pev_oldbuttons) & IN_ATTACK) || cangofull;
		
		//check the fire-rate and freezetime
		if (gametime-lastshot[id] > g_speed  && (is_user_bot(id) || nextattack[id] < 0.0) && !freezetime && auto)
		{
		
			new fired;
					
			if (my_pbgun == PB_SHOTGUN)
			{ //shoot 5 pellets
				for (new a = 0; a < 5; a++)
					fired = paint_fire(id, a) || fired;
			}
			else	//shoot 1 pellet
				fired = paint_fire(id, 0);
			
			if (fired)
			{
				
				lastshot[id] = gametime;
				set_user_clip(id, ammo - 1);
				
				//show the animation
				set_pev(id, pev_punchangle, Float:{-0.5, 0.0, 0.0});
				message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id);
				write_byte(g_shot_anim[my_pbgun]);
				write_byte(0);
				message_end();
				
				//shooting sound
				if (get_pcvar_num(sound))
					if (my_pbgun != PB_SNIPER)
						if (my_pbgun != PB_LAUNCHER)
							emit_sound(id, CHAN_AUTO, "misc/pbg.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
						else
						emit_sound(id, CHAN_AUTO, "misc/pb_launcher.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
					else
						emit_sound(id, CHAN_AUTO, "weapons/scout_fire-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);

				try_to_jam(id,my_pbgun)

			}
		}

	}
	return FMRES_IGNORED;
    }

    return FMRES_IGNORED
}

public paint_fire(id, num)
{
	new a, ent;
	while (a++ < g_pbcount - 1 && !ent)
		if (g_pbstatus[a] == 0)
			ent = g_pbstatus[a] = g_paintballs[a];
	if (!ent)
		while (a-- > 1 && !ent)
			if (g_pbstatus[a] == 2)
				ent = g_pbstatus[a] = g_paintballs[a];

	if (pev_valid(ent) && is_user_alive(id))
	{
		new Float:vangles[3], Float:nvelocity[3], Float:voriginf[3], vorigin[3], clr;
		set_pev(ent, pev_owner, id);
		
		new my_pbgun = user_has_pbgun(id);
		
		if (my_pbgun != PB_LAUNCHER) { //create a pellet
			set_pev(ent, pev_classname, "pbBullet");
			engfunc(EngFunc_SetModel, ent, "models/w_paintball.mdl");
			
			
			if (my_pbgun == PB_SHOTGUN) //make them smaller to avoid creation collisions
				engfunc(EngFunc_SetSize, ent, Float:{0.0, 0.0, 0.0}, Float:{1.0, 1.0, 1.0});
			else
				engfunc(EngFunc_SetSize, ent, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0});
	
			switch (get_pcvar_num(color))
			{
				case 2: clr = (get_user_team(id) == 1) ? 0 : 1;
				case 3: clr = (get_user_team(id) == 1) ? 4 : 3;
				case 4: clr = (get_user_team(id) == 1) ? 2 : 5;
				default: clr = random_num(0, 6);
			}
			set_pev(ent, pev_skin, clr);
		
			set_pev(ent, pev_gravity, 0.5);	
		}else
		{	//create a nade
			set_pev(ent, pev_classname, "pbExplosive");
			engfunc(EngFunc_SetModel, ent, "models/w_pb_launch_he.mdl");
			engfunc(EngFunc_SetSize, ent, Float:{-3.0, -3.0, -3.0}, Float:{3.0, 3.0, 3.0});

			set_pev(ent, pev_gravity, 1.0);	
		}
		get_user_origin(id, vorigin, 1);
		
		if (my_pbgun == PB_SHOTGUN)
		{ //avoid creation collisions
			vorigin[0] += random(5)-2;
			vorigin[1] += random(5)-2;
			vorigin[2] += num*5
		}
		IVecFVec(vorigin, voriginf);
		engfunc(EngFunc_SetOrigin, ent, voriginf);

		vangles[0] = random_float(-180.0, 180.0);
		vangles[1] = random_float(-180.0, 180.0);
		set_pev(ent, pev_angles, vangles);

		pev(id, pev_v_angle, vangles);
		set_pev(ent, pev_v_angle, vangles);
		pev(id, pev_view_ofs, vangles);
		set_pev(ent, pev_view_ofs, vangles);

		new veloc;
		
		if (get_pcvar_num(gravity))
			set_pev(ent, pev_movetype, MOVETYPE_BOUNCE);
		else
			set_pev(ent, pev_movetype, MOVETYPE_FLY);
		set_pev(ent, pev_solid, 2);
	

		//Different guns shoot at different speeds
		switch (my_pbgun)
			{
				case PB_MARKER: veloc = get_pcvar_num(speed_marker);
				case PB_GLOCK: veloc = get_pcvar_num(speed_pistol);
				case PB_USP: veloc = get_pcvar_num(speed_pistol);
				case PB_SNIPER: veloc = get_pcvar_num(speed_sniper);
				case PB_LAUNCHER: veloc = get_pcvar_num(speed_launcher);
				case PB_SHOTGUN: veloc = get_pcvar_num(speed_shotgun);
				case PB_SUPERMARKER: veloc = get_pcvar_num(speed_smarker);
				default: veloc = get_pcvar_num(speed_pistol);
			}
		
		velocity_by_aim(id, veloc, nvelocity);
		
		//Fix aim for bots
		if (is_user_bot(id))
			switch (my_pbgun)
			{
				case PB_MARKER: nvelocity[2] += (get_pcvar_num(gravity))? 150 : 0;
				case PB_GLOCK: nvelocity[2] += (get_pcvar_num(gravity))? 200 : 0;
				case PB_USP: nvelocity[2] += (get_pcvar_num(gravity))? 200 : 0;
				case PB_SNIPER: nvelocity[2] += (get_pcvar_num(gravity))? 35 : 0;
				case PB_LAUNCHER: nvelocity[2] += 250;
				case PB_SHOTGUN: nvelocity[2] += (get_pcvar_num(gravity))? 50 : 0;
				case PB_SUPERMARKER: nvelocity[2] += (get_pcvar_num(gravity))? 100 : 0;
				default: nvelocity[2] += (get_pcvar_num(gravity))? 150 : 0;
			}
		
		//Recoil!!!
		if (cs_get_user_zoom(id)== CS_SET_NO_ZOOM){
			//the sniper will shoot terribly bad without a scope
			new modifier = (my_pbgun != PB_SNIPER)? 1 : 5;
			
			new buttons = pev(id, pev_button);
			
			if (my_pbgun == PB_SHOTGUN)
				modifier = 2;
			else   //shoot worse while moving
				if (buttons & IN_JUMP || buttons & IN_FORWARD || buttons & IN_BACK || buttons & IN_MOVELEFT || buttons & IN_MOVERIGHT)
					modifier *= 2;
			
			new disp = get_pcvar_num(dispersion);
			nvelocity[0] += (random(disp)-disp/2) * modifier;
			nvelocity[1] += (random(disp)-disp/2) * modifier;
			nvelocity[2] += (random(disp)-disp/2) * modifier;
		}		
		
		set_pev(ent, pev_velocity, nvelocity);
		set_pev(ent, pev_effects, pev(ent, pev_effects) & ~EF_NODRAW);
		
		//glow
		set_task(0.1, "paint_glow", ent);
		
		if (my_pbgun != PB_LAUNCHER) //make it dissapear after a while
			set_task(15.0 , "paint_reset", ent+TASK_PB_RESET);
		else  //make it explode if there is no impact
			set_task(2.0, "time_explode", ent+TASK_PB_RESET);
	}

	return ent;
}

public fw_touch(bullet, ent)
{
	new class[20];
	pev(bullet, pev_classname, class, 19);

	if (!equali(class, "pbBullet")&&!equali(class, "pbHarmlessBullet")&&!equali(class, "pbExplosive"))
		return FMRES_IGNORED;

	new owner = pev(bullet, pev_owner);

	new Float:origin[3], class2[20], is_ent_alive = is_user_alive(ent);
	pev(ent, pev_classname, class2, 19);
	pev(bullet, pev_origin, origin);

	
	if (equali(class, "pbExplosive")){ //it is a nade
		new Float:gametime = get_gametime();
		
		//if it hits something after this time, explode
		if (gametime-lastshot[owner] > 0.5){			
			act_explode(bullet);
			
			set_pev(bullet, pev_velocity, Float:{0.0, 0.0, 0.0});
			set_pev(bullet, pev_classname, "pbPaint");
			set_pev(bullet, pev_solid, 0);
			set_pev(bullet, pev_movetype, 0);
			engfunc(EngFunc_SetModel, bullet, "sprites/paintball.spr");	
			
			new a, findpb = 0;
			while (a++ < g_pbcount && !findpb)
				if (g_paintballs[a] == bullet)
					findpb = g_pbstatus[a] = 2;
			remove_task(bullet);
			remove_task(bullet+TASK_PB_RESET);
			paint_reset(bullet+TASK_PB_RESET);
			return FMRES_HANDLED; 
		}
		else if (!equali(class2, "pbBullet")&&!equali(class2, "pbHarmlessBullet")&&get_pcvar_num(gravity)){
			
			//make it bounce and loose some velocity
			new Float:vel[3];
			pev(bullet,pev_velocity,vel);

			vel[0] /= 5.0;
			vel[1] /= 5.0;
			vel[2] /= 5.0;
			
			set_pev(bullet, pev_velocity, vel);
			
			if (!is_ent_alive) //make damage to world stuff
				ExecuteHam(Ham_TakeDamage, ent, owner, owner, get_pcvar_float(damage), 4098);
	
			
			return FMRES_IGNORED;
		}
	}

	//The bullet hits or bounces
	new hit;
	hit = random(5);

	if (is_ent_alive) //make damage
	{ 
		if (owner == ent || pev(ent, pev_takedamage) == DAMAGE_NO)
			return FMRES_IGNORED;
		if (get_user_team(owner) == get_user_team(ent))
			if (!get_pcvar_num(friendlyfire))
				return FMRES_IGNORED;

		if (hit != 0 && !equali(class, "pbHarmlessBullet"))
			ExecuteHam(Ham_TakeDamage, ent, owner, owner, get_pcvar_float(damage), 4098);
	}

	if (!equali(class2, "pbBullet")&&!equali(class2, "pbHarmlessBullet"))
		if (hit != 0 || !get_pcvar_num(pellets_real))
		{	//stop the pellet and make a splat
			set_pev(bullet, pev_velocity, Float:{0.0, 0.0, 0.0});
			set_pev(bullet, pev_classname, "pbPaint");
			set_pev(bullet, pev_solid, 0);
			set_pev(bullet, pev_movetype, 0);
			engfunc(EngFunc_SetModel, bullet, "sprites/paintball.spr");
	
			new a, findpb = 0;
			while (a++ < g_pbcount && !findpb)
				if (g_paintballs[a] == bullet)
					findpb = g_pbstatus[a] = 2;
	
			remove_task(bullet);
			remove_task(bullet+TASK_PB_RESET);
	
			if (get_pcvar_num(sound))
			{
				static wav[20];
				formatex(wav, 20, is_ent_alive ? "player/pl_pain%d.wav" : "misc/pb%d.wav", is_ent_alive ? random_num(4,7) : random_num(1,4));
				emit_sound(bullet, CHAN_AUTO, wav, 1.0, ATTN_NORM, 0, PITCH_NORM);
			}
	
			new bool:valid_surface = (is_ent_alive || containi(class2, "door") != -1) ? false : true;
			if (pev(ent, pev_health) && !is_ent_alive)
			{
				ExecuteHam(Ham_TakeDamage, ent, owner, owner, float(pev(ent, pev_health)), 0);
				valid_surface = false;
			}
			if (valid_surface)
			{
				paint_splat(bullet);
				set_task(float(get_pcvar_num(blife)), "paint_reset", bullet+TASK_PB_RESET);
			}
			else
				paint_reset(bullet+TASK_PB_RESET);
	
			return FMRES_HANDLED; 
		}else
		{	//the pellet bounces, reduce its speed
			if (get_pcvar_num(gravity)){
				new Float:vel[3];
				pev(bullet,pev_velocity,vel);
				
				vel[0] /= 10.0;
				vel[1] /= 10.0;
				vel[2] /= 10.0;
				set_pev(bullet, pev_velocity, vel);
			}
			//A bullet that bounces becomes harmless to players
			set_pev(bullet, pev_classname, "pbHarmlessBullet");
			return FMRES_IGNORED;
		}
	/*else
	{
		paint_reset(bullet+TASK_PB_RESET);
		return FMRES_HANDLED;
	}
	*/	

	return FMRES_IGNORED;
}

//for the super launcher
public fw_think(ent)
{
	new model[35];
	pev(ent, pev_model, model, 34);

	if (!equali(model, "models/w_pb_supernade.mdl"))
		return FMRES_IGNORED;

	if(!is_user_alive(pev(ent, pev_owner)))
		return FMRES_IGNORED;
		
	set_task(1.6, "act_superboom", ent);
		
	return FMRES_SUPERCEDE;
}

public act_superboom(ent)
{
	for (new a = 0; a < 10; a++)
		set_task(0.1 + a*0.2, "launch_nade", ent + TASK_NADE);	
	
	set_task(2.5, "remove_nade", ent + TASK_NADE);	
		
}

public remove_nade(ent)
{
	remove_task (ent)
	ent -= TASK_NADE
	act_explode(ent);
	engfunc(EngFunc_RemoveEntity, ent);
	
}

public launch_nade(param)
{
	new spawnent = param - TASK_NADE
	
	new a, ent;
	while (a++ < g_pbcount - 1 && !ent)
		if (g_pbstatus[a] == 0)
			ent = g_pbstatus[a] = g_paintballs[a];
	if (!ent)
		while (a-- > 1 && !ent)
			if (g_pbstatus[a] == 2)
				ent = g_pbstatus[a] = g_paintballs[a];

	if (pev_valid(ent)&&pev_valid(spawnent))
	{
		new Float:nvelocity[3], vorigin[3];
		set_pev(ent, pev_owner, pev(spawnent, pev_owner));
		
		//create a nade
		set_pev(ent, pev_classname, "pbExplosive");
		engfunc(EngFunc_SetModel, ent, "models/w_pb_launch_he.mdl");
		engfunc(EngFunc_SetSize, ent, Float:{-3.0, -3.0, -3.0}, Float:{3.0, 3.0, 3.0});

		set_pev(ent, pev_gravity, 1.0);	

		pev(spawnent,pev_origin, vorigin)
		vorigin[2] += 30
		set_pev(ent, pev_origin, vorigin)
		
		//IVecFVec(vorigin, voriginf);
		//engfunc(EngFunc_SetOrigin, ent, vorigin);

		set_pev(ent, pev_movetype, MOVETYPE_BOUNCE);
		
		set_pev(ent, pev_solid, 2);
			
		nvelocity[0] = random_float(-200.0, 200.0);
		nvelocity[1] = random_float(-200.0, 200.0);
		nvelocity[2] = 500.0;	

		set_pev(ent, pev_velocity, nvelocity);
		set_pev(ent, pev_effects, pev(ent, pev_effects) & ~EF_NODRAW);
		
		set_task(2.0, "time_explode", ent+TASK_PB_RESET);
	}

	return ent;
}


public act_explode(ent)
{
	new origin[3], Float:forigin[3], colors[4], owner = pev(ent, pev_owner), user_team = get_user_team(owner);

	colors = (user_team == 1) ? { 255, 0, 247, 70} : { 0, 255, 208, 30};
	pev(ent, pev_origin, forigin);
	FVecIVec(forigin, origin);

	new id, Float:distance = 150.0, Float:porigin[3];
	
	new MaxPlayers = get_maxplayers();

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(TE_BLOODSPRITE);
	write_coord(origin[0]);
	write_coord(origin[1]);
	write_coord(origin[2] + 20);
	write_short(blood2);
	write_short(blood1);
	write_byte(colors[2]);
	write_byte(30);
	message_end();
	
	while (id++ < MaxPlayers)
		if (is_user_alive(id))
		{
			pev(id, pev_origin, porigin);
			if (get_distance_f(forigin, porigin) <= distance)
				if (fm_is_visible(ent, id))
					ExecuteHam(Ham_TakeDamage, id, owner, owner, (user_team != get_user_team(id)) ? 100.0 : 300.0, 4098);
		}

	emit_sound(ent, CHAN_AUTO, "weapons/sg_explode.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);

	set_pev(ent, pev_classname, "pbHarmlessBullet");

}

stock bool:fm_is_visible(ent, target)
{
	if (pev_valid(ent) && pev_valid(target))
	{
		new Float:start[3], Float:view_ofs[3], Float:point[3];
		pev(ent, pev_origin, start);
		pev(ent, pev_view_ofs, view_ofs);
		pev(target, pev_origin, point);
		start[0] += view_ofs[0];
		start[1] += view_ofs[1];
		start[2] += view_ofs[2];
		engfunc(EngFunc_TraceLine, start, point, 1, ent, 0);
		new Float:fraction;
		get_tr2(0, TR_flFraction, fraction);
		if (fraction == 1.0)
			return true;
	}
	return false;
}

public paint_splat(ent)
{
	new Float:origin[3], Float:norigin[3], Float:viewofs[3], Float:angles[3], Float:normal[3], Float:aiming[3];
	pev(ent, pev_origin, origin);
	pev(ent, pev_view_ofs, viewofs);
	pev(ent, pev_v_angle, angles);

	norigin[0] = origin[0] + viewofs[0];
	norigin[1] = origin[1] + viewofs[1];
	norigin[2] = origin[2] + viewofs[2];
	aiming[0] = norigin[0] + floatcos(angles[1], degrees) * 1000.0;
	aiming[1] = norigin[1] + floatsin(angles[1], degrees) * 1000.0;
	aiming[2] = norigin[2] + floatsin(-angles[0], degrees) * 1000.0;
	
	new tr = 0
	engfunc(EngFunc_TraceLine, norigin, aiming, 0, ent, tr);
	//get_tr2(tr, TR_vecPlaneNormal, normal);
	//EngFunc_TraceHull,(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
	//engfunc(EngFunc_TraceHull, norigin, aiming, 0, HULL_LARGE, ent, tr)
	get_tr2(tr, TR_vecPlaneNormal, normal)

	
	vector_to_angle(normal, angles);
	angles[1] += 180.0;
	if (angles[1] >= 360.0) angles[1] -= 360.0;	
	
	set_pev(ent, pev_angles, angles);
	set_pev(ent, pev_v_angle, angles);

	origin[0] += (normal[0] * random_float(0.3, 2.7));
	origin[1] += (normal[1] * random_float(0.3, 2.7));
	origin[2] += (normal[2] * random_float(0.3, 2.7));
	engfunc(EngFunc_SetOrigin, ent, origin);
	set_pev(ent, pev_frame, float(random_num( (pev(ent, pev_skin) * 18), (pev(ent, pev_skin) * 18) + 17 ) ));

	if (pev(ent, pev_renderfx) != kRenderFxNone)
		set_rendering(ent);	

}

public paint_glow(ent)
{
	if (pev_valid(ent))
	{
		static pbglow[5], clr[3];
		get_pcvar_string(bglow, pbglow, 4);
		switch (get_pcvar_num(color))
		{
			case 2: clr = (get_user_team(pev(ent, pev_owner))==1) ? {255, 0, 0} : {0, 0, 255};
			default: clr = {255, 255, 255};
		}
		if (read_flags(pbglow) & (1 << 0))
			set_rendering(ent, kRenderFxGlowShell, clr[0], clr[1], clr[2], kRenderNormal, 255);
		if (read_flags(pbglow) & (1 << 1))
		{
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_BEAMFOLLOW);
			write_short(ent);
			write_short(beamspr);
			write_byte(4);
			write_byte(2);
			write_byte(clr[0]);
			write_byte(clr[1]);
			write_byte(clr[2]);
			write_byte(255);
			message_end();
		}
	}
}

public paint_reset(ent)
{
	remove_task(ent);
	ent -= TASK_PB_RESET;
	new a, findpb = 1;
	while (a++ <= g_pbcount && findpb)
		if (g_paintballs[a] == ent)
			findpb = g_pbstatus[a] = 0;

	set_pev(ent, pev_effects, pev(ent, pev_effects) | EF_NODRAW);
	engfunc(EngFunc_SetSize, ent, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0});
	set_pev(ent, pev_velocity, Float:{0.0, 0.0, 0.0});
	engfunc(EngFunc_SetOrigin, ent, Float:{-2000.0, -2000.0, -2000.0});
	if (pev(ent, pev_renderfx) != kRenderFxNone)
		set_rendering(ent);
}

public time_explode(ent)
{
	remove_task(ent);
	ent -= TASK_PB_RESET;
	if (!pev_valid(ent))
		return;
	act_explode(ent);

	set_pev(ent, pev_velocity, Float:{0.0, 0.0, 0.0});
	set_pev(ent, pev_classname, "pbPaint");
	set_pev(ent, pev_solid, 0);
	set_pev(ent, pev_movetype, 0);
	engfunc(EngFunc_SetModel, ent, "sprites/paintball.spr");	
	
	new a, findpb = 0;
	while (a++ < g_pbcount && !findpb)
		if (g_paintballs[a] == ent)
			findpb = g_pbstatus[a] = 2;
	remove_task(ent);
	paint_reset(ent+TASK_PB_RESET);
}


public ev_roundstart()
{
	for (new a = 1; a <= g_pbcount; a++)
		if (g_pbstatus[a] != 0)
			paint_reset(g_paintballs[a]+TASK_PB_RESET);
	if (freezetime)
		freezetime = 0;

}

public ev_freezetime()
	freezetime = 1;

stock user_has_pbgun(id)
{
	new retval;
	
	if (is_user_alive(id))
	{
		switch(get_user_weapon(id))
		{ 
		case CSW_MP5NAVY: 	retval = PB_MARKER;	
		case CSW_USP: 		retval = PB_USP;
		case CSW_GLOCK18: 	retval = PB_GLOCK;
		case CSW_SCOUT: 	retval = PB_SNIPER;
		case CSW_M3: 		retval = PB_LAUNCHER;
		case CSW_XM1014: 	retval = PB_SHOTGUN;
		case CSW_P90: 		retval = PB_SUPERMARKER;
		default: 		retval = 0;
		} 
			
	}
	return retval;
}


stock set_user_clip(id, ammo)
{
	new weaponname[32], weaponid = -1, weapon = get_user_weapon(id, _, _);
	get_weaponname(weapon, weaponname, 31);
	while ((weaponid = engfunc(EngFunc_FindEntityByString, weaponid, "classname", weaponname)) != 0)
		if (pev(weaponid, pev_owner) == id) {
			set_pdata_int(weaponid, 51, ammo, 4);
			return weaponid;
		}
	return 0;
}

// teame06's function
stock set_rendering(index, fx=kRenderFxNone, r=0, g=0, b=0, 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));
}

     
public fwd_TakeDamage ( id, i_Inflictor, i_Attacker, Float:f_Damage, i_DamageBits )
    {
	if (!is_user_alive(i_Attacker))
		return PLUGIN_CONTINUE;
    
	if ( get_user_weapon(i_Attacker) == CSW_KNIFE && get_pcvar_num(knife_ohk))
        {
            ExecuteHam(Ham_TakeDamage, id, i_Attacker, i_Attacker, 101.0, 4098);
        }

	return PLUGIN_CONTINUE;
    }

public weapon_jam(id, uc_handle)
{
	if (get_pcvar_num(jamon))
	{
		// show messages	
		set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)
		show_hudmessage(id, "Zaciela Ci sie bron - kliknij klawisz domyslnie (e)")
	
		// block the attack button 
		static buttons; buttons = get_uc( uc_handle, UC_Buttons )
		set_uc (uc_handle, UC_Buttons, buttons & ~IN_ATTACK);
	}
}

public clear_chamber(id)
{
	if (get_pcvar_num(jamon))
	{
		g_Jammed[id] = false;
		emit_sound(id,CHAN_AUTO,"weapons/scout_bolt.wav",1.0,ATTN_NORM,0,PITCH_NORM);
		
		// show messages 
		set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 3.0, 12.0);
		show_hudmessage(id, "wyczysc");
	}
}


public make_solid(ent)
{
	remove_task(ent);
	ent -= TASK_PB_RESET;
	if (!pev_valid(ent))
		return;
	set_pev(ent, pev_solid, 2);
	if (get_pcvar_num(gravity))
		set_pev(ent, pev_movetype, MOVETYPE_BOUNCE);
}

stock is_rpaintball_active()
{
	if(!cvar_exists("amx_pbmod"))
	{
		log_amx("Cvar: ^"amx_pbmod^" does not exist.")
		return 0
	}
	return get_cvar_num("amx_pbmod")
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
*/


  • +
  • -
  • 1




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych