Junior Member
|
03-14-2012
, 15:08
Re: Random Weapons, UPDATE 31-07-2006
|
#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;
}
__________________
|
|