UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: MZslayer11 on October 04, 2014, 03:21:00 am

Title: Refill Weapon Ammo
Post by: MZslayer11 on October 04, 2014, 03:21:00 am
How would I make a trigger that refills a players ammo in the gun they are holding?
Title: Re: Refill Weapon Ammo
Post by: BluntStuffy on October 04, 2014, 09:09:00 am
make a new .gsc and name it ammo_buy_triggers.gsc for example. And paste this in it:


Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

main()
{
ammo_trig = getentarray( "ammo_trigger", "targetname" );
array_thread(ammo_trig,::ammo_refill);
}


ammo_refill()
{
cost = 500;

self setcursorhint("HINT_NOICON");
self sethintstring("Press and Hold &&1 to refill your current weapon. Cost ["+ cost +"] ");

while(1)
{
player = undefined;

self waittill( "trigger", player );

weapon = player getcurrentweapon();
ammo_count = player GetFractionMaxAmmo( weapon );

if( player.score >= cost && ammo_count != 1 && !player maps\_laststand::player_is_in_laststand() && !isdefined( player.being_revived) ||
player.score >= cost && ammo_count != 1 && !player maps\_laststand::player_is_in_laststand() && isdefined( player.being_revived) && !player.being_revived)
{
player maps\_zombiemode_score::minus_to_player_score( cost );
player playsound( "cha_ching" );
player givemaxammo( weapon );
}

else
{
player playsound( "deny" );
}
}
}



Now go into you mapname.gsc and after this line:

Code Snippet
Plaintext
	maps\_zombiemode::main();

Put this one:

Code Snippet
Plaintext
      maps\ammo_buy_triggers::main();             //  IF YOU USED ANOTHER NAME FOR THE .GSC CHANGE IT HERE TOO!!





Now in radiant make triggers with the kvp's:

targetname - ammo_trigger





That should work..