PDA

View Full Version : Removing weapons out of a Map via script



Earliboy
12th May 2013, 11:30
Hello,
often you have that problem:
You download nice maps, run zombie gametype or rifle and then there are weapons inside the map.
To remove them out add a file named _rWeapons.gsc into the maps\mp\gametypes folder.

Open the GAMETYPE.gsc (zom.gsc, tdm.gsc) and go to main()

Add the following line:


thread maps\mp\gametypes\_rWeapons::init();


_rWeapons.gsc file:


//This script is writen by Earliboy
//You got full access to use this file and edit it.
//If you have any questions, contact me at Xfire: earliboy or skype: earliboy
//If you find any issues, please contact me!

//Adding a new weapon:
//rmWeapon("weapon_NAME_mp");
//Example: rmWeapon("weapon_mp44_mp");

//Add following line to your server.cfg
//set scr_remove_weapons "1"
//"1" = On (remove weapons) "0" = Off (don't remove weapons)

init()
{
if(getCvar("scr_remove_weapons") == "")
setCvar("scr_remove_weapons","1");

level.rmWeapons = getCvarInt("scr_remove_weapons");

if(!level.rmWeapons)
return;

rmWeapon("weapon_greasegun_mp");
rmWeapon("weapon_m1carbine_mp");
rmWeapon("weapon_m1garand_mp");
rmWeapon("weapon_springfield_mp");
rmWeapon("weapon_thompson_mp");
rmWeapon("weapon_bar_mp");
rmWeapon("weapon_sten_mp");
rmWeapon("weapon_enfield_mp");
rmWeapon("weapon_enfield_scope_mp");
rmWeapon("weapon_bren_mp");
rmWeapon("weapon_PPS42_mp");
rmWeapon("weapon_mosin_nagant_mp");
rmWeapon("weapon_SVT40_mp");
rmWeapon("weapon_mosin_nagant_sniper_mp");
rmWeapon("weapon_ppsh_mp");
rmWeapon("weapon_mp40_mp");
rmWeapon("weapon_kar98k_mp");
rmWeapon("weapon_g43_mp");
rmWeapon("weapon_kar98k_sniper_mp");
rmWeapon("weapon_mp44_mp");
rmWeapon("weapon_shotgun_mp");
rmWeapon("weapon_trenchgun_mp");
rmWeapon("weapon_raygun_mp");
rmWeapon("weapon_panzerschreck_mp");
rmWeapon("weapon_panzerfaust_mp");
rmWeapon("weapon_defaultweapon_mp");
rmWeapon("weapon_chainsaw_mp");
rmWeapon("weapon_flametrower_mp");
}

rmWeapon(ent)
{
ent = getEntArray(ent, "classname");

if(!isDefined(ent))
return;

for(i = 0; i < ent.size; i++)
ent[i] delete();
}

Tally
12th May 2013, 12:02
That's overly complicated. All you have to do is find all entities which have the substring "weapon_" in their classname and delete them:


init()
{

if(getCvar("scr_remove_weapons") == "")
setCvar("scr_remove_weapons","1");

level.rmWeapons = getCvarInt("scr_remove_weapons");

if( !level.rmWeapons )
return;

ents = getentarray();
for( i=0; i < ents.size; i++ )
{
if( isSubStr( ents[i].classname, "weapon_" ) )
ents[i] delete();
}

}


No need for great long lists of specific weapons.

Tally
12th May 2013, 12:03
EDIT - what is it with these forums and double posts? Get's on your friggin tits all the time.

kung foo man
12th May 2013, 12:19
Because the vBulletin-Software is so overly robust, that they dont need to fit their software to new PHP-versions...

Earliboy
12th May 2013, 16:14
Well,
if you only want to remove some weapons, then my script is much more usefull.

guiismiti
13th January 2014, 22:39
Was just reading random boards and found this, looks useful.
I'm hosting a meatbot server now, and had to remove the weapons from the maps and disable dropweapon.
If the bots walk over any weapon on the ground, they will pick it up. When they see an enemy, they will stay still and not shoot, since they use exclusive weapons to work properly.
That's also why I had to disable sprint, since it's technically a weapon.

Anyway, the way I found to remove the weapons is to edit the map file and change the spawn coordinates (will crash if you stack too many in 0;0;0). I guess your way is just better and, in a certain way, more correct.