当前位置 : 145z游戏站 | 热血传奇 | 传奇游戏 | 

新开传奇996引擎架设,超实用脚本推荐大全(二)

热度:
###商店脚本

####普通物品商店脚本
此脚本用于创建一个普通的物品商店,玩家可以在商店中购买和出售物品。
```lua
--定义商店物品列表
localshopItems={
{id=1name="长剑"price=100sellPrice=50}
{id=2name="皮甲"price=200sellPrice=100}
{id=3name="小血瓶"price=20sellPrice=10}
}

--打开商店界面
functionOpenShop(player)
player:SendMessage("欢迎来到商店!")
for_iteminipairs(shopItems)do
player:SendMessage(item.id.."."..item.name.."-售价:"..item.price.."金币,回收价:"..item.sellPrice.."金币")
end
player:SendMessage("请输入物品ID进行购买,输入负数ID进行出售,输入0退出商店。")
end

--处理玩家购买和出售请求
functionHandleShopRequest(playerinput)
ifinput==0then
player:SendMessage("感谢光临,再见!")
return
end

localitemId=math.abs(input)
localisBuy=input>0

for_iteminipairs(shopItems)do
ifitem.id==itemIdthen
ifisBuythen
ifplayer:GetGold()>=item.pricethen
player:ReduceGold(item.price)
player:AddItem(item.id)
player:SendMessage("你成功购买了"..item.name)
else
player:SendMessage("你的金币不足,无法购买。")
end
else
ifplayer:HasItem(item.id)then
player:RemoveItem(item.id)
player:AddGold(item.sellPrice)
player:SendMessage("你成功出售了"..item.name)
else
player:SendMessage("你没有该物品,无法出售。")
end
end
return
end
end
player:SendMessage("无效的物品ID,请重新输入。")
end

--与商店NPC交互事件
functionOnPlayerTalkToShopNPC(playernpc)
OpenShop(player)
player:RegisterInputCallback(HandleShopRequest)
end

--注册NPC交互事件
RegisterEvent("OnPlayerTalkToShopNPC"OnPlayerTalkToShopNPC)
```

####特殊物品限时商店脚本
该脚本创建一个限时开放的特殊物品商店,增加游戏的趣味性和紧张感。
```lua
--定义限时商店物品列表
locallimitedShopItems={
{id=10name="神秘戒指"price=500startTime="21:00"endTime="22:00"}
{id=11name="高级技能书"price=800startTime="22:00"endTime="23:00"}
}

--检查商店是否开放
functionIsShopOpen(item)
localcurrentTime=GetCurrentTimeString()
returncurrentTime>=item.startTimeandcurrentTime<item.endTime
end

--打开限时商店界面
functionOpenLimitedShop(player)
player:SendMessage("欢迎来到限时商店!")
for_iteminipairs(limitedShopItems)do
ifIsShopOpen(item)then
player:SendMessage(item.id.."."..item.name.."-售价:"..item.price.."金币")
end
end
player:SendMessage("请输入物品ID进行购买,输入0退出商店。")
end

--处理玩家购买请求
functionHandleLimitedShopRequest(playerinput)
ifinput==0then
player:SendMessage("感谢光临,再见!")
return
end

for_iteminipairs(limitedShopItems)do
ifitem.id==inputandIsShopOpen(item)then
ifplayer:GetGold()>=item.pricethen
player:ReduceGold(item.price)
player:AddItem(item.id)
player:SendMessage("你成功购买了"..item.name)
else
player:SendMessage("你的金币不足,无法购买。")
end
return
end
end
player:SendMessage("无效的物品ID或商店未开放,请重新输入。")
end

--与限时商店NPC交互事件
functionOnPlayerTalkToLimitedShopNPC(playernpc)
OpenLimitedShop(player)
player:RegisterInputCallback(HandleLimitedShopRequest)
end

--注册NPC交互事件
RegisterEvent("OnPlayerTalkToLimitedShopNPC"OnPlayerTalkToLimitedShopNPC)
```

###传送脚本

####普通地图传送脚本
玩家可以通过与传送NPC交互,传送到指定的地图。
```lua
--定义传送地点列表
localteleportLocations={
{id=1mapName="新手村"x=100y=200}
{id=2mapName="矿洞"x=50y=80}
}

--打开传送界面
functionOpenTeleportMenu(player)
player:SendMessage("欢迎使用传送服务!")
for_locationinipairs(teleportLocations)do
player:SendMessage(location.id..".传送到"..location.mapName)
end
player:SendMessage("请输入传送地点ID,输入0取消传送。")
end

--处理玩家传送请求
functionHandleTeleportRequest(playerinput)
ifinput==0then
player:SendMessage("传送已取消。")
return
end

for_locationinipairs(teleportLocations)do
iflocation.id==inputthen
player:Teleport(location.mapNamelocation.xlocation.y)
player:SendMessage("你已成功传送到"..location.mapName)
return
end
end
player:SendMessage("无效的传送地点ID,请重新输入。")
end

--与传送NPC交互事件
functionOnPlayerTalkToTeleportNPC(playernpc)
OpenTeleportMenu(player)
player:RegisterInputCallback(HandleTeleportRequest)
end

--注册NPC交互事件
RegisterEvent("OnPlayerTalkToTeleportNPC"OnPlayerTalkToTeleportNPC)
```

####等级限制传送脚本
某些地图需要玩家达到一定等级才能传送进入。
```lua
--定义等级限制传送地点列表
locallevelLimitedTeleportLocations={
{id=1mapName="中级地图"x=200y=300requiredLevel=20}
{id=2mapName="高级地图"x=150y=250requiredLevel=50}
}

--打开等级限制传送界面
functionOpenLevelLimitedTeleportMenu(player)
player:SendMessage("欢迎使用等级限制传送服务!")
for_locationinipairs(levelLimitedTeleportLocations)do
ifplayer:GetLevel()>=location.requiredLevelthen
player:SendMessage(location.id..".传送到"..location.mapName)
else
player:SendMessage(location.id..".传送到"..location.mapName.."(需要等级"..location.requiredLevel..")")
end
end
player:SendMessage("请输入传送地点ID,输入0取消传送。")
end

--处理玩家传送请求
functionHandleLevelLimitedTeleportRequest(playerinput)
ifinput==0then
player:SendMessage("传送已取消。")
return
end

for_locationinipairs(levelLimitedTeleportLocations)do
iflocation.id==inputthen
ifplayer:GetLevel()>=location.requiredLevelthen
player:Teleport(location.mapNamelocation.xlocation.y)
player:SendMessage("你已成功传送到"..location.mapName)
else
player:SendMessage("你的等级不足,无法传送到"..location.mapName)
end
return
end
end
player:SendMessage("无效的传送地点ID,请重新输入。")
end

--与等级限制传送NPC交互事件
functionOnPlayerTalkToLevelLimitedTeleportNPC(playernpc)
OpenLevelLimitedTeleportMenu(player)
player:RegisterInputCallback(HandleLevelLimitedTeleportRequest)
end

--注册NPC交互事件
RegisterEvent("OnPlayerTalkToLevelLimitedTeleportNPC"OnPlayerTalkToLevelLimitedTeleportNPC)
```

这些脚本进一步丰富了传奇游戏的玩法和功能,在使用时同样要依据996引擎的实际情况进行调整。
[顶部]