Raised This Month: $ Target: $400
 0% 

random weapons on spawn


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 11-23-2006 , 19:56   random weapons on spawn
Reply With Quote #1

If there is a plugin that gives random weapons on spawn, tell me plz


It somehow does not work, and the servercmd does not even run


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

#define plugin "Random Weapons test"
#define version "0.1"
#define author "original from Doombringer"


#define MAX_PLAYERS 32 
new bool:g_restart_attempt[MAX_PLAYERS + 1] 
new primary_weapon[32]
new secondary_weapon[32]

public plugin_init() {   
	register_plugin(plugin, version, author)
	register_event("ResetHUD", "event_hud_reset", "be")     
	register_clcmd("fullupdate", "clcmd_fullupdate")     
	register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in") 
	} 
	
public clcmd_fullupdate() {     
	return PLUGIN_HANDLED 
} 

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_hud_reset(id) {
	if (g_restart_attempt[id]) {
		g_restart_attempt[id] = false
		return     
	}     
	
	event_player_spawn(id) 
	
} // this function is called on player spawn public 

event_player_spawn(id) {
if (get_cvar_num("sv_rw")==1){

	new weapon[2][21]
	new ammo_type[21]
	new id, a

	strip_user_weapons(id)
	randomize_secondary(id)
				
	get_weaponname(secondary_weapon[id], weapon[1], 20)
				
	give_item(id, weapon[1])
	give_item(id, "weapon_knife")			
	ammo_type = get_ammotype(secondary_weapon[id])
				
	for(a = 0; a < 5; a++)
	give_item(id, ammo_type)
				
	client_print(id, print_chat,"You got a %s as secondary weapon",weapon[1][7])
//
	randomize_primary(id)
				
	get_weaponname(primary_weapon[id], weapon[0], 20)
				
	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,"You got a %s as primary weapon",weapon[0][7])
	server_cmd("amx_psay anthrax spawn test");	
	}
}


public randomize_primary(id)
{	
	new rand = random_num(1, 17)
	
	switch(rand)
	{				
		case 1: primary_weapon[id] = CSW_SCOUT
		
		case 2: primary_weapon[id] = CSW_XM1014
		
		case 3: primary_weapon[id] = CSW_MAC10
		
		case 4: primary_weapon[id] = CSW_AUG
		
		case 5: primary_weapon[id] = CSW_UMP45
	
		case 6: primary_weapon[id] = CSW_SG550
		
		case 7: primary_weapon[id] = CSW_FAMAS
	
		case 8: primary_weapon[id] = CSW_AWP
	        
		case 9: primary_weapon[id] = CSW_MP5NAVY
		
	        case 10: primary_weapon[id] = CSW_M249
	
		case 11: primary_weapon[id] = CSW_M3
	
		case 12: primary_weapon[id] = CSW_M4A1

		case 13: primary_weapon[id] = CSW_TMP

		case 14: primary_weapon[id] = CSW_G3SG1
		
		case 15: primary_weapon[id] = CSW_SG552
		
	        case 16: primary_weapon[id] = CSW_AK47

		case 17: primary_weapon[id] = CSW_P90
	}
	
	return PLUGIN_CONTINUE
}

public randomize_secondary(id)
{
	new rand = random_num(1,6)
	
	switch(rand)
	{
		case 1: secondary_weapon[id] = CSW_GLOCK18
		
		case 2: secondary_weapon[id] = CSW_USP
		
		case 3: secondary_weapon[id] = CSW_P228
		
		case 4: secondary_weapon[id] = CSW_DEAGLE
		
		case 5: secondary_weapon[id] = CSW_FIVESEVEN
		
		case 6: secondary_weapon[id] = CSW_ELITE
	}
	
	return PLUGIN_CONTINUE
}



stock get_ammotype(weapon)
{
	new ammo[21]
	
	switch(weapon)
	{
		case CSW_P228: ammo = "ammo_357sig"
		case CSW_SCOUT: ammo = "ammo_762nato"
		case CSW_XM1014: ammo = "ammo_buckshot"
		case CSW_MAC10: ammo = "ammo_45acp"
		case CSW_AUG: ammo = "ammo_556nato"
		case CSW_ELITE: ammo = "ammo_9mm"
		case CSW_FIVESEVEN: ammo = "ammo_57mm"
		case CSW_UMP45: ammo = "ammo_45acp"
		case CSW_SG550: ammo = "ammo_556nato"
		case CSW_GALIL: ammo = "ammo_556nato"
		case CSW_FAMAS: ammo = "ammo_556nato"
		case CSW_USP: ammo = "ammo_45acp"
		case CSW_GLOCK18: ammo = "ammo_9mm"
		case CSW_AWP: ammo = "ammo_338magnum"
		case CSW_MP5NAVY: ammo = "ammo_9mm"
		case CSW_M249: ammo = "ammo_556natobox"
		case CSW_M3: ammo = "ammo_buckshot"
		case CSW_M4A1: ammo = "ammo_556nato"
		case CSW_TMP: ammo = "ammo_9mm"
		case CSW_G3SG1: ammo = "ammo_762nato"
		case CSW_DEAGLE: ammo = "ammo_50ae"
		case CSW_SG552: ammo = "ammo_556nato"
		case CSW_AK47: ammo = "ammo_762nato"
		case CSW_P90: ammo = "ammo_57mm"
	}
	
	return ammo
}
Code # 2:

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

#define plugin "Random Weapons test"
#define version "0.1"
#define author "original from Doombringer"


new primary_weapon[32]
new secondary_weapon[32]

public plugin_init()
{
	register_plugin(plugin, version, author)
	register_cvar("sv_rw","0");
	register_event("ResetHUD", "give", "e")
}

public give(id)
{
if (get_cvar_num("sv_rw")==1){

	new weapon[2][21]
	new ammo_type[21]
	new id, a

	strip_user_weapons(id)
	randomize_secondary(id)
				
	get_weaponname(secondary_weapon[id], weapon[1], 20)
				
	give_item(id, weapon[1])
	give_item(id, "weapon_knife")			
	ammo_type = get_ammotype(secondary_weapon[id])
				
	for(a = 0; a < 5; a++)
	give_item(id, ammo_type)
				
	client_print(id, print_chat,"You got a %s as secondary weapon",weapon[1][7])
//
	randomize_primary(id)
				
	get_weaponname(primary_weapon[id], weapon[0], 20)
				
	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,"You got a %s as primary weapon",weapon[0][7])
	server_cmd("amx_psay anthrax spawn test");	
	}
return PLUGIN_CONTINUE
}


public randomize_primary(id)
{	
	new rand = random_num(1, 17)
	
	switch(rand)
	{				
		case 1: primary_weapon[id] = CSW_SCOUT
		
		case 2: primary_weapon[id] = CSW_XM1014
		
		case 3: primary_weapon[id] = CSW_MAC10
		
		case 4: primary_weapon[id] = CSW_AUG
		
		case 5: primary_weapon[id] = CSW_UMP45
	
		case 6: primary_weapon[id] = CSW_SG550
		
		case 7: primary_weapon[id] = CSW_FAMAS
	
		case 8: primary_weapon[id] = CSW_AWP
	        
		case 9: primary_weapon[id] = CSW_MP5NAVY
		
	        case 10: primary_weapon[id] = CSW_M249
	
		case 11: primary_weapon[id] = CSW_M3
	
		case 12: primary_weapon[id] = CSW_M4A1

		case 13: primary_weapon[id] = CSW_TMP

		case 14: primary_weapon[id] = CSW_G3SG1
		
		case 15: primary_weapon[id] = CSW_SG552
		
	        case 16: primary_weapon[id] = CSW_AK47

		case 17: primary_weapon[id] = CSW_P90
	}
	
	return PLUGIN_CONTINUE
}

public randomize_secondary(id)
{
	new rand = random_num(1,6)
	
	switch(rand)
	{
		case 1: secondary_weapon[id] = CSW_GLOCK18
		
		case 2: secondary_weapon[id] = CSW_USP
		
		case 3: secondary_weapon[id] = CSW_P228
		
		case 4: secondary_weapon[id] = CSW_DEAGLE
		
		case 5: secondary_weapon[id] = CSW_FIVESEVEN
		
		case 6: secondary_weapon[id] = CSW_ELITE
	}
	
	return PLUGIN_CONTINUE
}



stock get_ammotype(weapon)
{
	new ammo[21]
	
	switch(weapon)
	{
		case CSW_P228: ammo = "ammo_357sig"
		case CSW_SCOUT: ammo = "ammo_762nato"
		case CSW_XM1014: ammo = "ammo_buckshot"
		case CSW_MAC10: ammo = "ammo_45acp"
		case CSW_AUG: ammo = "ammo_556nato"
		case CSW_ELITE: ammo = "ammo_9mm"
		case CSW_FIVESEVEN: ammo = "ammo_57mm"
		case CSW_UMP45: ammo = "ammo_45acp"
		case CSW_SG550: ammo = "ammo_556nato"
		case CSW_GALIL: ammo = "ammo_556nato"
		case CSW_FAMAS: ammo = "ammo_556nato"
		case CSW_USP: ammo = "ammo_45acp"
		case CSW_GLOCK18: ammo = "ammo_9mm"
		case CSW_AWP: ammo = "ammo_338magnum"
		case CSW_MP5NAVY: ammo = "ammo_9mm"
		case CSW_M249: ammo = "ammo_556natobox"
		case CSW_M3: ammo = "ammo_buckshot"
		case CSW_M4A1: ammo = "ammo_556nato"
		case CSW_TMP: ammo = "ammo_9mm"
		case CSW_G3SG1: ammo = "ammo_762nato"
		case CSW_DEAGLE: ammo = "ammo_50ae"
		case CSW_SG552: ammo = "ammo_556nato"
		case CSW_AK47: ammo = "ammo_762nato"
		case CSW_P90: ammo = "ammo_57mm"
	}
	
	return ammo
}
So what should i use, tell me whats wrong, i want the plugin to give random weapons on player spawn
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME

Last edited by kp_uparrow; 11-23-2006 at 20:16.
kp_uparrow is offline
 


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 06:50.


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