[Half-Life AMXX] / weaponarena.sma Repository:
ViewVC logotype

View of /weaponarena.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (download) (annotate)
Tue Nov 20 22:36:56 2007 UTC (13 years ago) by ian
File size: 7580 byte(s)
Applied AGPLv3 license.
/*
Weapon Arena v0.1
Copyright (C) 2005 Ian (Juan) Cammarata

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------

To do:

Auto freeze time/buy time adjustment.
Stop weapon selected multiple times in one deal of guns.
Some way to choose what guys to use.
Unlimited ammo, 2 types.

--------------------------------------------------------------------------------

http://ian.cammarata.us
For AMX 2005
5/21/2005 4:22:27 AM
--------------------------------------------------------------------------------
*/

#include <amxmod>
#include <fun>
#include <amxmisc>
#include <VexdUM_stock>
#include <cstrike>
#include <cstrike2>
#include <lib_targets>

#define EV_SZ_buying "buying"

new curwpn[17],usedwpns,lastwpn
new equipmm=0,bool:rqup=false
new bool:waon=false

public spawned(id){
	if(waon){
		set_msg_block(get_user_msgid("AmmoPickup"),2)
		set_msg_block(get_user_msgid("WeapPickup"),2)
		set_msg_block(get_user_msgid("ItemPickup"),2)
		//weaponstrip(id,1)
		new ida[1]
		ida[0]=id
		set_task(0.1,"delaystrip",_,ida,1)
		cs_set_user_money(id,0,0)
	}
	else if(rqup){
		rqup=false
		set_task(0.1,"reequip")
	}
	return PLUGIN_HANDLED
}
public delaystrip(ida[1]){
	if(waon){
		weaponstrip(ida[0],get_cvar_num("amx_wpnarena_spawn_knife")?0:1)
		if(get_cvar_num("amx_wpnarena_spawn_randwpn")){
			if(equal(curwpn,"weapon_hegrenade")){
				give_item(ida[0],curwpn)
				set_offset_int(ida[0],388,254)
			}
			else for(new i=0;i<7;i++)give_item(ida[0],curwpn)
		}
	}
	return PLUGIN_HANDLED
}
public round_start(){
	set_msg_block(get_user_msgid("AmmoPickup"),0)
	set_msg_block(get_user_msgid("WeapPickup"),0)
	set_msg_block(get_user_msgid("ItemPickup"),0)
	return PLUGIN_HANDLED
}
public round_end(){
	if(get_cvar_num("amx_wpnarena")){
		if(!waon){
			waon=true
			client_print(0,print_chat,"[Weapon Arena] Weapon Arena enabled")
			if(get_cvar_num("amx_wpnarena_nopickup"))disable_armory_ents()
			set_msg_block(get_user_msgid("StatusIcon"),2)//Block buying
			if(equipmm>0){
				entity_set_string(equipmm,EV_SZ_targetname,"game_playersspawn_d")
			}
		}
	}
	else{
		if(waon){
			waon=false
			client_print(0,print_chat,"[Weapon Arena] Weapon Arena disabled")
			enable_armory_ents()
			new players[32],num
			get_players(players,num,"a")
			for(new i=0;i<num;i++)weaponstrip(players[i],1)
			set_msg_block(get_user_msgid("StatusIcon"),0)//Unblock buying
			if(equipmm>0)entity_set_string(equipmm,EV_SZ_targetname,"game_playerspawn")
			rqup=true
		}
	}
	if(waon){
		if(get_cvar_num("amx_wpnarena_spawn_randwpn")){
			if(usedwpns>=((1<<26)-1)){
				usedwpns=0
				client_print(0,print_chat,"[Weapon Arena] All weapons have been used, reseting list.")
			}
			new wpn[10]
			while(!strlen(wpn)){
				new i=random(26)
				if(!(usedwpns&(1<<i))&&i!=lastwpn){
					lastwpn=i
					switch(i){
						case 0:wpn="glock18"
						case 1:wpn="usp"
						case 2:wpn="p228"
						case 3:wpn="deagle"
						case 4:wpn="elite"
						case 5:wpn="fiveseven"
						case 6:wpn="m3"
						case 7:wpn="xm1014"
						case 8:wpn="mac10"
						case 9:wpn="tmp"
						case 10:wpn="mp5navy"
						case 11:wpn="ump45"
						case 12:wpn="p90"
						case 13:wpn="galil"
						case 14:wpn="famas"
						case 15:wpn="ak47"
						case 16:wpn="m4a1"
						case 17:wpn="sg552"
						case 18:wpn="aug"
						case 19:wpn="scout"
						case 20:wpn="awp"
						case 21:wpn="g3sg1"
						case 22:wpn="sg550"
						case 23:wpn="m249"
						case 24:wpn="knife"
						case 25:wpn="hegrenade"
					}
					usedwpns+=(1<<i)
				}
			}
			if(equal(wpn,"hegrenade")){
				set_msg_block(get_user_msgid("SendAudio"),2)
				set_msg_block(get_user_msgid("TextMsg"),2)
			}
			else{
				set_msg_block(get_user_msgid("SendAudio"),0)
				set_msg_block(get_user_msgid("TextMsg"),0)
			}
			client_print(0,print_chat,"[Weapon Arena] The weapon for next round will be %s.",wpn)
			new targets[32],targnum=0
			targets=targets_find(0,targnum,ALIVE,"str*")
			for(new i=0;i<targnum;i++)weaponstrip(targets[i],1)
			set_task(0.1,"rm_wpnboxes")
			format(curwpn,sizeof(curwpn)-1,"weapon_%s",wpn)
		}
	}
	return PLUGIN_HANDLED
}
public rm_wpnboxes(){//Put in function for use with set_task
	remove_entities("weaponbox")
	return PLUGIN_HANDLED
}
public reequip(){
	new players[32],num
	get_players(players,num,"ae","CT")
	for(new i=0;i<num;i++){
		for(new j=0;j<3;j++)give_item(players[i],"weapon_usp")
		give_item(players[i],"weapon_knife")
	}
	get_players(players,num,"ae","TERRORIST")
	for(new i=0;i<num;i++){
		for(new j=0;j<3;j++)give_item(players[i],"weapon_glock18")
		give_item(players[i],"weapon_knife")
	}
	get_players(players,num)
	for(new i=0;i<num;i++)cs_set_user_money(players[i],get_cvar_num("mp_startmoney"))
}
public wa_toggle(id,level,cid){
	if(cmd_access(id,level,cid,1)){
		if(get_cvar_num("amx_wpnarena")){
			set_cvar_num("amx_wpnarena",0)
			client_print(id,print_console,"[Weapon Arena] Weapon Arena disabled")
		}
		else{
			set_cvar_num("amx_wpnarena",1)
			client_print(id,print_console,"[Weapon Arena] Weapon Arena enabled")
		}
	}
	return PLUGIN_HANDLED
}
public disable_armory_ents(){
	new ent=find_entity(-1,"armoury_entity")
	while(ent>0){
		set_rendering(ent,kRenderFxGlowShell,255,0,0,kRenderNormal,50)
		entity_set_int(ent,EV_INT_solid,SOLID_NOT)
		ent=find_entity(ent,"armoury_entity")
	}
	return PLUGIN_HANDLED
}
public enable_armory_ents(){
	new ent=find_entity(-1,"armoury_entity")
	while(ent>0){
		set_rendering(ent,kRenderFxNone,255,0,0,kRenderNormal,255)
		entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
		ent=find_entity(ent,"armoury_entity")
	}
	return PLUGIN_HANDLED
}
public plugin_cfg(){
	new ent=find_entity(-1,"multi_manager")
	while(ent>0&&equipmm==0){
		new targname[17]
		entity_get_string(ent,EV_SZ_targetname,targname,sizeof(targname)-1)
		if(equal(targname,"game_playerspawn"))equipmm=ent
		ent=find_entity(ent,"multi_manager")
	}
	ent=find_entity(-1,"armoury_entity")
	while(ent>0){
		if(cs_get_armoury_type(ent)==CSW_AWP)cs_set_armoury_type(ent,CSW_SCOUT)
		ent=find_entity(ent,"armoury_entity")
	}
	return PLUGIN_CONTINUE
}
public plugin_init(){
	register_plugin("Weapon Arena","0.3","Don Juan-jello")
//CVARS
	register_cvar("amx_wpnarena","1")
	register_cvar("amx_wpnarena_spawn_randwpn","1")
	register_cvar("amx_wpnarena_spawn_knife","1")
	register_cvar("amx_wpnarena_nopickup","1")
	register_cvar("amx_wpnarena_nobuy","1")

	register_clcmd("amx_wpnarena_toggle","wa_toggle",ADMIN_RESERVATION,"- Toggles weapon arena on/off.")
	//register_event("DeathMsg","death_msg","a")
	register_event("ResetHUD","spawned","b")
	/* Called when an entity is spawned */
	register_logevent("round_start",2,"1=Round_Start")
	register_logevent("round_end",2,"1=Round_End")
	return PLUGIN_CONTINUE
}

Contact
ViewVC Help
Powered by ViewVC 1.0.4