Raised This Month: $ Target: $400
 0% 

random weapons on spawn


Post New Thread Reply   
 
Thread Tools Display Modes
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
VEN
Veteran Member
Join Date: Jan 2005
Old 11-24-2006 , 03:22   Re: random weapons on spawn
Reply With Quote #2

Don't strip/give weapons on HUD reset - it's bad.
VEN is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-24-2006 , 03:31   Re: random weapons on spawn
Reply With Quote #3

Code:
  new its_bad = crashing servers horably
The Specialist is offline
Send a message via AIM to The Specialist
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 11-24-2006 , 12:40   Re: random weapons on spawn
Reply With Quote #4

so what should i change it to, even on Hudreset, the function does not get called because there is a server commands that psays to anthrax
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 11-24-2006 , 12:51   Re: random weapons on spawn
Reply With Quote #5

You have to wait a bit after HUD reset. Your psay command does not get a call because the the HUD reset hook function interrupts with error on strip/give.
VEN is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 11-24-2006 , 17:19   Re: random weapons on spawn
Reply With Quote #6

the strip/give does not get called iether
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 11-25-2006 , 17:22   Re: random weapons on spawn
Reply With Quote #7

Code:
#include <amxmodx> #include <fun> #define plugin "Random Weapons" #define version "0.1" #define author "Doombringer" new cvar new primary_weapon[32] new secondary_weapon[32] public plugin_init() {     register_plugin(plugin, version, author)     register_event("ResetHUD", "hook_resethud", "be")         cvar = register_cvar("RW_enabled","1") }   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 } public give_things(id) {     if(get_pcvar_num(cvar) < 1)     return PLUGIN_CONTINUE         new weapon[2][21]     new ammo_type[21], a         strip_user_weapons(id)          give_item(id, "weapon_knife")         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])                 randomize_secondary(id)                     get_weaponname(secondary_weapon[id], weapon[1], 20)                 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,"You got a %s as secondary weapon",weapon[1][7])        return PLUGIN_CONTINUE }     public hook_resethud(id) {     set_task(0.3,"give_things", id)     return PLUGIN_CONTINUE } stock get_ammotype(weapon) {     new ammo         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 }

Last edited by Deviance; 11-26-2006 at 15:29.
Deviance is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-25-2006 , 22:50   Re: random weapons on spawn
Reply With Quote #8

Code:
    new ammo[21]
    
    switch(weapon)
    {
        case CSW_P228: ammo = "ammo_357sig"
        case CSW_SCOUT: ammo = "ammo_762nato"
        //etc...
won't work/is very bad. use the following
Code:
case CSW_P228: copy(ammo, 20, "ammo_357sig")
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 11-26-2006 , 06:34   Re: random weapons on spawn
Reply With Quote #9

Quote:
Originally Posted by Emp` View Post
Code:
    new ammo[21]
    
    switch(weapon)
    {
        case CSW_P228: ammo = "ammo_357sig"
        case CSW_SCOUT: ammo = "ammo_762nato"
        //etc...
won't work/is very bad. use the following
Code:
case CSW_P228: copy(ammo, 20, "ammo_357sig")
umm.
Quote:
Originally Posted by VEN
For get_ammotype you don't really need to perform a copy every time, it's inefficient.
Deviance is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-26-2006 , 14:32   Re: random weapons on spawn
Reply With Quote #10

but that is not how you fill a string...
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Reply



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