Eclipse
January 05, 2009, 11:23:45 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Congratulations Adulese.
Eclipse Desktop Contest
 
   Home   Chat Help Rules Arcade Search Calendar Gallery Login Register  
 
 
 
Recent Topics +-
I'm New/Back/Leaving! by <insert username here>
Today at 11:23:43 PM

Big city... by MrMiguu™
Today at 11:23:12 PM

My Custom GUI by kira423
Today at 11:23:11 PM

Rate the above user by HawkStorm95
Today at 11:23:10 PM

Necesito mappers y scripter para un proyecto de Zelda de alta calidad by The Roujo
Today at 11:23:03 PM

Count to 1,000,000! by kira423
Today at 11:20:57 PM

Combine Usernames! by kira423
Today at 11:19:05 PM

Last one to post Wins by <insert username here>
Today at 11:18:30 PM

Eclipse Desktop Contest by Marsh
Today at 11:14:33 PM

Party system : is it possible? by MrMiguu™
Today at 11:13:28 PM

Members Online +-
9 Guests, 14 Users
<insert username here>,
Devogen,
The Roujo,
Kreator,
kira423,
MrMiguu™,
HawkStorm95,
FS:CG Admin[Shadowwulf],
Baron,
‪‫‬‭‮‪‫Kusy,
Marsh,
Simius Cruentus,
Leaf [zach],
Karl
Pages: [1]
  Print  
Author Topic: Dice Rolling Game (script submission, 2/5 difficulty)  (Read 1468 times)
0 Members and 1 Guest are viewing this topic.
Ilnair
The Uber-Scriptor
Advanced Member
****
Offline Offline

Posts: 592


The Uber-Scriptor


View Profile WWW Email
« on: June 16, 2006, 05:46:38 AM »

And another nice script from me.

Difficulty:
Newb: 2/5
Advanced Scripter: 0/5
Me/Unnown/Baron (:D): like -200/5
In short, very easy to use script.


It works like this, inside a casino, a player can buy Game Coins, and a Game Dice. If a player uses the dice, he will lose 1 game coin (or a few, it depends on what you want). After that, 2 dices will roll, and if the number rolled is higher than the number the computer rolled previously, you'll win 60% of all Game Coins players lost by rolling the dice. If he loses, his coin will be gone, and someone else can try it.

Anyway, here it goes.

Step 1: Create a game dice. Make it a scripted item, and make it run script X (ie: 1 or 2).

Step 2: Find Sub ScriptedItem, and add the following below End Select:
Code: [Select]
Case X
    Call CasinoDiceGame(index)
Exit Sub

And replace X by the number you used. If you can not find Sub ScriptedItem, please enter this at the bottom of you main:
Code: [Select]
Sub ScriptedItem(index, Script)
Select Case Script
Case X
    Call CasinoDiceGame(index)
Exit Sub
End Select
End Sub

And once again, replace X by the number you used.


Step 3: enter the following script at the bottom of your main, and replace cost=int(1) by the number of coins you want gambling to cost, and replace Int(83) by the item number of your game coins:

Code: [Select]
'****************************************************************
'Dice Script, ©Dinand Mentink - ILNAIR!!!!!
'****************************************************************

Sub CasinoDiceGame(index)
Dim diceroll1
Dim diceroll2
Dim diceroll
Dim prevroll
Dim item
Dim itemvalue
Dim itemslot
Dim jackpot
Dim cost
Dim prevroller

cost = Int(1)
item = Int(83)
itemslot = Int(GetPlayerInvItemSlot(index, item))

If itemslot = 0 Then
Call PlayerMsg(index, "You do not have any Game Coins!", 12)
Exit Sub
End If

itemvalue = Int(GetPlayerInvItemValue(index, itemslot))

If itemvalue < cost Then
Call PlayerMsg(index, "You do not have enough Game Coins to play!", 12)
Exit Sub
Else
prevroller = GetVar("vars.ini", "Dice", "prevroller")

If prevroller = GetPlayerName(index) Then
Call PlayerMsg(index, "Give someone else a chance!", 12)
Exit Sub
End If

Call PutVar("vars.ini", "Dice", "prevroller", GetPlayerName(index))

prevroll = Int(GetVar("vars.ini", "Dice", "prevroll"))
jackpot = Int(GetVar("vars.ini", "Dice", "jackpot"))

diceroll1 = Int((6 - 1 + 1) * Rnd) + 1
diceroll2 = Int((6 - 1 + 1) * Rnd) + 1
diceroll = Int(diceroll1 + diceroll2)

If diceroll > prevroll Then
Call GlobalMsg(GetPlayerName(index) & " rolls the powerdice and" & " rolls a " & diceroll1 & " and a " & diceroll2 & "! This is " & diceroll & " in total and wins!", 10)
Else
Call GlobalMsg(GetPlayerName(index) & " rolls the powerdice and" & " rolls a " & diceroll1 & " and a " & diceroll2 & "! This is " & diceroll & " in total and loses!", 12)
jackpot = Int(jackpot + cost)
Call PutVar("vars.ini", "Dice", "jackpot", "" & jackpot)
Call GlobalMsg("The jackpot is " & Int(jackpot * 0.6) + 1 & " Game Coins for a " & prevroll + 1 & "!", 14)

If itemvalue = cost Then
Call SetPlayerInvItemNum(index, itemslot, 0)
Call SetPlayerInvItemValue(index, itemslot, 0)
Call SendInventoryUpdate(index, itemslot)
Else
Call SetPlayerInvItemValue(index, itemslot, itemvalue - cost)
Call SendInventoryUpdate(index, itemslot)
End If

Exit Sub
End If

itemslot = GetPlayerInvItemSlot(index, item)

If itemslot = 0 Then
itemslot = GetPlayerInvItemSlot(index, item)
Call SetPlayerInvItemNum(index, itemslot, item)
Call SetPlayerInvItemValue(index, itemslot, Int(jackpot * 0.6) + 1)
Call SendInventoryUpdate(index, itemslot)
Else
Call SetPlayerInvItemValue(index, itemslot, itemvalue + Int(jackpot * 0.6))
Call SendInventoryUpdate(index, itemslot)
End If


prevroll = Int((11 - 5 + 1) * Rnd) + 5
Call PutVar("vars.ini", "Dice", "prevroll", "" & prevroll)
jackpot = Int((3 - 1 + 1) * Rnd) + 1
Call PutVar("vars.ini", "Dice", "jackpot", "" & jackpot)
Call GlobalMsg("The jackpot is " & Int(jackpot * 0.6) + 1 & " Game Coins for a " & prevroll + 1 & "!", 14)


End If

End SUb

'****************************************************************
'End of Dice Script!, ©Dinand Mentink - ILNAIR!!!!!
'****************************************************************

Step 4: create a .ini file called vars.ini, and put the following in it:
Code: [Select]
[Dice]
jackpot=1
prevroll=6
prevroller=Ilnair
Cantinfla
Mid Scripter
Member
**
Offline Offline

Posts: 40



View Profile Email
« Reply #1 on: July 18, 2006, 08:40:02 PM »

I tried and failed so I got a question, how you start the dice game?

Can i make it like if you step on a scripted tile, it plays the dice game?
Since i wana make a casino like place...
Ilnair
The Uber-Scriptor
Advanced Member
****
Offline Offline

Posts: 592


The Uber-Scriptor


View Profile WWW Email
« Reply #2 on: July 19, 2006, 09:29:02 AM »

Well, i'm using a scripted item, called dice. But you could make an npc/scripted tile/command, just run the same sub.
Lee_Dragoon
Active Member
***
Offline Offline

Posts: 167



View Profile Email
« Reply #3 on: July 20, 2006, 04:35:17 PM »

Yay! I love games for players! thank you!
RamBONE
Chit Chat God
Teh Uberleet
*****
Offline Offline

Posts: 3,876


Creative Scripter


View Profile Email
« Reply #4 on: November 11, 2007, 01:36:33 PM »

Is this right?

cost = Int(1)
item = Int(5)
itemslot = Int(GetPlayerInvItemSlot(index, item))

or is this right?

cost = 1
item = 5
itemslot = Int(GetPlayerInvItemSlot(index, item))



tell me please
Kiath
Newb
*
Offline Offline

Posts: 7


View Profile Email
« Reply #5 on: January 29, 2008, 07:19:48 PM »

Awsome!
RamBONE
Chit Chat God
Teh Uberleet
*****
Offline Offline

Posts: 3,876


Creative Scripter


View Profile Email
« Reply #6 on: January 29, 2008, 07:35:57 PM »

Awesome it is ;)

But try not to post when its not neccesary
Kiath
Newb
*
Offline Offline

Posts: 7


View Profile Email
« Reply #7 on: January 30, 2008, 09:29:32 AM »

sorry :-[
Jewel
Teh Awesomeness
Newb
*
Offline Offline

Posts: 12


i bet 3 dollars you are reading my personal text


View Profile Email
« Reply #8 on: February 16, 2008, 06:48:38 AM »

the script looks cool, i have no use for it but it still looks cool, great job!
Pages: [1]
  Print  
 
 

Powered by EzPortal
Powered by MySQL Powered by PHP Powered by SMF 2.0 Beta 4 | SMF © 2006–2008, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!
Page created in 0.333 seconds with 35 queries.