UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: daedra descent on March 25, 2014, 12:05:34 am

Title: Buyable Max Ammo(Single Only)
Post by: daedra descent on March 25, 2014, 12:05:34 am
Basic buyable max ammo script. Can only be used once. Has option function arguments to easily customize the trigger(Cost, wait time).

Script:

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

main()
{
trig = getEnt("ammo_trig", "targetname");

trig ammo_trig(); // change the function input argument here. Example: trig ammo_trig(10000, 30);
}

ammo_trig(zombie_cost, time)
{

while(1)
{

if(!isdefined(zombie_cost) )
{
zombie_cost = 1000;
}

self sethintstring("Press F to buy ammo[Cost:" + zombie_cost + "]");

players = get_players();

self waittill( "trigger", players );

self.is_available = 1;

if(players.score >= zombie_cost && self.is_available == 1)
{

players maps\_zombiemode_score::minus_to_player_score( zombie_cost );

play_sound_at_pos( "purchase", self.origin );

players give_ammo();

self.is_available = 0;

if(isdefined(time) && time > 1 )
{
wait(time);
}
else
{
wait(1);
}
}
}
}
give_ammo()
{
players = get_players();

for (i = 0; i < players.size; i++)
{
player_weapons = self GetWeaponsListPrimaries();

for( x = 0; x < player_weapons.size; x++ )
{
self GiveMaxAmmo( player_weapons[x] );
}
}
}

Example of a proper argument set:

Code Snippet
Plaintext
trig ammo_trig(10000, 30);

The input "10000" represents the cost(zombie_cost), while the 30 represents the time(in seconds) before the trigger will allow the players to buy it again. Neither function arguments take a variable unless it is declared a number.
Title: Re: Buyable Max Ammo(Single Only)
Post by: jjbradman on March 25, 2014, 12:41:10 am
lol you forgot to specify some things and the values inside the that runs
Code Snippet
Plaintext
trig ammo_trig();
like
Code Snippet
Plaintext
trig ammo_trig(10000, 10);
you should comment there that they only have to change those values to whatever they want and script will do the rest
Title: Re: Buyable Max Ammo(Single Only)
Post by: daedra descent on March 25, 2014, 01:21:21 am
lol you forgot to specify some things and the values inside the that runs
Code Snippet
Plaintext
trig ammo_trig();
like
Code Snippet
Plaintext
trig ammo_trig(10000, 10);
you should comment there that they only have to change those values to whatever they want and script will do the rest

Added. Also added an explanation to first post to make it easier to understand. Hopefully it'll make a bit more sense.  ;D