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

[Tutorial] Buyable Perk Slots

HOT
broken avatar :(
Created 9 years ago
by AlecKeaneDUB
0 Members and 1 Guest are viewing this topic.
10,645 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 3 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 this is just a simple little script I put together that allows players to buy an extra perk slot. This is very simple and easy to do, so nobody should have any problems with it :)

NOTE: Due to some issues people have been having, I highly reccomend installing Bam's perks the manual way (i.e. adding the scripts yourself and not using script placer z for them). Now, I only say this because I believe there may be a problem in the script if you do not install them the manual way or do not have them installed. I will re-write the script with the necessary changes and checks when I have the time and will update this topic. Thank you.

Step 1:
Open your map in radiant and place a script model of a perk bottle (or you can use a different model if you'd like), and give it this KVP:
Code Snippet
Plaintext
targetname : perk_bottle_model
Now place a trigger around the perk bottle (or whatever model you used), and give it the KVP:
Code Snippet
Plaintext
targetname : buy_slot_trigger
Save and close your map.

Step 2:
Go into WaWroot/mods/yourmapname/maps and open up YourMapName.gsc

Step 3:
Find this:
Code Snippet
Plaintext
maps\_zombiemode::main();
And directly under that line, paste this:
Code Snippet
Plaintext
thread buyable_perk_slot();
Now, paste this at the very bottom of the file:
Code Snippet
Plaintext
buyable_perk_slot()
{
level.perk_limit = 4; //Initial perk limit, feel free to change
level.perk_limit_max = 8; //Max perk limit, feel free to change
level.buy_slot_cost = 1500; //Cost of perk slot, feel free to change
buy_slot_trigger = getent( "buy_slot_trigger" , "targetname" ); //Gets the trigger entity
perk_bottle_model = getent("perk_bottle","targetname" ); //Gets the model entity

playfxontag (level._effect["powerup_on"], perk_bottle_model, "tag_origin"); //Puts the powerup effect around the bottle
self thread perk_bottle_rotate( perk_bottle_model );

buy_slot_trigger SetCursorHint("HINT_NOICON"); //Gets rid of hand symbol
buy_slot_trigger UseTriggerRequireLookAt(); //Requires the player to look at the trigger to use it
buy_slot_trigger SetHintString("Press &&1 To Buy Perk Slot [Cost: 1500]"); //Hint string players will see

while(1) //Loops so players can use it more than once
{
buy_slot_trigger waittill( "trigger", player ); //Waits until player uses trigger

if(player.score >= level.buy_slot_cost && level.perk_limit < level.perk_limit_max) //Checks to see if the player has enough points
{
player maps\_zombiemode_score::minus_to_player_score( level.buy_slot_cost ); //Subtracts the cost from the player's score
level.perk_limit = level.perk_limit + 1; //Increases the player's perk limit by 1
iprintlnbold( "You Can Now Hold " +level.perk_limit+ "/" +level.perk_limit_max+ " Perks" ); //Displays this message to the player
}

if(player.score >= level.buy_slot_cost && level.perk_limit >= level.perk_limit_max) //checks if the player has reached the max perk limit
{
return;
}
}
}

perk_bottle_rotate( perk_bottle_model )
{
self endon( "disconnect" );
while(1)
{
perk_bottle_model rotateyaw( 360 ,2 ); //Rotates the bottle
wait 2;
}
}
**PLEASE NOTE**

If you have Bam's BO perks in your map, make sure to go into _zombiemode.gsc and delete the level.perk_limit line in there. If you dont, it will cause bugs in the script.



I hope some people find this tutorial helpful, and please let me know if you encounter any problems. :)

Thanks to PROxFTW and Arceus for letting me know of syntax errors :D
Last Edit: May 14, 2015, 09:28:01 pm by AlecKeaneDUB
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 2 days ago
Posts
1,191
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
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.
MZslayer11's Contact & Social LinksMZslayer11Service_Code_30#2655
Nice job man, I may use this  ;) How would I have "Perk Limit: #" in the top left corner of the screen, like zombie counter style. Would it be a simple modification?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 3 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
Nice job man, I may use this  ;) How would I have "Perk Limit: #" in the top left corner of the screen, like zombie counter style. Would it be a simple modification?
Thanks! :D  And here's a hud elem I put together:
Code Snippet
Plaintext
perk_hud_count()
{
PerkSlots = create_simple_hud();
PerkSlots.horzAlign = "center";
PerkSlots.vertAlign = "middle";
PerkSlots.alignX = "Left";
PerkSlots.alignY = "middle";
PerkSlots.y = 230;
PerkSlots.x = 60;
PerkSlots.foreground = 1;
PerkSlots.fontscale = 8.0;
PerkSlots.alpha = 1;
PerkSlots.color = ( 0.423, 0.004, 0 );


PerkText = create_simple_hud();
PerkText.horzAlign = "center";
PerkText.vertAlign = "middle";
PerkText.alignX = "center";
PerkText.alignY = "middle";
PerkText.y = 230;
PerkText.x = -1;
PerkText.foreground = 1;
PerkText.fontscale = 8.0;
PerkText.alpha = 1;
PerkText.color = ( 0.423, 0.004, 0 );
PerkText SetText("Perk Limit: ");


while(1)
{
PerkAmount = level.perk_limit;
PerkSlots SetValue(PerkAmount);
 
PerkSlots.alpha = 1;

wait 0.5;
}
}
Just put that after the buyable_perk_slot() function.

Then inside the buyable_perk_slot() function, add this:
Code Snippet
Plaintext
self thread perk_hud_count();
Directly under this:
Code Snippet
Plaintext
self thread perk_bottle_rotate( perk_bottle_model );
And you should be good to go :) You'll have to mess with the hud elem positions though, I'm not sure what the xy values are for the top left of the screen. I'll see if I can figure them out and if I do I'll post another reply ;)
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 2 days ago
Posts
1,191
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
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.
MZslayer11's Contact & Social LinksMZslayer11Service_Code_30#2655
Thanks man! I'll test all this tomorrow When I get a chance ;)
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 6 months 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
Code Snippet
Plaintext
buyable_perk_slot()
{
perk_limit = 4; //Initial perk limit, feel free to change
perk_limit_max = 8; //Max perk limit, feel free to change
buy_slot_cost = 1500; //Cost of perk slot, feel free to change
buy_slot_trigger = getent( "buy_slot_trigger" , "targetname" ); //Gets the trigger entity
perk_bottle_model = getent("perk_bottle","targetname" ); //Gets the model entity

playfxontag (level._effect["powerup_on"], perk_bottle_model, "tag_origin"); //Puts the powerup effect around the bottle
self thread perk_bottle_rotate( perk_bottle_model );

buy_slot_trigger SetCursorHint("HINT_NOICON"); //Gets rid of hand symbol
buy_slot_trigger UseTriggerRequireLookAt(); //Requires the player to look at the trigger to use it
buy_slot_trigger SetHintString("Press &&1 To Buy Perk Slot [Cost: " + buy_slot_cost + "]"); //Hint string players will see

while(1) //Loops so players can use it more than once
{
buy_slot_trigger waittill( "trigger", player ); //Waits until player uses trigger

if(!is_player_valid(player))
{
wait 0.1;
continue;
}
if(player.score < buy_slot_cost)//DUKIP - Score less than amount
{
player PlaySound("deny");
player thread play_no_money_perk_dialog();
wait 0.1;
continue;
}
if(player.perk_limit >= perk_limit_max) //DUKIP - If we're at max then deny and continue
{
player PlaySound("deny");
wait 0.1;
continue;
}
if(player.perk_limit < perk_limit_max) //Checks to see if the player doesn't hax max perks.
{
player maps\_zombiemode_score::minus_to_player_score( buy_slot_cost ); //Subtracts the cost from the player's score
player.perk_limit++; //Increases the player's perk limit by 1
iprintlnbold( "You Can Now Hold " + player.perk_limit + "/" + perk_limit_max + " Perks" ); //Displays this message to the player
}
}
}

More efficient code.

Edit: Make sure somewhere on onPlayerSpawned you add self.perk_limit = (some_amount);
Last Edit: April 24, 2015, 02:42:16 am by DidUknowiPwn
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 3 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
buyable_perk_slot()
{
perk_limit = 4; //Initial perk limit, feel free to change
perk_limit_max = 8; //Max perk limit, feel free to change
buy_slot_cost = 1500; //Cost of perk slot, feel free to change
buy_slot_trigger = getent( "buy_slot_trigger" , "targetname" ); //Gets the trigger entity
perk_bottle_model = getent("perk_bottle","targetname" ); //Gets the model entity

playfxontag (level._effect["powerup_on"], perk_bottle_model, "tag_origin"); //Puts the powerup effect around the bottle
self thread perk_bottle_rotate( perk_bottle_model );

buy_slot_trigger SetCursorHint("HINT_NOICON"); //Gets rid of hand symbol
buy_slot_trigger UseTriggerRequireLookAt(); //Requires the player to look at the trigger to use it
buy_slot_trigger SetHintString("Press &&1 To Buy Perk Slot [Cost: " + buy_slot_cost + "]"); //Hint string players will see

while(1) //Loops so players can use it more than once
{
buy_slot_trigger waittill( "trigger", player ); //Waits until player uses trigger

if(!is_player_valid(player))
{
wait 0.1;
continue;
}
if(player.score < buy_slot_cost)//DUKIP - Score less than amount
{
player PlaySound("deny");
player thread play_no_money_perk_dialog();
wait 0.1;
continue;
}
if(player.perk_limit >= perk_limit_max) //DUKIP - If we're at max then deny and continue
{
player PlaySound("deny");
wait 0.1;
continue;
}
if(player.perk_limit < perk_limit_max) //Checks to see if the player doesn't hax max perks.
{
player maps\_zombiemode_score::minus_to_player_score( buy_slot_cost ); //Subtracts the cost from the player's score
player.perk_limit++; //Increases the player's perk limit by 1
iprintlnbold( "You Can Now Hold " + player.perk_limit + "/" + perk_limit_max + " Perks" ); //Displays this message to the player
}
}
}

More efficient code
Thanks :) I'm still learning so I didn't expect my version to be perfect lol
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 1 January 2014
Last active: 3 years ago
Posts
397
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Signature
×
vinnyz500's Groups
vinnyz500's Contact & Social Linkspsn_hackedlobbies4uXxMrPotatoxXvinnyz500
It doesn't set the perk limit to 4 so I can keep buying perks without the feature. How do you set a limit of 4?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 3 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
It doesn't set the perk limit to 4 so I can keep buying perks without the feature. How do you set a limit of 4?
Go into _zombiemode.gsc and add level.perk_limit = 4 right underneath maps\_zombiemode_auto_turret::init();
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
nah there is no limit check by default, and bam used a "level" limit, rather than induvidual players

Youd need to edit the function in zombiemode_perks.gsc ( I think its vending_trigger() )


Btw, nice work man ;)
Last Edit: April 27, 2015, 02:15:14 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 9 months ago
Posts
577
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
My preferred name is "xSanchez78".
Check me out here: www.steamcommunity.com/id/xSanchez78
×
alaurenc9's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
alaurenc9's Contact & Social LinksxSanchez78xSanchez78xSanchez78xSanchez78xSanchez78xSanchez78
Code Snippet
Plaintext
buyable_perk_slot()
{
perk_limit = 4; //Initial perk limit, feel free to change
perk_limit_max = 8; //Max perk limit, feel free to change
buy_slot_cost = 1500; //Cost of perk slot, feel free to change
buy_slot_trigger = getent( "buy_slot_trigger" , "targetname" ); //Gets the trigger entity
perk_bottle_model = getent("perk_bottle","targetname" ); //Gets the model entity

playfxontag (level._effect["powerup_on"], perk_bottle_model, "tag_origin"); //Puts the powerup effect around the bottle
self thread perk_bottle_rotate( perk_bottle_model );

buy_slot_trigger SetCursorHint("HINT_NOICON"); //Gets rid of hand symbol
buy_slot_trigger UseTriggerRequireLookAt(); //Requires the player to look at the trigger to use it
buy_slot_trigger SetHintString("Press &&1 To Buy Perk Slot [Cost: " + buy_slot_cost + "]"); //Hint string players will see

while(1) //Loops so players can use it more than once
{
buy_slot_trigger waittill( "trigger", player ); //Waits until player uses trigger

if(!is_player_valid(player))
{
wait 0.1;
continue;
}
if(player.score < buy_slot_cost)//DUKIP - Score less than amount
{
player PlaySound("deny");
player thread play_no_money_perk_dialog();
wait 0.1;
continue;
}
if(player.perk_limit >= perk_limit_max) //DUKIP - If we're at max then deny and continue
{
player PlaySound("deny");
wait 0.1;
continue;
}
if(player.perk_limit < perk_limit_max) //Checks to see if the player doesn't hax max perks.
{
player maps\_zombiemode_score::minus_to_player_score( buy_slot_cost ); //Subtracts the cost from the player's score
player.perk_limit++; //Increases the player's perk limit by 1
iprintlnbold( "You Can Now Hold " + player.perk_limit + "/" + perk_limit_max + " Perks" ); //Displays this message to the player
}
}
}

More efficient code.

Edit: Make sure somewhere on onPlayerSpawned you add self.perk_limit = (some_amount);

i would also add this under where it defines "perk_limit"

Code Snippet
Plaintext
flag_wait( "all_players_connected" );
players = get_players();
for( i = 0; i < players.size; i++ )
{
players[i].perk_limit = perk_limit;
}

and also change "play_no_money_perk_dialog()"
to "maps\_zombiemode_perks::play_no_money_perk_dialog()".
Because that function is only in _zombiemode_perks.gsc
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 24 April 2015
Last active: 8 years ago
Posts
49
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
×
kanenikont's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
kanenikont's Contact & Social Links
Can anyone help me?
I have the "more efficient" part of the script along with the other scripts above it that are not included in the more efficient part.  I have Bam's perks installed and I took out the level.perk_limit in my _zombiemode.gsc.  When I load the map with it like I described, the perk HUD is there (It says perk limit = (no number), and it lets me buy all 8 perks without buying more slots, even though I can still buy the perk bottle.  If I leave Bam's level.perk_limit in the _zombiemode.gsc It says perk limit = 4 on the HUD and the game limits me to 4 perks and I can buy slots but not more actual perks. Any help would be great!
broken avatar :(
×
broken avatar :(
True Blue Elite
Location: auAustralia
Date Registered: 8 February 2015
Last active: 8 months ago
Posts
688
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Still Kickin'
Signature


×
Andy Whelan's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Andy Whelan's Contact & Social LinksAndyWhelanAndyWhelan01AndyWhelan
Thank you, works well only it still allows me to buy more perks but I fixed it
EDIT:
For some reason it still lets me buy after I thought I fixed it, I am using Bams perks and got them through Scriptplacer Z. I have searched for the level.perk_limit but haven't found it.
Last Edit: May 12, 2015, 12:08:56 pm by Andy Whelan
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
you havent made anychange to the trigger for the perk, thats why its not working

your setting a limit yes, but that limit is not being considered when buying a perk

you need to add a check into _zombiemode_perks on the triggers
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 24 April 2015
Last active: 8 years ago
Posts
49
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
×
kanenikont's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
kanenikont's Contact & Social Links
Can't find it haha, oh well. Might just leave this out.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 3 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
These errors you guys are getting are odd to me. It may he because I added in Bam's perks manually, as I dont use script placer Z. That could be the problem...something with the script placer, because the script and everything I posted works 110% perfect for me  ???

 
Loading ...