Jump to content

Problem with Perk point script


Magnusen2

Recommended Posts

Ok so i created a perk point script to use in my mod.

 

 

Scriptname xxxPerkPointBook extends ObjectReference  



Message Property PerkMessage  Auto  



Event OnEquipped(Actor reader)

    Int PerkPoints = game.GetPerkPoints()

    if (reader != Game.GetPlayer())
        return
    endif

    
int ibutton = PerkMessage.show()

if reader != game.GetPlayer()
    if ibutton == 0
        if PerkPoints <= 253                            
            Game.ModPerkPoints(1)
            debug.Notification("Perk point added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif ibutton == 1
        if PerkPoints <= 251                            
            Game.ModPerkPoints(3)
            debug.Notification("3 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif ibutton == 2
        if PerkPoints <= 249                            
            Game.ModPerkPoints(5)
            debug.Notification("5 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif ibutton == 3
        if PerkPoints <= 244                            
            Game.ModPerkPoints(10)
            debug.Notification("10 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif ibutton == 4
        if PerkPoints <= 229                            
            Game.ModPerkPoints(25)
            debug.Notification("25 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif ibutton == 5
        if PerkPoints <= 204                            
            Game.ModPerkPoints(50)
            debug.Notification("50 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif ibutton == 6
        if PerkPoints > 0                            
            Game.ModPerkPoints(0)
            debug.Notification("All perk points removed")
        else
            debug.Notification("You don't have perk points to remove")
        endif
        
    
    endif
    
endif

EndEvent

 

 

 

It functions through a book that displays a message box in which the user can select how many points he wants.

 

The problem: The message displays fine but no notification nor perk points is given to the user.

 

Any help on this?

Edited by Magnusen2
Link to comment
Share on other sites

The line immediately after showing the message says that the rest of the script should only execute if the reader is not the player.

Removed that line.

 

 

Message Property zxxxPerkPointBookMessage  Auto  


Function OnEquipped(Actor reader)

    Int PerkPoints = game.GetPerkPoints()

    if reader != game.GetPlayer()
        return
    endIf
    
    Int iButton = zxxxPerkPointBookMessage.show()
    if iButton == 0
        if PerkPoints <= 253                            
            Game.ModPerkPoints(1)
            debug.Notification("Perk point added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif iButton == 1
        if PerkPoints <= 251                            
            Game.ModPerkPoints(3)
            debug.Notification("3 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif iButton == 2
        if PerkPoints <= 249                            
            Game.ModPerkPoints(5)
            debug.Notification("5 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif iButton == 3
        if PerkPoints <= 244                            
            Game.ModPerkPoints(10)
            debug.Notification("10 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif iButton == 4
        if PerkPoints <= 229                            
            Game.ModPerkPoints(25)
            debug.Notification("25 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
    
    
    elseif iButton == 5
        if PerkPoints <= 204                            
            Game.ModPerkPoints(50)
            debug.Notification("50 perk points added")
        else
            debug.Notification("You can't add more perk points")
        endif
        
        
    elseif iButton == 6
        if PerkPoints > 0                            
            Game.ModPerkPoints(0)
            debug.Notification("All perk points removed")
        else
            debug.Notification("You don't have perk points to remove")
        endif
        
    endif
    
EndFunction

 

 

But now there's another problem. When i read the book a notification appears that one perk point was added, but the message box that was supposed to appear to let the player choose how many points he wants doesn't.

Link to comment
Share on other sites

If the message property isn't filled the Show() function always returns 0 which would give one perk point in your code. Double check that the property is filled. And make sure you aren't testing on a save game that had seen a previous version of that script where that property wasn't filled. Property values get stored with a saved game.

Link to comment
Share on other sites

If the message property isn't filled the Show() function always returns 0 which would give one perk point in your code. Double check that the property is filled. And make sure you aren't testing on a save game that had seen a previous version of that script where that property wasn't filled. Property values get stored with a saved game.

Started a new game and the message shows up. It looks like the book is busted for my previous playthrough.

Thanks everyone.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...