Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Skill Script Help


Dastyruck
 Share

Recommended Posts

Alright, I made this skill script for woodcutting which is being called by a scripted tile.

I have it so if the player doesnt have any data it creates data but this isnt working at all.

If someone has data it works, but if they dont… it doesnt work... sooooo...

Here is the code.

```
'********************************
Sub WoodCut(index)
'********************************
Dim success
Dim slot
Dim number 
Dim level 
Dim times

number = 8
slot = 1
level = Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level")
success = Rand(Int(level), 5)
times = Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times")
If Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level") <> "" Then
    Call PlayerMsg(index, "If", GREEN)
    If success = 1 Then
        Do While slot < 25
        If Getplayerinvitemnum( index, Int( slot ) ) = Int( number ) Then
            Call SetPlayerInvItemNum(index, Int( slot ), Int( number ) )
            Call SetPlayerInvItemValue(index, Int( slot ), Int(1) )
            Call SendInventoryUpdate(index, Int(slot) )
            slot = 25
        End If
        slot = slot + 1
        Loop 
        Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times",Int( times ) + 1)
        If times = 50 Then
            If level < 4 Then
                Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level",Int( level) + 1)
                Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times",0)
            End If
        End If   
        Call PlayerMsg(index, "You successfully harvested 1 wood!", GREEN) 

    Else
    Call PlayerMsg(index, "You did not harvest any wood.", GREEN)
    End If

Else
Call PlayerMsg(index, "Else", GREEN)
    times = 0
    level = 1
    Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level",Int(level)+0)
    Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times",Int(times)+0)

    number = 8
    slot = 1
    level = Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level")
    success = Rand(Int(level), 5)
    times = Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times")

    If success = 1 Then
        Do While slot < 25
        If Getplayerinvitemnum( index, Int( slot ) ) = 0 Then
            Call SetPlayerInvItemNum(index, Int( slot ), Int( number ) )
            Call SetPlayerInvItemValue(index, Int( slot ), Int(1) )
            Call SendInventoryUpdate(index, Int(slot) )
            slot = 25
        End If
        slot = slot + 1
        Loop 
        Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times",Int( times ) + 1)
        If times = 50 Then
            If level < 4 Then
                Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","level",Int( level) + 1)
                Call Putvar("scripts\charextras\" & GetPlayerName(index) & ".ini","woodcut","times",0)
            End If
        End If

        Call PlayerMsg(index, "You successfully harvested 1 wood!", GREEN) 

    Else
    Call PlayerMsg(index, "You did not harvest any wood.", GREEN)
    End If

End If
Call PlayerMsg(index, "End", GREEN)
End Sub
```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...