Cxrrupt2 Since you have not done gsc before and the code you used as base is old i wanted to show how you could make it lil bit better.
You have used "thread" which allow running code after it even if the old function is not done running. Because of this you can use same "wallweaponmonitorbox" and "playchalkfx" functions for all weapons.
Also with loops you should add endons like "level endon("end_game");" which stops the loop running after game ended otherwise the loop can cause issues like crashing.
#include maps\mp\_utility;
#include maps\mp\zombies\_zm_utility;
#include common_scripts\utility;
#include maps\mp\gametypes_zm\_hud_util;
#include maps\mp\zombies\_zm_weapons;
#include maps\mp\zombies\_zm_magicbox;
init()
{
if(getdvar("mapname") == "zm_transit") //run only in any transit map
{
//precaching fx effects might cause issues if game has them already precached
//caused error with other script of mine
level._effect["wall_b23r"] = loadfx( "maps/zombie/fx_zmb_wall_buy_berreta93r" );
level._effect["wall_m16"] = loadfx( "maps/zombie/fx_zmb_wall_buy_m16" );
level._effect["wall_mp5k"] = loadfx( "maps/zombie/fx_zmb_wall_buy_mp5k" );
flag_wait( "initial_blackscreen_passed" );
thread wallweaponmonitorbox(( 1126.7, 865.359, 10 ), ( 0, 270, 0 ), "m16_zm", 1200, 600 );
thread playchalkfx("wall_m16", ( 1126.7, 865.359, 10 ), ( 0, 270, 0 ));
thread wallweaponmonitorbox(( 611, -997, 177.2 ), ( 0, 270, 0 ), "mp5k_zm", 1200, 600 );
thread playchalkfx("wall_mp5k", ( 611, -995, 177 ), ( 0, 270, 0 ));
thread wallweaponmonitorbox(( 2428, 438, -5 ), ( 0, 180, 0 ), "fiveseven_zm", 1200, 600 );
thread playchalkfx("wall_b23r", ( 2428, 438, -5 ), ( 0, 180, 0 ));
}
}
playchalkfx(effect, origin, angles)
{
level endon("end_game");
for(;;)
{
fx = SpawnFX(level._effect[ effect ], origin,AnglesToForward(angles),AnglesToUp(angles));
TriggerFX(fx);
level waittill("connected", player);
fx Delete();
}
}
wallweaponmonitorbox(origin, angles, weapon, cost, ammo )
{
level endon("end_game");
name = get_weapon_display_name( weapon );
trigger = spawn("trigger_radius", origin, 0, 35, 80);
trigger SetCursorHint("HINT_NOICON");
trigger SetHintString("Hold ^3&&1^7 For Buy " + name + " [Cost: " + cost + "] Ammo [Cost: " + ammo + "] Upgraded Ammo [Cost: 4500]");
for(;;)
{
trigger waittill("trigger", player);
if(player usebuttonpressed() && !player maps\mp\zombies\_zm_laststand::player_is_in_laststand() && player can_buy_weapon())
{
if( !player has_weapon_or_upgrade(weapon) && player.score >= cost )
{
player playsound( "zmb_cha_ching" );
player.score -= cost;
player thread weapon_give( weapon, 0, 1 );
if(!isdefined(model))
{
play_sound_at_pos( "weapon_show", origin, player );
model = spawn("script_model", origin);
model.angles = angles;
model setmodel(getweaponmodel( weapon ));
}
wait 3;
}
else
{
if(player has_upgrade(weapon) && player.score >= 4500)
{
if(player ammo_give(get_upgrade_weapon(weapon)))
{
player.score -= 4500;
player playsound("zmb_cha_ching");
wait 3;
}
}
else if(player hasweapon(weapon) && player.score >= ammo)
{
if(player ammo_give(weapon))
{
player.score -= ammo;
player playsound("zmb_cha_ching");
wait 3;
}
}
}
}
wait .05;
}
}