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

Check if the player is reloading

broken avatar :(
Created 12 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
4,938 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Hi there.

How can I check if the player is currently reloading in an "if" statement?
I know I can use the,
Code Snippet
Plaintext
self waittill("reload_start");
But that wouldn't work very well in my case, I would need an if statement to check if the player is reloading.

How can I check if the player is reloading in that case then?
Thanks in advance.
Last Edit: June 26, 2014, 08:39:40 pm by Ege115
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 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
self.is_reloading = true;

Maybe?

edit: thats after the waittill() obviously.
Last Edit: June 26, 2014, 08:45:05 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Hi there.

How can I check if the player is currently reloading in an "if" statement?
I know I can use the,
Code Snippet
Plaintext
self waittill("reload_start");
But that wouldn't work very well in my case, I would need an if statement to check if the player is reloading.

How can I check if the player is reloading in that case then?
Thanks in advance.

You could thread a watch  for the reload like electric cherry that sets a variable true between "reload_start" and "reload"?
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You could thread a watch  for the reload like electric cherry that sets a variable true between "reload_start" and "reload"?
"reload_start" and "reload"? Does waittill("reload") exist?

Or am I just being stupid now?

Edit: I don't know but would this work?
Code Snippet
Plaintext
reload_check()
{
self endon( "disconnect" );
self waittill("spawned_player");

self.is_reloading = false;

while(1)
{
weapon = self getcurrentweapon();
clip = self GetWeaponAmmoClip(weapon);

if(clip.size <=0)
{
self.is_reloading = true;
}
wait .05;
}
}
Last Edit: June 26, 2014, 09:44:41 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
"reload_start" and "reload"? Does waittill("reload") exist?

Or am I just being stupid now?

Edit: I don't know but would this work?
Code Snippet
Plaintext
reload_check()
{
self endon( "disconnect" );
self waittill("spawned_player");

self.is_reloading = false;

while(1)
{
weapon = self getcurrentweapon();
clip = self GetWeaponAmmoClip(weapon);

if(clip.size <=0)
{
self.is_reloading = true;
}
wait .05;
}
}

I'll check it out tonight if you don't have it solved yet. If you don't have electric cherry, Google it. I think there is a script in it that will solve your problem.
Last Edit: June 26, 2014, 10:03:01 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 11 years ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social LinksDuaLVIIthomas.gascoigne.7DuaLVIITheProlonger
No, Unless, because the player may not reload the weapon through sprinting and change weapons with the variable still set to true, alternatively the player doesn't have enough ammo to reload with which would still keep the variable to true so you'd have to put in several other if's and buts and candy and nuts into it.

I've never check or tried reload checking but if self.is_reloading is an actual variable used to define if the play is reloading or not then you'd wan't to put a check into a flow control that runs all the time to each individual player with a tiiiny little wait within to stop it from going *freezing for 5 seconds so I can return my favourite infinite loop error*
and then passing a notify (( `self notify("reloading")` )) when self.is_reloading is set to true. Of coarse there will be a spam of those notifies unless you also add in another variable into the reload checker function with another if statement to control it. With self notify, in other functions you can just use self waittill from there (( `self waittill("reloading")` ))

But like I said, Never tried it, not even sure if that variable self.is_reloading even exists and if not this reply was a gorgeous waste of time.

Since I lost all my work recently and haven't completely re-installed World at War yet, I can't test it out otherwise I would of before posting this.

Oh Well :)
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
Run this on all players using
Code Snippet
Plaintext
array_thread(getPlayers(), ::reloading_monitor);

Code Snippet
Plaintext
reloading_monitor()
{
while(1)
{
self.reloading = false;
self waittill("reload_start");
ammo = self getWeaponAmmoClip(self getCurrentWeapon()); //get their current ammo during the reload, probably 0
self.reloading = true;
while(ammo == self getWeaponAmmoClip(self getCurrentWeapon())) //wait for the ammo to change to something other than what we caught during the reload
wait 0.00001;
}
}

Then you can check if(self.reloading) or whatever is appropriate for the function you are using it in.

I use this in UGX Mod and it works perfectly fine.
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 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.
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
Run this on all players using
Code Snippet
Plaintext
array_thread(getPlayers(), ::reloading_monitor);

Code Snippet
Plaintext
reloading_monitor()
{
while(1)
{
self.reloading = false;
self waittill("reload_start");
ammo = self getWeaponAmmoClip(self getCurrentWeapon()); //get their current ammo during the reload, probably 0
self.reloading = true;
while(ammo == self getWeaponAmmoClip(self getCurrentWeapon())) //wait for the ammo to change to something other than what we caught during the reload
wait 0.00001;
}
}

Then you can check if(self.reloading) or whatever is appropriate for the function you are using it in.
I remember seeing reload_start/reload_end ,=,
Edit: Nevermind no reload_end
Last Edit: June 27, 2014, 02:44:56 am by DidUknowiPwn
Marked as best answer by Ege115 12 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
This script will set a variable for the player, is_reloading, based on whether or not the player is currently reloading. I had two issues that I could not resolve. getting the sprint binding when it was shift was an issue, so I worked around it, and if you switch weapons too quickly that you end right back at the same weapon, it doesn't register, so I added a 3 second timer to stop if from setting reload true until the next time. I think I accounted for the other stuff that cancels reload though.

I left the print statements in the top code so you can see what it is doing and see that you have the option to do something depending of if the player finishes reloading or not.

You can just thread this in your nazi_zombie_mapname.gsc right above zombie mode
Code Snippet
Plaintext
    thread reloadWatch();
/*--------------------
ZOMBIE MODE
----------------------*/

Code Snippet
Plaintext
reloadWatch(){
flag_wait("all_players_connected");
players = get_players();
for(i=0;i<players.size;i++){
players[i].isreloading = 0;
players[i] thread reloadStatus();
}
}
reloadStatus(){
while(1){
self waittill("reload_start");
self.reloading = 1;
self thread playerReloading();
self waittill("reloaded");
self.reloading = 0;
wait(.05);
}
}
playerReloading(){
self endon("reloaded");
gun = self getcurrentweapon();
ammo = self getcurrentweaponclipammo();
self thread playerTimer(3);//3 second fail safe
while(!(self playerButtonCancel()) && !(self playerWeaponCancel()) && !(ammo < self getcurrentweaponclipammo()) && gun == self getcurrentweapon() && !(self getstance() == "prone") ){

wait(.05);
}
if(ammo < self getcurrentweaponclipammo() && gun == self getcurrentweapon() ){
self iprintlnbold("I finished reloading");
}else{
self iprintlnbold("Reloading must have been interupted");
}
self notify("reloaded");
}
playerTimer(timer){
self endon("reloaded");
wait(timer); //added due to bug with switching weapons too fast.
self iprintlnbold("Reloading too long, must be bug");
self notify("reloaded");
}
playerButtonCancel(){
buttons = [];
buttons[0] = "[{weapprev}]";
buttons[1] = "[{weapnext}]";
buttons[2] = "[{+breath_sprint}]";//returns Shift, instead of shift, but != to "shift"?
buttons[3] = "[{+sprint}]";
for(b=0;b<buttons.size;b++){
if(self Buttonpressed(buttons[b]) || self Buttonpressed("shift")){
return true;
}
}
return false;
}
playerWeaponCancel(){
if(self isthrowingGrenade() || self ismeleeing() || self isfiring()){
return true;
}
}

I also included a stand alone _isReloading.gsc down below if you rather add it below maps\_zombiemode::main();
Code Snippet
Plaintext
/*--------------------
ZOMBIE MODE
----------------------*/
[[level.DLC3.weapons]]();
[[level.DLC3.powerUps]]();
maps\_zombiemode::main();
maps\_isReloading::init();

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

init(){
flag_wait("all_players_connected");
players = get_players();
for(i=0;i<players.size;i++){
players[i].isreloading = 0;
players[i] thread reloadStatus();
}
}
reloadStatus(){
while(1){
self waittill("reload_start");
self.is_reloading = 1;
self thread playerReloading();
self waittill("reloaded");
self.is_reloading = 0;
wait(.05);
}
}
playerReloading(){
self endon("reloaded");
gun = self getcurrentweapon();
ammo = self getcurrentweaponclipammo();
self thread playerTimer(3);//3 second fail safe
while(!(self playerButtonCancel()) && !(self playerWeaponCancel()) && !(ammo < self getcurrentweaponclipammo()) && gun == self getcurrentweapon() && !(self getstance() == "prone") ){
wait(.05);
}
if(ammo < self getcurrentweaponclipammo() && gun == self getcurrentweapon() ){
// self iprintlnbold("I finished reloading");
}else{
// self iprintlnbold("Reloading must have been interupted");
}
self notify("reloaded");
}
playerTimer(timer){
self endon("reloaded");
wait(timer); //added due to bug with switching weapons too fast.
// self iprintlnbold("Reloading too long, must be bug");
self notify("reloaded");
}
playerButtonCancel(){
buttons = [];
buttons[0] = "[{weapprev}]";
buttons[1] = "[{weapnext}]";
buttons[2] = "[{+breath_sprint}]";//returns Shift, instead of shift, but != to "shift"?
buttons[3] = "[{+sprint}]";
for(b=0;b<buttons.size;b++){
if(self Buttonpressed(buttons[b]) || self Buttonpressed("shift")){
return true;
}
}
return false;
}
playerWeaponCancel(){
if(self isthrowingGrenade() || self ismeleeing() || self isfiring()){
return true;
}
}
Last Edit: June 27, 2014, 07:44:11 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Hi, I have finally tested and your script worked perfect makecents. It was hard for me to decide which script I was going to use in this topic. xD

This almost deserves a tutorial makecents. :D
thanks for the script.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Hi, I have finally tested and your script worked perfect makecents. It was hard for me to decide which script I was going to use in this topic. xD

This almost deserves a tutorial makecents. :D
thanks for the script.

Cool! Glad it worked for you.

 
Loading ...