Edit: Taking a look at Pwns suggestion now, if that would work better
You'll have the same issue because the initialization part is the problem, not your perks. It's where you chose to initialize those atts. That is why it was saying that it wasn't defined. When it got the players array, the array was empty atm.
if(!isDefined(player.perk_bought)) player.perk_bought = 0;//initializes here when needed if(!isDefined(player.perklimit)) player.perklimit = 4;//initializes here when needed if(player.perk_bought >= player.perklimit){ player iPrintLn("Perk Limit Hit"): continue; }
Edit: Only issue with this method of initializing, per player, here, is that if the player didn't get any perks before the ee was completed, when they do, they will be left with 4 perk limit, lol. So again, I would go with a level var if the ee is not player based. Replacing that first part I told you to delete with level.perklimit = 4; and the second part replace player.perklimit with level.perklimit.
Last Edit: September 16, 2015, 05:46:00 pm by MakeCents
You'll have the same issue because the initialization part is the problem, not your perks. It's where you chose to initialize those atts. That is why it was saying that it wasn't defined. When it got the players array, the array was empty atm.
if(!isDefined(player.perk_bought)) player.perk_bought = 0;//initializes here when needed if(!isDefined(player.perklimit)) player.perklimit = 4;//initializes here when needed if(player.perk_bought >= player.perklimit){ player iPrintLn("Perk Limit Hit"): continue; }
Edit: Only issue with this method of initializing, per player, here, is that if the player didn't get any perks before the ee was completed, when they do, they will be left with 4 perk limit, lol. So again, I would go with a level var if the ee is not player based. Replacing that first part I told you to delete with level.perklimit = 4; and the second part replace player.perklimit with level.perklimit.
Yeah, I had done few modifications to the script, so Pwns thing didnt work Testing this now
Edit: Throwing bad syntax:
Code Snippet
Plaintext
if(player.perk_bought >= level.perklimit{
Not sure, if you meant this on last line of your comment or
Another edit: I derped out, lol, fixing it now
Last edit: First thing was working. Then I added the level vars like said and now perklimit doesnt get changed
Last Edit: September 16, 2015, 07:21:05 pm by HitmanVere
Last edit: First thing was working. Then I added the level vars like said and now perklimit doesnt get changed
Do you mean the perk limit that you set to 9 after the ee isn't changing? Did you add iprintlnbold statements to check if the code makes it there or if it is a typo or something?
Do you mean the perk limit that you set to 9 after the ee isn't changing? Did you add iprintlnbold statements to check if the code makes it there or if it is a typo or something?
Going through everything again, just in case, lol. Start of EE:
Code Snippet
Plaintext
level.perklimit = 4;
When perklimit gets to 9:
Code Snippet
Plaintext
level.perklimit = 9;
And in perkscript:
Code Snippet
Plaintext
// Perk limit testing for( ;; ) { self waittill( "trigger", player ); if(!isDefined(player.perk_bought)) player.perk_bought = 0;//initializes here when needed if(!isDefined(player.perklimit)) player.perklimit = 4;//initializes here when needed if(player.perk_bought >= player.perklimit){ player iPrintLn("Perk Limit Hit"): continue; } if(!isDefined(player.buying_perk) || player.buying_perk == false) { self thread vending_trigger_drink(player); self thread player_perk_think_timer(); player.perk_bought++; } } }
Since you changed it to level vars instead of player you will need to change this also:
Code Snippet
Plaintext
if(!isDefined(player.perklimit)) player.perklimit = 4;//initializes here when needed if(player.perk_bought >= player.perklimit){
to this:
Code Snippet
Plaintext
if(!isDefined(level.perklimit)) level.perklimit = 4;//initializes here when needed if(player.perk_bought >= level.perklimit){
The initialization prob isn't needed, since you added it to the other script, but will not hurt to have it here too, but without it in the other script you risk resetting perk limits when buying a perk. So make sure you have the level.perklimit in the other script where you put the player ones before and it didn't' work. it will work as a level var though.
Last Edit: September 17, 2015, 02:00:10 pm by MakeCents
Since you changed it to level vars instead of player you will need to change this also:
Code Snippet
Plaintext
if(!isDefined(player.perklimit)) player.perklimit = 4;//initializes here when needed if(player.perk_bought >= player.perklimit){
to this:
Code Snippet
Plaintext
if(!isDefined(level.perklimit)) level.perklimit = 4;//initializes here when needed if(player.perk_bought >= level.perklimit){
The initialization prob isn't needed, since you added it to the other script, but will not hurt to have it here too, but without it in the other script you risk resetting perk limits when buying a perk. So make sure you have the level.perklimit in the other script where you put the player ones before and it didn't' work. it will work as a level var though.
Okay, it works now! But there is one issue. To remove the perk buying delay, I had to move rest of the function to new function, as seen from comment before. This happens, when Im buying perk and I keep hitting the trigger: That makes me hit the perklimit immediately (Not sure, if it hits it with one hit or multiple, but spamming it = instant perklimit hit)
You've chosen to add or increase the perk limit var as you buy perks and then reset it when you die or go down. These are the things I spoke of earlier. This is the reason I don't do it that way and I use hasperk or Dukips idea of getting the hud size will work too if you use the same hud array for all your perks. This means you change your if to what Dukip said, with the ifDefined added to it. Or you use what I made. Both should work.
With that being said, you put your increment player.perk_bought++; in the right place where that should not be happening if player.buying_perk is defined, so it must not be.
Add iprintlinbold statments to the if right below that iprintlnbold and print the value of each level.perklimit, and player.perk_bought. This will verify that the numbers are working correctly and that your issue is that it is incrementing when you spam the button.
Its up to you how you wish to resolve that issue. - move that increment line to another area, like where the shader gets added down below in the perk more. - fix the buying_perk attribute - switch to using the hud size method.
Edit: If you want, send me the scripts and I will just do this for you. Some people hate scripting, lol. But if you want to continue learning, I don't mind trying to help.
Last Edit: September 17, 2015, 05:18:52 pm by MakeCents
You've chosen to add or increase the perk limit var as you buy perks and then reset it when you die or go down. These are the things I spoke of earlier. This is the reason I don't do it that way and I use hasperk or Dukips idea of getting the hud size will work too if you use the same hud array for all your perks. This means you change your if to what Dukip said, with the ifDefined added to it. Or you use what I made. Both should work.
With that being said, you put your increment player.perk_bought++; in the right place where that should not be happening if player.buying_perk is defined, so it must not be.
Add iprintlinbold statments to the if right below that iprintlnbold and print the value of each level.perklimit, and player.perk_bought. This will verify that the numbers are working correctly and that your issue is that it is incrementing when you spam the button.
Its up to you how you wish to resolve that issue. - move that increment line to another area, like where the shader gets added down below in the perk more. - fix the buying_perk attribute - switch to using the hud size method.
Edit: If you want, send me the scripts and I will just do this for you. Some people hate scripting, lol. But if you want to continue learning, I don't mind trying to help.
Moved it under player perk_hud_create( perk ); and it works now perfectly! Best answer given and +1, since now I know better how to use level.stuff = something; and player.stuff = something; Credits will be also given in update