UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Giving max ammo for current weapon only

broken avatar :(
Created 10 years ago
by AlecKeaneDUB
0 Members and 1 Guest are viewing this topic.
4,449 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
I have things in my map that you can search (kind of like dig sites) and each one has a 10% chance of giving you a weapon refill (max ammo for the weapon you are holding). Now this is the part i have for the max ammo:
Code Snippet
Plaintext
player = undefined;
current_gun = player getcurrentweapon();
player GiveMaxAmmo( current_gun );
Now i dont just have those thrown together in my actual script, they are in the correct places. But why doesnt this work? I'm curious about what im missing or why the game wont read this. Does anyone know what i could use instead?
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 9 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
player = undefined;

This is why. Your setting the player variable to undefined, AKA it doesn't exist.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
Code Snippet
Plaintext
player = undefined;

This is why. Your setting the player variable to undefined, AKA it doesn't exist.
So i would take out the player so its just "GiveMaxAmmo( current_gun );"? I wouldnt do the for() loop and give it to players[ i ] because wont that give it to every player? And that isnt what i want
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 9 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
So i would take out the player so its just "GiveMaxAmmo( current_gun );"?

No. You have to figure out which player you want to run the code on. If the code only runs after a player uses a trigger, you can use:

Code Snippet
Plaintext
<trig> waittill("trigger", player);

Quote
I wouldnt do the for() loop and give it to players[ i ] because wont that give it to every player?

Depends on whats inside the for() loop. If you filter the players out by using an if condition then the code will only run for that player. However if you have a trigger(see above) you don't and shouldn't do this. The player variable in the waittill above will automatically get the player that used the trigger for you.

Otherwise if you just have an for() loop with the max ammo code inside then yes, it would just give the ammo to all players.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
No. You have to figure out which player you want to run the code on. If the code only runs after a player uses a trigger, you can use:

Code Snippet
Plaintext
<trig> waittill("trigger", player);

Depends on whats inside the for() loop. If you filter the players out by using an if condition then the code will only run for that player. However if you have a trigger(see above) you don't and shouldn't do this. The player variable in the waittill above will automatically get the player that used the trigger for you.

Otherwise if you just have an for() loop with the max ammo code inside then yes, it would just give the ammo to all players.

I'm confused about what you mean by adding the waittill( "trigger" , player ); function...because the player already has to use a trigger to search the location, so wouldnt adding another waittill( "trigger" , player ); make them have to hit it twice? I'm probably just stupid, but anyway here's the code i have:
Code Snippet
Plaintext
look_in_trash()
{
player = undefined;
cost = 500;
trash_trig = getent( "trash_trig" , "targetname" );
trash_trig usetriggerrequirelookat();
trash_trig setCursorHint("HINT_NOICON");
trash_trig sethintstring( "Press &&1 to search trash [Cost: "+cost+"]" );
current_gun = player getcurrentweapon();
rand = randomintrange( 1, 10 );

while(1)
{
trash_trig waittill( "trigger" , player );

if(level.has_key == false && player.score >= cost && isDefined(level.key_in_trash))
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "You found a key!" );
level.has_key = true;
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand == 1) // 10% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "Weapon Refill!" );
player GiveMaxAmmo( current_gun );
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand != 1) // 90% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "No luck." );
trash_trig delete();
}
else if(player.score < cost)
{
player maps\_zombiemode_perks::play_no_money_perk_dialog();
wait 0.1;
continue;
}
}
}
Last Edit: June 18, 2015, 01:56:38 pm by AlecKeaneDUB
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 1 year ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
So, everything else works fine on that, except the gun giving ammo part?
Edit: I looked up and bare with me, Im not good scripter, but you can try adding at start undefined and then defining it at the function itself like:
Code Snippet
Plaintext
look_in_trash()
{
player = undefined;
cost = 500;
trash_trig = getent( "trash_trig" , "targetname" );
trash_trig usetriggerrequirelookat();
trash_trig setCursorHint("HINT_NOICON");
trash_trig sethintstring( "Press &&1 to search trash [Cost: "+cost+"]" );
current_gun = undefined;
rand = randomintrange( 1, 10 );

while(1)
{
trash_trig waittill( "trigger" , player );

if(level.has_key == false && player.score >= cost && isDefined(level.key_in_trash))
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "You found a key!" );
level.has_key = true;
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand == 1) // 10% chance of getting this
{
                        current_gun = player getcurrentweapon();
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "Weapon Refill!" );
player GiveMaxAmmo( current_gun );
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand != 1) // 90% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "No luck." );
trash_trig delete();
}
else if(player.score < cost)
{
player maps\_zombiemode_perks::play_no_money_perk_dialog();
wait 0.1;
continue;
}
}
}

Works for me, I have done something similar, dont quote me on that though  :-X
Last Edit: June 18, 2015, 02:35:43 pm by HitmanVere
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
So, everything else works fine on that, except the gun giving ammo part?
Edit: I looked up and bare with me, Im not good scripter, but you can try adding at start undefined and then defining it at the function itself like:
Code Snippet
Plaintext
look_in_trash()
{
player = undefined;
cost = 500;
trash_trig = getent( "trash_trig" , "targetname" );
trash_trig usetriggerrequirelookat();
trash_trig setCursorHint("HINT_NOICON");
trash_trig sethintstring( "Press &&1 to search trash [Cost: "+cost+"]" );
current_gun = undefined;
rand = randomintrange( 1, 10 );

while(1)
{
trash_trig waittill( "trigger" , player );

if(level.has_key == false && player.score >= cost && isDefined(level.key_in_trash))
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "You found a key!" );
level.has_key = true;
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand == 1) // 10% chance of getting this
{
                        current_gun = player getcurrentweapon();
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "Weapon Refill!" );
player GiveMaxAmmo( current_gun );
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand != 1) // 90% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "No luck." );
trash_trig delete();
}
else if(player.score < cost)
{
player maps\_zombiemode_perks::play_no_money_perk_dialog();
wait 0.1;
continue;
}
}
}

Works for me, I have done something similar, dont quote me on that though  :-X
Hmm...not sure why having it undefined to begin with would make a difference, but i'll give it a try :) Btw yes everything else does work
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 2 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Since player is undefined it's trying to grab and set on an entity that doesn't exist.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 9 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I'm confused about what you mean by adding the waittill( "trigger" , player ); function...because the player already has to use a trigger to search the location, so wouldnt adding another waittill( "trigger" , player ); make them have to hit it twice? I'm probably just stupid, but anyway here's the code i have:
Code Snippet
Plaintext
look_in_trash()
{
player = undefined;
cost = 500;
trash_trig = getent( "trash_trig" , "targetname" );
trash_trig usetriggerrequirelookat();
trash_trig setCursorHint("HINT_NOICON");
trash_trig sethintstring( "Press &&1 to search trash [Cost: "+cost+"]" );
current_gun = player getcurrentweapon();
rand = randomintrange( 1, 10 );

while(1)
{
trash_trig waittill( "trigger" , player );

if(level.has_key == false && player.score >= cost && isDefined(level.key_in_trash))
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "You found a key!" );
level.has_key = true;
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand == 1) // 10% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "Weapon Refill!" );
player GiveMaxAmmo( current_gun );
trash_trig delete();
}
else if(player.score >= cost && !isDefined(level.key_in_trash) && rand != 1) // 90% chance of getting this
{
player iprintln( "Searching..." );
player maps\_zombiemode_score::minus_to_player_score( cost );
wait 2;
player iprintlnbold( "No luck." );
trash_trig delete();
}
else if(player.score < cost)
{
player maps\_zombiemode_perks::play_no_money_perk_dialog();
wait 0.1;
continue;
}
}
}

Eh no. I was just saying that because i had no idea what the rest of the function looked like. What you had before is fine, Just removed the player = undefined; right before you do the get weapon function and it should work.

Last Edit: June 18, 2015, 09:05:32 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 13 May 2014
Last active: 5 years ago
Posts
167
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
jbird's Groups
Code Snippet
Plaintext
full_ammo_powerup( drop_item )
{
players = get_players();

for (i = 0; i < players.size; i++)
{
//if (whatever if function you need here)
{
// array_thread (players, ::full_ammo_on_hud, drop_item);
players[i] thread full_ammo_on_hud( drop_item );
players[i] GiveMaxAmmo(players[i] GetCurrentWeapon());
}
}
}
Last Edit: June 18, 2015, 09:44:29 pm by jbird
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 9 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
full_ammo_powerup( drop_item )
{
players = get_players();

for (i = 0; i < players.size; i++)
{
//if (whatever if function you need here)
{
// array_thread (players, ::full_ammo_on_hud, drop_item);
players[i] thread full_ammo_on_hud( drop_item );
players[i] GiveMaxAmmo(players[i] GetCurrentWeapon());
}
}
}

 :facepalm2:

Did you not read the rest of the topic?

 
Loading ...