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

Help with my script

broken avatar :(
Created 7 years ago
by djluvorng
0 Members and 1 Guest are viewing this topic.
1,644 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 24 May 2013
Last active: 1 month ago
Posts
21
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Youtube.com/ornggaming
Signature
youtube.com/ornggaming
×
djluvorng's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
djluvorng's Contact & Social Linksdjluvorng
I need help with a script I am writing for playing a sound when a specific gun is out of ammo. The script gives no errors but The sound does not play. Any help would be appreciated. ;)

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

main()
{
thread ammo();
}


ammo()
{

flag_wait( "all_players_connected" );
wait 1;
players = get_players();
j = 0
currentweapon = players[j] getCurrentWeapon();
bullets_left = players[j] GetFractionMaxAmmo( currentweapon );
for( i = 0; i < players.size; i++ )

wait .5;

if( currentweapon == "bo2_zm_colt" && bullets_left < 0.1 )

players[i] playsound("aib");

wait .5;


}
Marked as best answer by djluvorange 7 years ago
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
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.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
Something like this should work:

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

main()
{
thread ammo_init();
}


ammo_init()
{
flag_wait( "all_players_connected" );
wait 1;

players = get_players();
array_thread( players,::ammo_watch );
}

ammo_watch()
{
while(1)
{
currentweapon = self getCurrentWeapon();

while( self GetFractionMaxAmmo( currentweapon ) >= 0.1 && currentweapon == "bo2_zm_colt" )
[
wait 0.2;
}

if( currentweapon == "bo2_zm_colt" && self GetFractionMaxAmmo( currentweapon ) < 0.1 )
{
self playsound("aib");
}
wait 0.1;

// wait till the player has ammo again, or lost the weapon and restart the loop
while( self hasweapon("bo2_zm_colt") && self GetFractionMaxAmmo( "bo2_zm_colt" ) < 0.1 )
{
wait 0.2;
}
}
}
Last Edit: December 27, 2016, 06:23:49 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 24 May 2013
Last active: 1 month ago
Posts
21
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Youtube.com/ornggaming
×
djluvorng's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
djluvorng's Contact & Social Linksdjluvorng
wow, thanks! ;D
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
respect the dead

donates greatly appreciated :) paypal.me/F3ARxReaper666
discord server:
https://discord.gg/tsGHW99
×
death_reaper0's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
just wanted to point out a typo
Code Snippet
Plaintext
	while( self GetFractionMaxAmmo( currentweapon ) >= 0.1 && currentweapon == "bo2_zm_colt" )
[
wait 0.2;
}

should be
Code Snippet
Plaintext
while( self GetFractionMaxAmmo( currentweapon ) >= 0.1 && currentweapon == "bo2_zm_colt" )
{
wait 0.2;
}


 
Loading ...