魔兽彩票系统脚本V2.0 by Golgorth
################################################################################
############Lottery by Golgorth##V2.0###########################################
################################################################################
##1.- 你需要在主目录下创建一个目录,名叫"lottery"
##2.- 你应该检查每个配置的内容以适合你的需要
## 你可以自定义NPC所说的话,奖励物品使用的时间
## 获奖中奖号码的彩票
##3.- 你需要添加这些: [lotsystem::winnumber $player] :this check ##
## 将其放到 startup.tcl 的 OnPlayerDeath 中 ##
## 以检查是否到了运行 winnernumber proc 的时候 ##
## 请小心地放入到正确的命名域(namespace)中 ,命名域是指你将代码放入到的目标脚本位置,而不是文件名
################################################################################
################################################################################
#这是 creatures.scp 中的彩票员,复制并修改id, 阵营以及模型,使其针对大部分的玩家
################################################################################
[creature 900101]
attack=2000 2000
name=彩券发行员
model=7311
faction=12
guild=国有彩券发行
type=7
family=7
questscript=lotterynpc
npcflags=07
faction=12
elite=3
level=60
maxhealth=10370
damage=1037 1659
maxmana=0
sell=30033 # 必须和 items.scp中添加的彩券ID一致
###################################################################
#这是在 items.scp 中的物品 #
###################################################################
[item 30033]
name=彩券
buyprice=10000
startquest=123002 # 必须和添加到 quest.scp 中的quest ID一致,其实就是一个获得以后激活的任务
questscript=lottery
stackable=1
class=12
classes=07FFF
flags=0800
material=-1
maxcount=1
model=31744
quality=1
races=01FF
sellprice=0
subclass=0
#########################################################
#添加到 quest.scp 中的内容(不要问为什么需要这个) #
#########################################################
[quest 123002]
name=彩券
objectives=获取你的彩券号码。
desc=准备好测试你的幸运指数了吗?
deliver=30033 1
src_item=30033
###########################################################
# 在tcl目录中创建文件 lotsystem.tcl,并将以下内容复制到该文件中 #
###########################################################
namespace eval lotsystem {
proc lotterynum { player } {
set pname [GetName $player]
set n1_list "1 2 3 4 5 6 7 8 9 0"
set n2_list "1 2 3 4 5 6 7 8 9 0"
set n3_list "1 2 3 4 5 6 7 8 9 0"
set num1 [lindex $n1_list [expr {int(rand()*[llength $n1_list])}]]
set num2 [lindex $n2_list [expr {int(rand()*[llength $n2_list])}]]
set num3 [lindex $n3_list [expr {int(rand()*[llength $n3_list])}]]
set number "$num1$num2$num3"
set file "lottery/$number"
if { [file exists "lottery/$number"] != 1} {
set id [open $file a+]
puts $id "$pname"
close $id
return "你的彩券号码是 $number"
}
set id [open $file a+]
puts $id "$pname"
close $id
return "你的彩券号码是 $number"
}
# You should change the hours and day to check if is time to run lotto and to delete the folder
proc winnumber { player } {
set hourtime [clock format [clock seconds] -format {%H}]
set daytime [clock format [clock seconds] -format {%u}]
set checkfile "lottery/checkfile"
if { [file exists "lottery/checkfile"] != 1 } {
if { ($hourtime == 16) && ($daytime == 1) } {
set n1_list "1 2 3 4 5 6 7 8 9 0"
set n2_list "1 2 3 4 5 6 7 8 9 0"
set n3_list "1 2 3 4 5 6 7 8 9 0"
set num1 [lindex $n1_list [expr {int(rand()*[llength $n1_list])}]]
set num2 [lindex $n2_list [expr {int(rand()*[llength $n2_list])}]]
set num3 [lindex $n3_list [expr {int(rand()*[llength $n3_list])}]]
set number "$num1$num2$num3"
set file "lottery/winnernumber"
if { [file exists "lottery/winnernumber"] != 1 } {
set id [open $file w+]
puts $id "$number"
close $id
set cf [open $checkfile w+]
puts $cf ""
close $cf
}
set id [open $file w+]
puts $id "$number"
close $id
set cf [open $checkfile w+]
puts $cf ""
close $cf
}
}
if { ($daytime == 7) && ($hourtime == 23) } {
file delete -force "lottery"
file mkdir "lottery"
}
return
}
proc readwinner { player } {
set pname [GetName $player]
set yes "lottery/$pname"
set thewinneris "winnernumber"
set file "lottery/$thewinneris"
if { [file exists "lottery/$thewinneris"] != 1 } { return "中奖号码还没有生成" }
set id [open $file r]
gets $id data
close $id
set secondfile "lottery/$data"
if { [file exists "lottery/$data"] != 1 } { return "本期没有任何人中奖." }
set secondid [open $secondfile r]
gets $secondid seconddata
close $secondid
set lines [split $seconddata \n]
set youwin [lsearch $seconddata $pname]
if { $youwin != -1 } {
if { [file exists "lottery/$pname"] != 1 } {
#Here you put the reward, use Item id.
AddItem $player 7
set cut [open $yes w+]
puts $cut "1"
close $cut
Say $player 0 "我中奖了!!"
}
}
return "中奖号是 $data,中奖的玩家有:$lines"
}
}
############################################################
#在tcl目录下创建文件 lottery.tcl,并将以下代码复制到文件中#
############################################################
namespace eval lottery {
proc QueryQuest { obj player questid } {
if { [GetQuestStatus $player $questid] != 4 } {
SendQuestReward $player $obj $questid "最棒的奖励!" "你是否真的想赌赌?"
SendGossipComplete $player
#SendQuestRequestItems $player $obj $questid "" "Activate your bet."
} else {
SendQuestDetails $player $obj $questid
}
}
proc QuestAccept { obj player questid } {
SendQuestReward $player $obj $questid "最棒的奖励!" "你是否真的想赌赌?"
SendGossipComplete $player
}
proc RequestReward { npc player questid } {
}
proc QuestChooseReward { obj player questid choose } {
lotsystem::lotterynum $player
}
proc OnOpen { obj player lootid } {
}
}
###########################################################
#在tcl目录下创建文件 lotterynpc.tcl,并将以下内容复制到该文件中 #
###########################################################
#--------------------------------------------------------
namespace eval lotterynpc {
}
#--------------------------------------------------------
proc lotterynpc::GossipHello { npc player } {
SendGossip $player $npc { text 0 "我想购买一张彩券" }\
{ text 0 "我中奖了吗?" }\
{ text 1 "我需要一些相关资料" }
}
#--------------------------------------------------------
# the lotsystem::winnumber $player is not very good here, so its better to put it in startup tcl in for example on playerdeath proc.
proc lotterynpc::GossipSelect { npc player option } {
switch $option {
0 { VendorList $player $npc }
1 { SendGossipComplete $player
lotsystem::winnumber $player
set win [lotsystem::readwinner $player ]
set resp "$win"
set news "text 0 \"$resp \n\n\n\""
set footer "text 2 \"Visit for more
Informations\""
SendGossip $player $npc $news \
$footer }
2 { SendGossip $player $npc { text 0 "你需要购买一张彩券(我正在贩卖),然后激活它。当彩券生效时,中奖号码将被通知并且发布在这里。如果你是中奖者,那么你将自动获得奖品。开奖时间在每周日 16:00。祝你中奖!!"} }
}
}
#--------------------------------------------------------
proc lotterynpc::QueryQuest { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestStatus { npc player } {
}
#--------------------------------------------------------
proc lotterynpc::QuestHello { npc player } {
}
#--------------------------------------------------------
proc lotterynpc::QuestSelect { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestAccept { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestChooseReward { npc player questid choose } {
}
#--------------------------------------------------------
proc lotterynpc::RequestReward { npc player questid } {
商业版发布站程序下载:发布站程序下载:
############Lottery by Golgorth##V2.0###########################################
################################################################################
##1.- 你需要在主目录下创建一个目录,名叫"lottery"
##2.- 你应该检查每个配置的内容以适合你的需要
## 你可以自定义NPC所说的话,奖励物品使用的时间
## 获奖中奖号码的彩票
##3.- 你需要添加这些: [lotsystem::winnumber $player] :this check ##
## 将其放到 startup.tcl 的 OnPlayerDeath 中 ##
## 以检查是否到了运行 winnernumber proc 的时候 ##
## 请小心地放入到正确的命名域(namespace)中 ,命名域是指你将代码放入到的目标脚本位置,而不是文件名
################################################################################
################################################################################
#这是 creatures.scp 中的彩票员,复制并修改id, 阵营以及模型,使其针对大部分的玩家
################################################################################
[creature 900101]
attack=2000 2000
name=彩券发行员
model=7311
faction=12
guild=国有彩券发行
type=7
family=7
questscript=lotterynpc
npcflags=07
faction=12
elite=3
level=60
maxhealth=10370
damage=1037 1659
maxmana=0
sell=30033 # 必须和 items.scp中添加的彩券ID一致
###################################################################
#这是在 items.scp 中的物品 #
###################################################################
[item 30033]
name=彩券
buyprice=10000
startquest=123002 # 必须和添加到 quest.scp 中的quest ID一致,其实就是一个获得以后激活的任务
questscript=lottery
stackable=1
class=12
classes=07FFF
flags=0800
material=-1
maxcount=1
model=31744
quality=1
races=01FF
sellprice=0
subclass=0
#########################################################
#添加到 quest.scp 中的内容(不要问为什么需要这个) #
#########################################################
[quest 123002]
name=彩券
objectives=获取你的彩券号码。
desc=准备好测试你的幸运指数了吗?
deliver=30033 1
src_item=30033
###########################################################
# 在tcl目录中创建文件 lotsystem.tcl,并将以下内容复制到该文件中 #
###########################################################
namespace eval lotsystem {
proc lotterynum { player } {
set pname [GetName $player]
set n1_list "1 2 3 4 5 6 7 8 9 0"
set n2_list "1 2 3 4 5 6 7 8 9 0"
set n3_list "1 2 3 4 5 6 7 8 9 0"
set num1 [lindex $n1_list [expr {int(rand()*[llength $n1_list])}]]
set num2 [lindex $n2_list [expr {int(rand()*[llength $n2_list])}]]
set num3 [lindex $n3_list [expr {int(rand()*[llength $n3_list])}]]
set number "$num1$num2$num3"
set file "lottery/$number"
if { [file exists "lottery/$number"] != 1} {
set id [open $file a+]
puts $id "$pname"
close $id
return "你的彩券号码是 $number"
}
set id [open $file a+]
puts $id "$pname"
close $id
return "你的彩券号码是 $number"
}
# You should change the hours and day to check if is time to run lotto and to delete the folder
proc winnumber { player } {
set hourtime [clock format [clock seconds] -format {%H}]
set daytime [clock format [clock seconds] -format {%u}]
set checkfile "lottery/checkfile"
if { [file exists "lottery/checkfile"] != 1 } {
if { ($hourtime == 16) && ($daytime == 1) } {
set n1_list "1 2 3 4 5 6 7 8 9 0"
set n2_list "1 2 3 4 5 6 7 8 9 0"
set n3_list "1 2 3 4 5 6 7 8 9 0"
set num1 [lindex $n1_list [expr {int(rand()*[llength $n1_list])}]]
set num2 [lindex $n2_list [expr {int(rand()*[llength $n2_list])}]]
set num3 [lindex $n3_list [expr {int(rand()*[llength $n3_list])}]]
set number "$num1$num2$num3"
set file "lottery/winnernumber"
if { [file exists "lottery/winnernumber"] != 1 } {
set id [open $file w+]
puts $id "$number"
close $id
set cf [open $checkfile w+]
puts $cf ""
close $cf
}
set id [open $file w+]
puts $id "$number"
close $id
set cf [open $checkfile w+]
puts $cf ""
close $cf
}
}
if { ($daytime == 7) && ($hourtime == 23) } {
file delete -force "lottery"
file mkdir "lottery"
}
return
}
proc readwinner { player } {
set pname [GetName $player]
set yes "lottery/$pname"
set thewinneris "winnernumber"
set file "lottery/$thewinneris"
if { [file exists "lottery/$thewinneris"] != 1 } { return "中奖号码还没有生成" }
set id [open $file r]
gets $id data
close $id
set secondfile "lottery/$data"
if { [file exists "lottery/$data"] != 1 } { return "本期没有任何人中奖." }
set secondid [open $secondfile r]
gets $secondid seconddata
close $secondid
set lines [split $seconddata \n]
set youwin [lsearch $seconddata $pname]
if { $youwin != -1 } {
if { [file exists "lottery/$pname"] != 1 } {
#Here you put the reward, use Item id.
AddItem $player 7
set cut [open $yes w+]
puts $cut "1"
close $cut
Say $player 0 "我中奖了!!"
}
}
return "中奖号是 $data,中奖的玩家有:$lines"
}
}
############################################################
#在tcl目录下创建文件 lottery.tcl,并将以下代码复制到文件中#
############################################################
namespace eval lottery {
proc QueryQuest { obj player questid } {
if { [GetQuestStatus $player $questid] != 4 } {
SendQuestReward $player $obj $questid "最棒的奖励!" "你是否真的想赌赌?"
SendGossipComplete $player
#SendQuestRequestItems $player $obj $questid "" "Activate your bet."
} else {
SendQuestDetails $player $obj $questid
}
}
proc QuestAccept { obj player questid } {
SendQuestReward $player $obj $questid "最棒的奖励!" "你是否真的想赌赌?"
SendGossipComplete $player
}
proc RequestReward { npc player questid } {
}
proc QuestChooseReward { obj player questid choose } {
lotsystem::lotterynum $player
}
proc OnOpen { obj player lootid } {
}
}
###########################################################
#在tcl目录下创建文件 lotterynpc.tcl,并将以下内容复制到该文件中 #
###########################################################
#--------------------------------------------------------
namespace eval lotterynpc {
}
#--------------------------------------------------------
proc lotterynpc::GossipHello { npc player } {
SendGossip $player $npc { text 0 "我想购买一张彩券" }\
{ text 0 "我中奖了吗?" }\
{ text 1 "我需要一些相关资料" }
}
#--------------------------------------------------------
# the lotsystem::winnumber $player is not very good here, so its better to put it in startup tcl in for example on playerdeath proc.
proc lotterynpc::GossipSelect { npc player option } {
switch $option {
0 { VendorList $player $npc }
1 { SendGossipComplete $player
lotsystem::winnumber $player
set win [lotsystem::readwinner $player ]
set resp "$win"
set news "text 0 \"$resp \n\n\n\""
set footer "text 2 \"Visit for more
Informations\""
SendGossip $player $npc $news \
$footer }
2 { SendGossip $player $npc { text 0 "你需要购买一张彩券(我正在贩卖),然后激活它。当彩券生效时,中奖号码将被通知并且发布在这里。如果你是中奖者,那么你将自动获得奖品。开奖时间在每周日 16:00。祝你中奖!!"} }
}
}
#--------------------------------------------------------
proc lotterynpc::QueryQuest { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestStatus { npc player } {
}
#--------------------------------------------------------
proc lotterynpc::QuestHello { npc player } {
}
#--------------------------------------------------------
proc lotterynpc::QuestSelect { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestAccept { npc player questid } {
}
#--------------------------------------------------------
proc lotterynpc::QuestChooseReward { npc player questid choose } {
}
#--------------------------------------------------------
proc lotterynpc::RequestReward { npc player questid } {
商业版发布站程序下载:发布站程序下载:
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论