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

This sub isnt working. help please


JayT
 Share

Recommended Posts

hey im making a lottery/chest script but my on click sub dont seem to be working when i click the chest :huh:
```
' Executes when a player clicks on an OnClick tile.
Sub OnClick(Index, Script)
Dim Amount
Dim High
Dim Low

Low = 2
High = 50
Amount = Rand(Low, High)
Select Case Script
Case 0
Call PlayerMsg(Index, "No Use", WHITE)
Case 1
Call PlayerMsg(Index, "No Use", WHITE)
Case 2
If GetVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS") = 1 Then
Call GiveItem(Index, Amount, 1)
Call PlayerMsg(Index, "Congratulations you have used a Lottery Point!", WHITE)
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 0)
Else
Call PlayerMsg(Index, "You dont have a Lottery Point, you can obtain one from Mr Lucky!" BRIGHTRED)
End If

Case Else
Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```i got my OC set to case 2 but nothing happens! lol
Link to comment
Share on other sites

ok maybe this will help…... this is all the script that i have up to yet:

```
------------------
Lottery Script
------------------
'THIS GOES IN ONCLICK FOR CHEST'

Dim Amount
Dim High
Dim Low

Low = 2
High = 50
Amount = Rand(Low, High)

Case x
If GetVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS") = 1 Then
Call GiveItem(Index, Amount, 1)
Call PlayerMsg(Index, "Congratulations you have used a Lottery Point!", WHITE)
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 0)
Else
Call PlayerMsg(Index, "You dont have a Lottery Point, you can obtain one from Mr Lucky!", BRIGHTRED)
End If

'THIS GOES IN SCRIPTEDNPC'

Case x
If GetVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS") = 0 Then
Call Prompt(index, "Would you like to buy a Lottery Point?", 2)

Else
Call PlayerMsg(Index, "You already have a Lottery Point! Click a Chest to get a prize!", WHITE)

End If

'THIS GOES IN PROMPT UNDER THE FIRST "Select Case Value"'
Case x
If CanTake(Index, 82, 15) Then
Call TakeItem(Index, 82, 15)
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 1)

'THIS GOES IN PROMPT UNDER THE SECOND "Select Case Value"'
Case x
Call PlayerMsg(Index, "Ok then please come back later...", WHITE)

```
Link to comment
Share on other sites

@Bobosk:

> it probably is, aside from the fact you're checking if a string = an int, and the incorrect GiveItem syntax, not to mention, giveitem gives non-stackable items, so you need to use GiveCurrency

items 2-50 or non stackable. and the string thing works for my other scripts and the ones admiral did for me :huh:
Link to comment
Share on other sites

@Bobosk:

> then label your crap correctly, because the way you have it, looks like you're meaning to give them a random amount of gold.. as for the rest of your debugging, stick playermsgs everywhere

```
'THIS GOES IN ONCLICK FOR CHEST'

Dim Item
Dim High
Dim Low

Low = 2
High = 50
Item = Rand(Low, High)

Case x
If GetVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", "1") Then
Call GiveItem(Index, Item, 1)
Call PlayerMsg(Index, "Congratulations you have used a Lottery Point!", WHITE)
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 0)
Else
Call PlayerMsg(Index, "You dont have a Lottery Point, you can obtain one from Mr Lucky!", BRIGHTRED)
End If

```
Happy….. :icon_surprised:
Link to comment
Share on other sites

```
Call GiveItem(Index, Item, 1)
```I think you need to use itemnum() and reference your variable here.

Future note:
```
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 0)

```This is fine if the max lottery points is 1… if you want to carry more... then you need to reduce by 1, not set to 0.
Hint:putvar=getvar-1
Link to comment
Share on other sites

@~SW~:

> ```
> Call GiveItem(Index, Item, 1)
> ```I think you need to use itemnum() and reference your variable here.
>
> Future note:
> ```
> Call PutVar("Accounts\" & GetPlayerLogin(Index) & "\" & GetPlayerName(Index) & ".ini", "LOTTERY", "STATUS", 0)
>
> ```This is fine if the max lottery points is 1… if you want to carry more... then you need to reduce by 1, not set to 0.
> Hint:putvar=getvar-1

yer the max lotto points is 1… but the first part i dont get... do you mean GiveItem(Index, ItemNum(Item), 1)
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...