Raised This Month: $73 Target: $400
 18% 

Random Weapons, UPDATE 31-07-2006


Post New Thread Reply   
 
Thread Tools Display Modes
Meathead~MBG~
Junior Member
Join Date: Mar 2009
Old 03-14-2012 , 15:08   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #31

Trying to convert this to dod, no errors but not working.

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

#define PLUGIN "Random Weapons"
#define VERSION "0.1"
#define AUTHOR "Meathead"
// Original CS code by doombringer
#define TIME_AFTER_SPAWN 0.0
#define MAX_PLAYERS 32

new bool:g_restart_attempt[MAX_PLAYERS + 1]
new cvar, mode;
new primary_weapon[32] ,secondary_weapon[32];
new g_Msg[3][] = { "", "You got a %s as secondary weapon", "You got a %s as primary weapon" }
	
public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR );
	
	register_event( "ResetHUD", "event_resethud", "be" );
	register_clcmd( "fullupdate", "clcmd_fullupdate" );
	register_event( "TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in" );
	
	cvar = register_cvar( "RW_enabled", "1" );
	mode = register_cvar( "RW_mode", "2" );
}	


public randomize_primary( id )
{	
	new rand = random_num( 1, 24 )
	
	switch( rand )
	{				
		case 1	: primary_weapon[id] = DODW_GARAND;
		case 2	: primary_weapon[id] = DODW_SCOPED_KAR;
		case 3	: primary_weapon[id] = DODW_THOMPSON;
		case 4	: primary_weapon[id] = DODW_STG44;	
		case 5	: primary_weapon[id] = DODW_SPRINGFIELD;
		case 6	: primary_weapon[id] = DODW_KAR;	
		case 7	: primary_weapon[id] = DODW_BAR;
		case 8	: primary_weapon[id] = DODW_MP40;    
		case 9	: primary_weapon[id] = DODW_MG42;	
		case 10	: primary_weapon[id] = DODW_30_CAL;
		case 11	: primary_weapon[id] = DODW_M1_CARBINE;
		case 12	: primary_weapon[id] = DODW_MG34;
		case 13	: primary_weapon[id] = DODW_GREASEGUN;
		case 14	: primary_weapon[id] = DODW_FG42;
		case 15	: primary_weapon[id] = DODW_K43;
		case 16	: primary_weapon[id] = DODW_ENFIELD;
		case 17	: primary_weapon[id] = DODW_STEN;
		case 18	: primary_weapon[id] = DODW_BREN;
		case 19	: primary_weapon[id] = DODW_BAZOOKA;
		case 20	: primary_weapon[id] = DODW_PANZERSCHRECK;
		case 21	: primary_weapon[id] = DODW_PIAT;
		case 22	: primary_weapon[id] = DODW_SCOPED_FG42;
		case 23	: primary_weapon[id] = DODW_FOLDING_CARBINE;
		case 24	: primary_weapon[id] = DODW_SCOPED_ENFIELD;
	}
}

public randomize_secondary( id )
{
	new rand = random_num( 1,3 )
	
	switch( rand )
	{
		case 1: secondary_weapon[id] = DODW_COLT;
		case 2: secondary_weapon[id] = DODW_LUGER;
		case 3: secondary_weapon[id] = DODW_WEBLEY;
		
	}
}

public clcmd_fullupdate( ) 
{
	return PLUGIN_HANDLED_MAIN;
}

public event_restart_attempt( ) 
{
	new players[32], num;
	get_players( players, num, "a" );
	
	for( new i; i < num; ++i )
		g_restart_attempt[players[i]] = true;
}

public event_resethud( id ) 
{
	if ( g_restart_attempt[id] ) 
	{
		g_restart_attempt[id] = false;
		return;
	}
	event_player_spawn( id );
}

public give_things( id ) 
{
	if( get_pcvar_num( cvar ) < 1 )
		return;
	
	new weapon[2][27], ammo_type[27], a;
	
	switch( get_pcvar_num( mode ) )
	{
		case 0:
		{
			randomize_secondary( id )
			get_weaponname( secondary_weapon[id], weapon[1], 26 )
			give_item( id, weapon[1] )				
			ammo_type = get_ammotype( secondary_weapon[id] )
			
			for( a = 0; a < 5; a++ )
				give_item( id, ammo_type )
				
			client_print( id, print_chat, g_Msg[1] ,weapon[1][7] )
		}
			
		case 1:
		{
			randomize_primary( id )
			get_weaponname( primary_weapon[id], weapon[0], 26 )
			give_item( id, weapon[0] )
			ammo_type = get_ammotype( primary_weapon[id] )				
				
			for( a = 0; a < 5; a++) 
				give_item( id, ammo_type )				
				
			client_print( id, print_chat, g_Msg[2], weapon[0][7] )
		}
			
		case 2:
		{
			randomize_primary( id )
			get_weaponname( primary_weapon[id], weapon[0], 26 )				
			give_item( id, weapon[0] )
			ammo_type = get_ammotype( primary_weapon[id] )
			
			for( a = 0; a < 5; a++ )
				give_item( id, ammo_type )
				
			client_print( id, print_chat, g_Msg[2], weapon[0][7])	

			randomize_secondary( id )			
			get_weaponname( secondary_weapon[id], weapon[1], 26 )				
			give_item( id, weapon[1] )				
			ammo_type = get_ammotype(secondary_weapon[id] )
				
			for(a = 0; a < 5; a++)
				give_item(id, ammo_type)
				
			client_print( id, print_chat, g_Msg[1], weapon[1][7] )
		}
	}
}

public strip_weapons( id )
{
if(user_has_weapon(id, DODW_COLT))
   {
    ham_strip_weapon(id, "weapon_colt");
    ham_strip_weapon(id, "weapon_garand");
    ham_strip_weapon(id, "weapon_thompson");
    ham_strip_weapon(id, "weapon_spring");
    ham_strip_weapon(id, "weapon_bar");
    ham_strip_weapon(id, "weapon_30cal"); 
    ham_strip_weapon(id, "weapon_m1carbine");
    ham_strip_weapon(id, "weapon_greasegun");
    ham_strip_weapon(id, "weapon_bazooka");
    ham_strip_weapon(id, "weapon_luger");
    ham_strip_weapon(id, "weapon_scopedkar");
    ham_strip_weapon(id, "weapon_mp44");
    ham_strip_weapon(id, "weapon_kar");
    ham_strip_weapon(id, "weapon_mp40");
    ham_strip_weapon(id, "weapon_mg42");
    ham_strip_weapon(id, "weapon_mg34");
    ham_strip_weapon(id, "weapon_fg42");
    ham_strip_weapon(id, "weapon_k43");
    ham_strip_weapon(id, "weapon_tmp");
    ham_strip_weapon(id, "weapon_enfield");
    ham_strip_weapon(id, "weapon_sten");
    ham_strip_weapon(id, "weapon_bren");
    ham_strip_weapon(id, "weapon_webley");
    ham_strip_weapon(id, "weapon_pschreck");
    ham_strip_weapon(id, "weapon_piat");
    give_things( id );
    }
if(user_has_weapon(id, DODW_LUGER))
    {
    ham_strip_weapon(id, "weapon_colt");
    ham_strip_weapon(id, "weapon_garand");
    ham_strip_weapon(id, "weapon_thompson");
    ham_strip_weapon(id, "weapon_spring");
    ham_strip_weapon(id, "weapon_bar");
    ham_strip_weapon(id, "weapon_30cal"); 
    ham_strip_weapon(id, "weapon_m1carbine");
    ham_strip_weapon(id, "weapon_greasegun");
    ham_strip_weapon(id, "weapon_bazooka");
    ham_strip_weapon(id, "weapon_luger");
    ham_strip_weapon(id, "weapon_scopedkar");
    ham_strip_weapon(id, "weapon_mp44");
    ham_strip_weapon(id, "weapon_kar");
    ham_strip_weapon(id, "weapon_mp40");
    ham_strip_weapon(id, "weapon_mg42");
    ham_strip_weapon(id, "weapon_mg34");
    ham_strip_weapon(id, "weapon_fg42");
    ham_strip_weapon(id, "weapon_k43");
    ham_strip_weapon(id, "weapon_tmp");
    ham_strip_weapon(id, "weapon_enfield");
    ham_strip_weapon(id, "weapon_sten");
    ham_strip_weapon(id, "weapon_bren");
    ham_strip_weapon(id, "weapon_webley");
    ham_strip_weapon(id, "weapon_pschreck");
    ham_strip_weapon(id, "weapon_piat");
    give_things( id );
    }
    if(user_has_weapon(id, DODW_WEBLEY))
    {
    ham_strip_weapon(id, "weapon_colt");
    ham_strip_weapon(id, "weapon_garand");
    ham_strip_weapon(id, "weapon_thompson");
    ham_strip_weapon(id, "weapon_spring");
    ham_strip_weapon(id, "weapon_bar");
    ham_strip_weapon(id, "weapon_30cal"); 
    ham_strip_weapon(id, "weapon_m1carbine");
    ham_strip_weapon(id, "weapon_greasegun");
    ham_strip_weapon(id, "weapon_bazooka");
    ham_strip_weapon(id, "weapon_luger");
    ham_strip_weapon(id, "weapon_scopedkar");
    ham_strip_weapon(id, "weapon_mp44");
    ham_strip_weapon(id, "weapon_kar");
    ham_strip_weapon(id, "weapon_mp40");
    ham_strip_weapon(id, "weapon_mg42");
    ham_strip_weapon(id, "weapon_mg34");
    ham_strip_weapon(id, "weapon_fg42");
    ham_strip_weapon(id, "weapon_k43");
    ham_strip_weapon(id, "weapon_tmp");
    ham_strip_weapon(id, "weapon_enfield");
    ham_strip_weapon(id, "weapon_sten");
    ham_strip_weapon(id, "weapon_bren");
    ham_strip_weapon(id, "weapon_webley");
    ham_strip_weapon(id, "weapon_pschreck");
    ham_strip_weapon(id, "weapon_piat");
    give_things( id );
    }
}


public event_player_spawn( id )
{
	set_task( TIME_AFTER_SPAWN, "strip_weapons", id );
}

stock ham_strip_weapon(id,weapon[])
{  
    if(!equal(weapon,"weapon_",7)) return 0;

    new wId = get_weaponid(weapon);
    if(!wId) return 0;

    new wEnt = fm_find_ent_by_owner(1,weapon,id);
    if(!wEnt) return 0;
    
    new dummy, weapon = get_user_weapon(id,dummy,dummy);
    if(weapon == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
    
    if(!ExecuteHamB(Ham_RemovePlayerItem,id,any:wEnt)) return 0;
    ExecuteHamB(Ham_Item_Kill,wEnt);

    set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
    return 1;
}

stock get_ammotype(weapon)
{
	new ammo[27];
	
	switch( weapon )
	{
		case DODW_COLT				: ammo = "AMMO_PISTOL";
		case DODW_LUGER				: ammo = "AMMO_PISTOL";
		case DODW_GARAND			: ammo = "AMMO_RIFLE";
		case DODW_SCOPED_KAR		: ammo = "AMMO_RIFLE";
		case DODW_THOMPSON			: ammo = "AMMO_SMG";
		case DODW_STG44				: ammo = "AMMO_HEAVY";
		case DODW_SPRINGFIELD		: ammo = "AMMO_SPRING";
		case DODW_KAR				: ammo = "AMMO_RIFLE";
		case DODW_BAR				: ammo = "AMMO_HEAVY";
		case DODW_MP40				: ammo = "AMMO_SMG";
		case DODW_MG42				: ammo = "AMMO_MG42";
		case DODW_30_CAL			: ammo = "AMMO_30CAL";
		case DODW_M1_CARBINE		: ammo = "AMMO_ALTRIFLE";
		case DODW_MG34				: ammo = "AMMO_ALTRIFLE";
		case DODW_GREASEGUN			: ammo = "AMMO_SMG";
		case DODW_FG42				: ammo = "AMMO_HEAVY";
		case DODW_K43				: ammo = "AMMO_ALTRIFLE";
		case DODW_ENFIELD			: ammo = "AMMO_RIFLE";
		case DODW_STEN				: ammo = "AMMO_SMG";
		case DODW_BREN				: ammo = "AMMO_HEAVY";
		case DODW_BAZOOKA			: ammo = "AMMO_ROCKET";
		case DODW_PANZERSCHRECK		: ammo = "AMMO_ROCKET";
		case DODW_PIAT				: ammo = "AMMO_ROCKET";
		case DODW_SCOPED_FG42		: ammo = "AMMO_HEAVY";
		case DODW_FOLDING_CARBINE	: ammo = "AMMO_ALTRIFLE";
		case DODW_SCOPED_ENFIELD	: ammo = "AMMO_RIFLE";
		case DODW_WEBLEY			: ammo = "AMMO_PISTOL";
		
		
	}
	
	return ammo;
}
__________________
Meathead~MBG~ is offline
alencore
Senior Member
Join Date: Oct 2011
Old 09-25-2013 , 06:50   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #32

Is there any working version of this that works along csdm?

woops nevermind seems I forgot some few things to do make it work hehe.
works perfect now tnx!
__________________

Last edited by alencore; 09-26-2013 at 05:12.
alencore is offline
alencore
Senior Member
Join Date: Oct 2011
Old 09-27-2013 , 04:50   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #33

Wish someone could edit this and add random grenades...
__________________
alencore is offline
Lexofles
Member
Join Date: Sep 2013
Old 09-28-2013 , 07:01   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #34

Quote:
Originally Posted by alencore View Post
Wish someone could edit this and add random grenades...
totaly agree alencore , i have a zombie server and i need to disable the buy menu or i can choose a weapon after random weapon is given , so its pointless then to have it
Lexofles is offline
alencore
Senior Member
Join Date: Oct 2011
Old 09-28-2013 , 10:14   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #35

Quote:
Originally Posted by Lexofles View Post
totaly agree alencore , i have a zombie server and i need to disable the buy menu or i can choose a weapon after random weapon is given , so its pointless then to have it
Here's a nice alternative to have total control to randomize weapons you love plus nades, get the last one posted on last page...
http://forums.alliedmods.net/showthread.php?p=646639
both plugin are buggy on AS maps though.
__________________

Last edited by alencore; 09-28-2013 at 10:27.
alencore is offline
blanko
Senior Member
Join Date: Aug 2008
Location: Wodka und EnergyDrink
Old 06-05-2016 , 10:20   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #36

How STUPID can you be to forget GALIL on this? For the love of the gods, you make a plugin about the whole weapon pack and forgot a very important one? Unbelieveable!
__________________
blanko is offline
arC`
Member
Join Date: May 2005
Old 09-22-2019 , 21:15   Re: Random Weapons, UPDATE 31-07-2006
Reply With Quote #37

any chance to make this with random weps on spawn instead of newround?

edit; it's on page 2 but doesn't compile lol
edit2: there's a fixed, working version a few posts after that, thanks OP!
edit3: can't believe he forgot the galil tho heh
__________________
100 years ago

Last edited by arC`; 09-23-2019 at 11:19.
arC` is offline
Send a message via AIM to arC`
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 09:55.


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