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

[script] Perk Watcher

HOT
broken avatar :(
Created 10 years ago
by daedra descent
0 Members and 1 Guest are viewing this topic.
11,784 views
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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
I created a little script that filters what perks the player has based on a input array(specialties). The script is intended for stock perks but you can add whatever you want to the array and it should work just fine.

Script:
Code Snippet
Plaintext
watch_player_perks()
{
perks = [];
perks[perks.size] = "specialty_armorvest";
perks[perks.size] = "specialty_quickrevive";
perks[perks.size] = "specialty_rof";
perks[perks.size] = "specialty_fastreload";


while(1)
{
for(i = 0; i < perks.size; i++)
{
// iprintln("found perks" + perks[i]);

players = get_players();
for(k = 0; k < players.size; k++)
{
if(players[k] hasperk(perks[i]) )
{

if(perks[i] == "specialty_armorvest")
{
players[k].has_jug = true;
}
if(perks[i] == "specialty_quickrevive")
{
players[k].has_revive = true;
}
if(perks[i] == "specialty_rof")
{
players[k].has_rof = true;
}
if(perks[i] == "specialty_fastreload")
{
players[k].has_reload = true;
}

// players[k] iprintln("You have perks:" + perks[i]);
}
}
}
wait(.1);
}
}

How to add a new perk:
Spoiler: click to open...
Firstly you need to get the actual(technical) perk name that the same uses. Once you have that all you need to do is add a new value to the array like So:
Code Snippet
Plaintext
	perks = [];
perks[perks.size] = "specialty_armorvest";
perks[perks.size] = "specialty_quickrevive";
perks[perks.size] = "specialty_rof";
perks[perks.size] = "specialty_fastreload";
perks[perks.size] = "NEW_PERK_HERE";

Once you have that you need to create a if statement to "catch" the perk after its filtered by hasperk() like so:
Code Snippet
Plaintext
 
if(perks[i] == "specialty_armorvest")
{
players[k].has_jug = true;
}
if(perks[i] == "specialty_quickrevive" && players.size == 1)
{
players[k].has_revive = true;
}
if(perks[i] == "specialty_rof")
{
players[k].has_rof = true;
}
if(perks[i] == "specialty_fastreload")
{
players[k].has_reload = true;
}
if(perks[i] == "NEW_PERK_HERE")
{
players[k].has_reload = true;
}

If done correctly then the affect defined in the if statement should now init when the player has the perks.

Example of a working affect using this function:
Code Snippet
Plaintext
watch_player_perks()
{
perks = [];
perks[perks.size] = "specialty_armorvest";
perks[perks.size] = "specialty_quickrevive";
perks[perks.size] = "specialty_rof";
perks[perks.size] = "specialty_fastreload";


while(1)
{
for(i = 0; i < perks.size; i++)
{
// iprintln("found perks" + perks[i]);

players = get_players();
for(k = 0; k < players.size; k++)
{
if(players[k] hasperk(perks[i]) )
{

if(perks[i] == "specialty_armorvest")
{
players[k].has_jug = true;
}
if(perks[i] == "specialty_quickrevive" && players.size == 1)
{
players[k].has_revive = true;

// wait(5);
players[k] unsetperk(perks[i]);
players[k] maps\_zombiemode_perks::perk_hud_destroy( perks[i] );
players[k] iprintln("Taking perk:" + perks[i]);
players[k] iprintln("Reason: Quick Revive has no affect in Solo");
players[k] maps\_zombiemode_score::add_to_player_score( 1000 );
}
if(perks[i] == "specialty_rof")
{
players[k].has_rof = true;
}
if(perks[i] == "specialty_fastreload")
{
players[k].has_reload = true;
}

// players[k] iprintln("You have perks:" + perks[i]);
}
}
}
wait(.1);
}
}

and thats it. Make sure to give credit if you use it. Comments, questions, suggestion's are all welcome. Just don't be an ass by making an "optimized" version unless its for personal use.

P.S. I wasn't sure if i should have made the players variable a level variable. If it should be then please tell me so i can change it ASAP.
Last Edit: April 07, 2014, 09:39:02 pm by daedra descent
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 9 months ago
Posts
5,551
Respect
6,691Add +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.
Just don't be an ass by making an "optimized" version unless its for personal use.

P.S. I wasn't sure if i should have made the players variable a level variable. If it should be then please tell me so i can change it ASAP.
Anyone else see the irony?
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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
Anyone else see the irony?

Don't remember taking someone else's script and then modifying it while calling it my "optimized" version.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
lol i dont think it a good idea to make players a "level" var under any circumstances lol. in any case we can use our old friend which is the "self" ent
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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
lol i dont think it a good idea to make players a "level" var under any circumstances lol. in any case we can use our old friend which is the "self" ent

I didn't think it would either. I assumed that the .has_<perk> is persistent on the players[k] variable so that even if you where to create an entirely new function the value would still be set, which is why i'm asking.

I had thought about using self, but i figured it would be easier to keep everything in the function.
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 9 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
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.
I didn't think it would either. I assumed that the .has_<perk> is persistent on the players[k] variable so that even if you where to create an entirely new function the value would still be set, which is why i'm asking.

I had thought about using self, but i figured it would be easier to keep everything in the function.
You tell people not to "optimize" your scripts and then you ask for help. That's the irony. The people who are editing your scripts are trying to help you write better scripts.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
You tell people not to "optimize" your scripts and then you ask for help. That's the irony. The people who are editing your scripts are trying to help you write better scripts.
lol  :lol: xD
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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
You tell people not to "optimize" your scripts and then you ask for help. That's the irony. The people who are editing your scripts are trying to help you write better scripts.

Oh i see. That wasn't exactly what i was getting at. I had meant for people not to 1-up me in a way that is rude or disrespectful. Of course suggestions, feedback, questions, etc  are welcome.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
dual wasnt being rude when he posted the code the other time lol, you have to accept that sometime your code has useless stuff and well dual is being known for making quality scripts
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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
dual wasnt being rude when he posted the code the other time lol, you have to accept that sometime your code has useless stuff and well dual is being known for making quality scripts

I never said anyone's username in particular.

Also, can we please stay on topic? I really need to know if this works for everyone else and what their thoughts are on it. has anyone tried it on coop?
Last Edit: April 07, 2014, 10:40:38 pm by daedra descent
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok, i havent tested .-. can you tell me what does it does? xD haha i was a lil bit lazy to read all the code :L
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 9 years ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Community 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.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social Linksthomas.gascoigne.7DuaLVIIDuaLVIITheProlonger
dual wasnt being rude when he posted the code the other time lol, you have to accept that sometime your code has useless stuff and well dual is being known for making quality scripts

Oh I'm not going to bother any more.

ok, i havent tested .-. can you tell me what does it does? xD haha i was a lil bit lazy to read all the code :L

Just checks what stock perks you have.
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 9 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
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.
Oh I'm not going to bother any more.
I'll take care of it  :accepted:

Code Snippet
Plaintext
/*
Example usage outside of this script:
if(player.currentPerks["specialty_revive"]) player iPrintLn("You have Quick Revive");
*/
watch_player_perks()
{
perks = [];
perks[perks.size] = "specialty_armorvest";
perks[perks.size] = "specialty_quickrevive";
perks[perks.size] = "specialty_rof";
perks[perks.size] = "specialty_fastreload";

players = get_players();
while(1)
{
for(i = 0; i < perks.size; i++)
{
for(k = 0; k < players.size; k++)
{
if(!isDefined(players[k].currentPerks)) players[k].currentPerks = [];
if(!isDefined(players[k].currentPerks[perks[i]])) players[k].currentPerks[perks[i]] = false;
if(players[k] hasperk(perks[i])) players[k].currentPerks[perks[i]] = true;
else players[k].currentPerks[perks[i]] = false;
}
}
wait 0.1;
}
}
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
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'll take care of it  :accepted:

Code Snippet
Plaintext
/*
Example usage outside of this script:
if(player.currentPerks["specialty_revive"]) player iPrintLn("You have Quick Revive");
*/
watch_player_perks()
{
perks = [];
perks[perks.size] = "specialty_armorvest";
perks[perks.size] = "specialty_quickrevive";
perks[perks.size] = "specialty_rof";
perks[perks.size] = "specialty_fastreload";

players = get_players();
while(1)
{
for(i = 0; i < perks.size; i++)
{
for(k = 0; k < players.size; k++)
{
if(!isDefined(players[k].currentPerks)) players[k].currentPerks = [];
if(!isDefined(players[k].currentPerks[perks[i]])) players[k].currentPerks[perks[i]] = false;
if(players[k] hasperk(perks[i])) players[k].currentPerks[perks[i]] = true;
else players[k].currentPerks[perks[i]] = false;
}
}
wait 0.1;
}
}

Thats just a slightly more efficient way of doing it.

I could have done that or something like this:

Code Snippet
Plaintext
				if(perks[i] == "specialty_fastreload" || perks[i] == "specialty_armorvest" || perks[i] == "specialty_quickrevive" || perks[i] =="specialty_rof")
{
players[k].has_ + perks[i] = true;
}
(don't have time to actually test this to see if it works but you get the idea)

my version is a bit easier on the eyes & easier to follow.
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 4 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter Elite
My Groups
More
×
YaPh1l's Groups
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Code Snippet
Plaintext
				if(perks[i] == "specialty_fastreload" || perks[i] == "specialty_armorvest" || perks[i] == "specialty_quickrevive" || perks[i] =="specialty_rof")
{
players[k].has_ + perks[i] = true;
}
This does not work.

- Phil.

 
Loading ...