Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
[Tutorial/AULA] Cash System Avançado/Loja Cash
+19
Monns
Chavesvga
Roronoa Zoro
Kuraudo
Lucas FM
KaiqueHunter
igordias2
ownims
Bender
Faabinhuu ;
Valentine
DeaN
Minato
BrunoFox
Jonny Day's
Lucky
Nietore
wallace123
Nanzin
23 participantes
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Tutoriais
Página 1 de 7
Página 1 de 7 • 1, 2, 3, 4, 5, 6, 7
[Tutorial/AULA] Cash System Avançado/Loja Cash
olá pessoal, mais uma vez eu aqui para apresentar mais uma "[aula/tutorial]". Dessa vez eu trago o meu sistema Exlusivo de Cash (Credito in_game) e uma Loja de cash tambem ;
Nome: Cash and Loja Cash System
Dificuldade: Avançado
Criador: Nanzin
- Nanzin por que criou esse sistema?
R: Bom Na Verdade eu tinha criado pro meu Projeto exclusivo (Hogwarts World Online), mais depois de ver uma grande demanda do uso do NP Master v3.0 decidi disponibiliza-lo! (e ensinar!);
Vamos começar com o Primeiro Script: Game_Party
- ScreenShot:
Subtitua o seu Atual Por esse:
- Código:
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 处理同伴的类。包含金钱以及物品的信息。本类的实例
# 请参考 $game_party。
#------------------------------------------------------------------------------
# * Edited By: Nanzin
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :actors # 角色
attr_reader :gold # 金钱
attr_reader :steps # 步数
attr_reader :cash
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 建立角色序列
@actors = []
# 初始化金钱与步数
@gold = 0
@cash = 0
@steps = 0
# 生成物品、武器、防具的所持数 hash
@items = {}
@weapons = {}
@armors = {}
end
#--------------------------------------------------------------------------
# ● 设置初期同伴
#--------------------------------------------------------------------------
def setup_starting_members
@actors = []
for i in $data_system.party_members
@actors.push($game_actors[i])
end
end
#--------------------------------------------------------------------------
# ● 设置战斗测试用同伴
#--------------------------------------------------------------------------
def setup_battle_test_members
@actors = []
for battler in $data_system.test_battlers
actor = $game_actors[battler.actor_id]
actor.level = battler.level
gain_weapon(battler.weapon_id, 1)
gain_armor(battler.armor1_id, 1)
gain_armor(battler.armor2_id, 1)
gain_armor(battler.armor3_id, 1)
gain_armor(battler.armor4_id, 1)
actor.equip(0, battler.weapon_id)
actor.equip(1, battler.armor1_id)
actor.equip(2, battler.armor2_id)
actor.equip(3, battler.armor3_id)
actor.equip(4, battler.armor4_id)
actor.recover_all
@actors.push(actor)
end
@items = {}
for i in 1...$data_items.size
if $data_items[i].name != ""
occasion = $data_items[i].occasion
if occasion == 0 or occasion == 1
@items[i] = 9999
end
end
end
end
#--------------------------------------------------------------------------
# ● 同伴成员的还原
#--------------------------------------------------------------------------
def refresh
# 游戏数据载入后角色对像直接从 $game_actors
# 分离。
# 回避由于载入造成的角色再设置的问题。
new_actors = []
for i in 0...@actors.size
if $data_actors[@actors[i].id] != nil
new_actors.push($game_actors[@actors[i].id])
end
end
@actors = new_actors
end
#--------------------------------------------------------------------------
# ● 获取最大等级
#--------------------------------------------------------------------------
def max_level
# 同伴人数为 0 的情况下
if @actors.size == 0
return 0
end
# 初始化本地变量 level
level = 0
# 求得同伴的最大等级
for actor in @actors
if level < actor.level
level = actor.level
end
end
return level
end
#--------------------------------------------------------------------------
# ● 加入同伴
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# 获取角色
actor = $game_actors[actor_id]
# 同伴人数未满 4 人、本角色不在队伍中的情况下
if @actors.size < 4 and not @actors.include?(actor)
# 添加角色
@actors.push(actor)
# 还原主角
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# ● 角色离开
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
# 删除觉得
@actors.delete($game_actors[actor_id])
# 还原主角
$game_player.refresh
end
#--------------------------------------------------------------------------
# ● 增加金钱 (减少)
# n : 金额
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = [[@gold + n, 0].max, 9999999].min
end
#--------------------------------------------------------------------------
# * gain_cash
# n = quantidade
#--------------------------------------------------------------------------
def gain_cash
@cash = [[@cash + n, 0].max, 9999999].min
end
#--------------------------------------------------------------------------
# * lose_cash
# n = quantidade
#--------------------------------------------------------------------------
def lose_cash(n)
gain_cash(-n)
end
#--------------------------------------------------------------------------
# ● 减少金钱
# n : 金额
#--------------------------------------------------------------------------
def lose_gold(n)
# 调用数值逆转 gain_gold
gain_gold(-n)
end
#--------------------------------------------------------------------------
# ● 增加步数
#--------------------------------------------------------------------------
def increase_steps
@steps = [@steps + 1, 9999999].min
end
#--------------------------------------------------------------------------
# ● 获取物品的所持数
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_number(item_id)
# 如果 hash 个数数值不存在就返回 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取武器所持数
# weapon_id : 武器 ID
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
# 如果 hash 个数数值不存在就返回 0
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取防具所持数
# armor_id : 防具 ID
#--------------------------------------------------------------------------
def armor_number(armor_id)
# 如果 hash 个数数值不存在就返回 0
return @armors.include?(armor_id) ? @armors[armor_id] : 0
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 9999999].min
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 9999999].min
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 9999999].min
end
end
#--------------------------------------------------------------------------
# ● 减少物品
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# 调用 gain_item 的数值逆转
gain_item(item_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少武器
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_weapon(weapon_id, n)
# 调用 gain_weapon 的数值逆转
gain_weapon(weapon_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少防具
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_armor(armor_id, n)
# 调用 gain_armor 的数值逆转
gain_armor(armor_id, -n)
end
#--------------------------------------------------------------------------
# ● 判断物品可以使用
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_can_use?(item_id)
# 物品个数为 0 的情况
if item_number(item_id) == 0
# 不能使用
return false
end
# 获取可以使用的时候
occasion = $data_items[item_id].occasion
# 战斗的情况
if $game_temp.in_battle
# 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
return (occasion == 0 or occasion == 1)
end
# 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
return (occasion == 0 or occasion == 2)
end
# -------------------------------------------------------------------------
# ● 是否可以装备判定
# -------------------------------------------------------------------------
def item_can_equip?(actor,item)
if actor.level<item.need_lv or
actor.str<item.need_str or
actor.dex<item.need_dex or
actor.agi<item.need_agi or
actor.int<item.need_int
return false
end
return true
end
# -------------------------------------------------------------------------
# ● 是否可以装备的详细判定(颜色设定)
# -------------------------------------------------------------------------
def item_can_equip01?(actor,item)
if actor.level < item.need_lv
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip02?(actor,item)
if actor.str < item.need_str
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip03?(actor,item)
if actor.dex < item.need_dex
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip04?(actor,item)
if actor.agi < item.need_agi
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip05?(actor,item)
if actor.int < item.need_int
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ● 清除全体的行动
#--------------------------------------------------------------------------
def clear_actions
# 清除全体同伴的行为
for actor in @actors
actor.current_action.clear
end
end
#--------------------------------------------------------------------------
# ● 可以输入命令的判定
#--------------------------------------------------------------------------
def inputable?
# 如果一可以输入命令就返回 true
for actor in @actors
if actor.inputable?
return true
end
end
return false
end
#--------------------------------------------------------------------------
# ● 全灭判定
#--------------------------------------------------------------------------
def all_dead?
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
return false
end
# 同伴中无人 HP 在 0 以上
for actor in @actors
if actor.hp > 0
return false
end
end
# 全灭
return true
end
#--------------------------------------------------------------------------
# ● 检查连续伤害 (地图用)
#--------------------------------------------------------------------------
def check_map_slip_damage
for actor in @actors
if actor.hp > 0 and actor.slip_damage?
actor.hp -= [actor.maxhp / 100, 1].max
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
$game_temp.gameover = $game_party.all_dead?
end
end
end
#--------------------------------------------------------------------------
# ● 对像角色的随机确定
# hp0 : 限制为 HP 0 的角色
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# 初始化轮流
roulette = []
# 循环
for actor in @actors
# 符合条件的场合
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# 获取角色职业的位置 [位置]
position = $data_classes[actor.class_id].position
# 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
n = 4 - position
# 添加角色的轮流 n 回
n.times do
roulette.push(actor)
end
end
end
# 轮流大小为 0 的情况
if roulette.size == 0
return nil
end
# 转轮盘赌,决定角色
return roulette[rand(roulette.size)]
end
#--------------------------------------------------------------------------
# ● 对像角色的随机确定 (HP 0)
#--------------------------------------------------------------------------
def random_target_actor_hp0
return random_target_actor(true)
end
#--------------------------------------------------------------------------
# ● 对像角色的顺序确定
# actor_index : 角色索引
#--------------------------------------------------------------------------
def smooth_target_actor(actor_index)
# 取得对像
actor = @actors[actor_index]
# 对像存在的情况下
if actor != nil and actor.exist?
return actor
end
# 循环
for actor in @actors
# 对像存在的情况下
if actor.exist?
return actor
end
end
end
#--------------------------------------------------------------------------
# ● 完整鼠标系统
#--------------------------------------------------------------------------
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
@mtp_x = mouse_x
@mtp_y = mouse_y
unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
#得到鼠标图标方向
$mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y) if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
else
#令鼠标图标为正常
$mouse_icon_id = 0 if @mouse_sta != 2
end
#单击鼠标时进行判断寻路或跟随
if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
unless $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
#初始化
@mouse_sta = 1
p_direction = 5
#检查鼠标处能否开启事件
event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
#若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
@mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
if @mouse_sta != 2
#鼠标状态不为跟随状态则取数据并初始化路径
trg_x = (mouse_x + $game_map.display_x / 4) / 32
trg_y = (mouse_y + $game_map.display_y / 4) / 32
@paths = []
@paths_id = 0
if event_start == 0 #若不能开启事件
if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
find_path = Find_Path.new
@paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
end
else #若能开启事件则改变角色朝向
@direction = p_direction
end
end
end
end
#开始移动
if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #排除无效情况
if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
case @paths[@paths_id] #判断路径
when 6
@last_move_x = true
move_right
@paths_id += 1
@direction = 6
when 4
@last_move_x = true
move_left
@paths_id += 1
@direction = 4
when 2
@last_move_x = false
move_down
@direction = 2
@paths_id += 1
when 8
@last_move_x = false
move_up
@direction = 8
@paths_id += 1
end
end
end
elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
if Mouse.press?(Mouse::LEFT) #持续按住鼠标
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #排除无效情况
#跟随方向判断并跟随
if @mtp_x > self.screen_x
if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < @mtp_x - self.screen_x
move_right
$mouse_icon_id = 16
@direction = 6
end
if @mtp_y - self.screen_y > @mtp_x - self.screen_x
move_down
$mouse_icon_id = 12
@direction = 2
end
if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
move_up
$mouse_icon_id = 18
@direction = 8
end
end
if @mtp_x < self.screen_x
if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < self.screen_x - @mtp_x
move_left
$mouse_icon_id = 14
@direction = 4
end
if @mtp_y - self.screen_y > self.screen_x - @mtp_x
move_down
$mouse_icon_id = 12
@direction = 2
end
if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
move_up
$mouse_icon_id = 18
@direction = 8
end
end
end
else #没状态的情况
$mouse_icon_id = 0
@mouse_sta = 0
@paths_id = @paths.size #终止寻路移动
end
end
self_update
end
end
#Mouse.init
#END { Mouse.exit }
- Explicaçoes desse Script:
-> nas linhas: 14 a 17 voce encontra os seguintes codigos:
- Código:
attr_reader :actors # 角色
attr_reader :gold # 金钱
attr_reader :steps # 步数
attr_reader :cash
- Nisso eu Estou Dizendo que a nova Variavel "cash" voce tem direitos apenas de leitura (reader);
-> Na Linha 26 voce encontra:
- Código:
@cash = 0
- com iss eu digo que o valor inicial do seu cash é 0!
-> Na Linha 142 voce encontra:
- Código:
def gain_cash
@cash = [[@cash + n, 0].max, 9999999].min
end
- no procedimento gain_cash estou dizendo que o cash será igual a ele mesmo mais o valor estipulado
e que seu maximo é 9999999
ex:
- Código:
$game_party.gain_cash(100)
-> na linha 149 voce encontra:
- Código:
def lose_cash(n)
gain_cash(-n)
end
- Nesse procedimento estou dizendo que perder cash é ganhar cash - o valor;
ex:
- Código:
$game_party.lose_cash(100)
entao basicamente fica: 100-100 = 0;
2º Script [NET] Network
- ScreenShot:
- Substitua o Seu por Esse:
- Código:
#===============================================================================
# ** Network - Manages network data.
#-------------------------------------------------------------------------------
# Author Me and Mr.Mo
# Modified Marlos Gama
# Version 2.0
# Date 11-04-06
# Modified² Nanzin
#===============================================================================
SDK.log("Network", "Mr.Mo and Me", "1.0", " 11-04-06")
p "TCPSocket script not found (class Network)" if not SDK.state('TCPSocket')
#-------------------------------------------------------------------------------
# Begin SDK Enabled Check
#-------------------------------------------------------------------------------
if SDK.state('TCPSocket') == true and SDK.state('Network')
module Network
class Main
#--------------------------------------------------------------------------
# * Attributes
#--------------------------------------------------------------------------
attr_accessor :socket
attr_accessor :pm
# getpm, pmname, writepm
# AUTHENFICATION = 0 => Authenficates
# ID_REQUEST = 1 => Returns ID
# NAME_REQUEST = 2 => Returns UserName
# GROUP_REQUEST = 3 => Returns Group
# CLOSE = 4 => Close, Stop Connection
# NET_PLAYER = 5 => Netplayers Data
# MAP_PLAYER = 6 => Mapplayers Data
# KICK = 7 => Kick a Player
# KICK ALL = 8 => Kick all Players
# REMOVE = 9 => Remove Player (CLOSE SYNONYM)
# SYSTEM = 10 => System (Var's and Switches)
# MOD_CHANGE = 11 => Message ot Day Change
# TRADE = 12 => Trade
# PRIVATE_CHAT = 13 => Private Chat
# = 14
# POKE = 15 => Poke Player
# SLAP = 16 => Decrease HP or SP PLayer
# SLAP ALL = 17 => Decrease Hp or SP ALL
# ADM - MOD = 18 => Admin/Mod Command Returns
# = 19
# TEST STOP = 20 => Connection Test End
#--------------------------------------------------------------------------
# * Initialiation
#--------------------------------------------------------------------------
def self.initialize
@players = {}
@mapplayers = {}
@netactors = {}
@pm = {}
@pm_lines = []
@user_test = false
@user_exist = false
@socket = nil
@nooprec = 0
@id = -1
@name = ""
@group = ""
@status = ""
@oldx = -1
@oldy = -1
@oldd = -1
@oldp = -1
@oldid = -1
@login = false
@pchat_conf = false
@send_conf = false
@trade_conf = false
@servername = ""
@pm_getting = false
@self_key1 = nil
@self_key2 = nil
@self_key3 = nil
@self_value = nil
@trade_compelete = false
@trading = false
@trade_id = -1
$party = Net_Party.new
end
#--------------------------------------------------------------------------
# * Returns Servername
#--------------------------------------------------------------------------
def self.servername
return @servername.to_s
end
#--------------------------------------------------------------------------
# * Returns Socket
#--------------------------------------------------------------------------
def self.socket
return @socket
end
#--------------------------------------------------------------------------
# * Returns UserID
#--------------------------------------------------------------------------
def self.id
return @id
end
#--------------------------------------------------------------------------
# * Returns UserName
#--------------------------------------------------------------------------
def self.name
return @name
end
#--------------------------------------------------------------------------
# * Returns current Status
#--------------------------------------------------------------------------
def self.status
return "" if @status == nil or @status == []
return @status
end
#--------------------------------------------------------------------------
# * Returns Group
#--------------------------------------------------------------------------
def self.group
if @group.downcase.include?("adm")
group = "admin"
elsif @group.downcase.include?("mod")
group = "mod"
else
group = "standard"
end
return group
end
#--------------------------------------------------------------------------
# * Returns Mapplayers
#--------------------------------------------------------------------------
def self.mapplayers
return {} if @mapplayers == nil
return @mapplayers
end
#--------------------------------------------------------------------------
# * Returns NetActors
#--------------------------------------------------------------------------
def self.netactors
return {} if @netactors == nil
return @netactors
end
#--------------------------------------------------------------------------
# * Returns Players
#--------------------------------------------------------------------------
def self.players
return {} if @players == nil
return @players
end
def self.map_empty?(map_id)
for p in @players.values
next if p.nil?
if p.map_id == map_id || $game_map.map_id == map_id
return false
end
end
return true
end
def self.map_number(map_id)
n = 0
for p in @players.values
next if p.nil?
if p.map_id == map_id
n += 1
end
end
if $game_map.map_id == map_id
n += 1
end
return n
end
def self.stone_team(team)
a = []
b = []
for p in @players.values
next if p.nil?
if p.map_id == 399
if p.x < 9
a.push(p)
else
b.push(p)
end
end
end
if $game_player.x < 9
a.push(p)
else
b.push(p)
end
if team == 1
return a
else
return b
end
end
#--------------------------------------------------------------------------
# * Destroys player
#--------------------------------------------------------------------------
def self.destroy(id)
!if $party.empty?
for i in 0..$party.members.size
if $party.members[i] != nil
name = $game_party.actors[0].name
Network::Main.pchat($party.members[i].netid,"[COM] [ET] #{name}")
Network::Main.pchat($party.members[i].netid,"#{name} saiu da party!")
#$Hud_Party.visible = false
#$Hud_Party.active = false
end
end
end
$party.party_exit
@players[id.to_s] = nil rescue nil
@mapplayers[id.to_s] = "" rescue nil
for player in @mapplayers
@mapplayers.delete(id.to_s) if player[0].to_i == id.to_i
end
for player in @players
@players.delete(id.to_s) if player[0].to_i == id.to_i
end
if $scene.is_a?(Scene_Map)
begin
$scene.spriteset[id].dispose unless $scene.spriteset[id].disposed?
rescue
nil
end
end
end
#--------------------------------------------------------------------------
# * Create A socket
#--------------------------------------------------------------------------
def self.start_connection(host, port)
@socket = TCPSocket.new(host, port)
end
#--------------------------------------------------------------------------
# * Asks for Id
#--------------------------------------------------------------------------
def self.get_id
@socket.send("<1>'req'</1>\n")
end
#--------------------------------------------------------------------------
# * Asks for name
#--------------------------------------------------------------------------
def self.get_name
@socket.send("<2>'req'</2>\n")
end
#--------------------------------------------------------------------------
# * Asks for Group
#--------------------------------------------------------------------------
def self.get_group
#@socket.send("<3>'req'</3>\n")
@socket.send("<check>#{self.name}</check>\n")
end
#--------------------------------------------------------------------------
# * Registers (Attempt to)
#--------------------------------------------------------------------------
def self.send_register(user,pass)
# Register with User as name, and Pass as password
@socket.send("<reges #{user}>#{pass}</reges>\n")
# Start Loop for Retrival
loop = 0
loop do
loop += 1
self.update
# Break If Registration Succeeded
break if @registered
# Break if Loop reached 10000
break if loop == 10000
end
end
#--------------------------------------------------------------------------
# * Asks for Network Version Number
#--------------------------------------------------------------------------
def self.retrieve_version
@socket.send("<ver>#{User_Edit::VERSION}</ver>\n")
end
#--------------------------------------------------------------------------
# * Asks for Message of the day
#--------------------------------------------------------------------------
def self.retrieve_mod
@socket.send("<mod>'request'</mod>\n")
end
#--------------------------------------------------------------------------
# * Asks for Login (and confirmation)
#--------------------------------------------------------------------------
def self.send_login(user,pass)
@socket.send("<login #{user}>#{pass}</login>\n")
end
#--------------------------------------------------------------------------
# * Send Errors
#--------------------------------------------------------------------------
def self.send_error(lines)
if lines.is_a?(Array)
for line in lines
@socket.send("<err>#{line}</err>\n")
end
elsif lines.is_a?(String)
@socket.send("<err>#{lines}</err>\n")
end
end
#--------------------------------------------------------------------------
# * Authenfication
#--------------------------------------------------------------------------
def self.amnet_auth
# Send Authenfication
@socket.send("<0>'e'</0>\n")
@auth = false
# Set Try to 0, then start Loop
try = 0
loop do
# Add 1 to Try
try += 1
loop = 0
# Start Loop for Retrieval
loop do
loop += 1
self.update
# Break if Authenficated
break if @auth
# Break if loop reaches 20000
break if loop == 20000
end
# If the loop was breaked because it reached 10000, display message
p "#{User_Edit::NOTAUTH}, Tentativa #{try} de #{User_Edit::CONNFAILTRY}" if loop == 20000
# Stop everything if try mets the maximum try's
break if try == User_Edit::CONNFAILTRY
# Break loop if Authenficated
break if @auth
end
# Go to Scene Login if Authenficated
$scene = Scene_Login.new if @auth
end
#--------------------------------------------------------------------------
# * Send Start Data
#--------------------------------------------------------------------------
def self.send_start
send = ""
# Send Username And character's Graphic Name
send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}';"
# Send guild of the player
send += "@guild = '#{$guild_name.to_s}';"
# Send gold
send += "@gold = '#{$game_party.item_number(Item_Ouro::Item_Id.to_i).to_s}';"
# Send Cash
send += "@cash = '#{$game_party.item_number(Item_Cash::Cash_Id.to_i).to_s}';"
# Send guild position of the player
send += "@position = '#{$guild_position.to_s}';"
# Send bandeira of the guild player
send += "@flag = '#{$flag.to_s}';"
# Send grupo of the player
send += "@grupo = '#{$game_party.actors[0].grupo}';"
# Send status ban of the player
send += "@ban = '#{$game_party.actors[0].ban}';"
# Send map mensage
send += "@chat_text = '#{$chat_text.to_s}';"
# Send level info
send += "@level_info = '#{$level_info.to_s}';"
# Send Exp
send += "@now_exp = '#{$game_party.actors[0].now_exp}';"
send += "@next_exp = '#{$game_party.actors[0].next_exp}';"
# Send genero
send += "@sexo = '#{$game_party.actors[0].sexo}';"
# Sends Map ID, X and Y positions
send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y};"
# Sends Name
send += "@nome = '#{$game_party.actors[0].name}';" if User_Edit::Bandwith >= 1
# Sends Direction
send += "@direction = #{$game_player.direction};" if User_Edit::Bandwith >= 2
# Sends Move Speed
send += "@move_speed = #{$game_player.move_speed};" if User_Edit::Bandwith >= 3
# Sends Requesting start
send += "@weapon_id = #{$game_party.actors[0].weapon_id};"
send += "@armor1_id = #{$game_party.actors[0].armor1_id};"
send += "@armor2_id = #{$game_party.actors[0].armor2_id};"
send += "@armor3_id = #{$game_party.actors[0].armor3_id};"
send += "@armor4_id = #{$game_party.actors[0].armor4_id};"
send += "@str = #{$game_party.actors[0].str};"
send += "@agi = #{$game_party.actors[0].agi};"
send += "@dex = #{$game_party.actors[0].dex};"
send += "@int = #{$game_party.actors[0].int};"
send += "@arma_n = '#{$arma_n.to_s}';"
send += "@escudo_n = '#{$escudo_n.to_s}';"
#if $data_weapons[$game_party.actors[0].weapon_id] != nil
#send += "@arma_atk = #{$data_weapons[$game_party.actors[0].weapon_id].name};"
#end
#if $data_armors[$game_party.actors[0].armor1_id] != nil
#send += "@escudo_def = #{$data_armors[$game_party.actors[0].armor1_id].name};"
#end
send += "start(#{self.id});"
@socket.send("<5>#{send}</5>\n")
self.send_newstats
#send_actor_start
end
#--------------------------------------------------------------------------
# * Return PMs
#-------------------------------------------------------------------------
def self.pm
return @pm
end
#--------------------------------------------------------------------------
# * Get PMs
#--------------------------------------------------------------------------
def self.get_pms
@pm_getting = true
@socket.send("<22a>'Get';</22a>\n")
end
Última edição por Nanzin em Qui Nov 24, 2011 10:17 pm, editado 2 vez(es)
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
Continuaçao Script...
Explicaçoes Script:
> na Linha 338 voce encontra:
observe atentamente a linha: 347 existe o seguinte codigo:
- nesse comando eu estou enviando a variavel de cash para o "servidor"!;
-> Na Linha 488 voce encontra as mesmas coisas, eu estou enviando novamente os comandos para o servidor!;
- Código:
#--------------------------------------------------------------------------
# * Update PMs
#--------------------------------------------------------------------------
def self.update_pms(message)
#Starts all the variables
@pm = {}
@current_Pm = nil
@index = -1
@message = false
#Makes a loop to look thru the message
for line in message
#If the line is a new PM
if line == "$NEWPM"
@index+=1
@pm[@index] = Game_PM.new(@index)
@message = false
#if the word has $to_from
elsif line == "$to_from" and @message == false
to_from = true
#if the word has $subject
elsif line == "$Subject" and @message == false
subject = true
#if the word has $message
elsif line == "$Message" and @message == false
@message = true
elsif @message
@pm[@index].message += line+"\n"
elsif to_from
@pm[@index].to_from = line
to_from = false
elsif subject
@pm[@index].subject = line
subject = false
end
end
@pm_getting = false
end
#--------------------------------------------------------------------------
# * Checks if the PM is still not get.
#--------------------------------------------------------------------------
def self.pm_getting
return @pm_getting
end
#--------------------------------------------------------------------------
# * Write PMs
#--------------------------------------------------------------------------
def self.write_pms(message)
send = message
@socket.send("<22d>#{send}</22d>\n")
end
#--------------------------------------------------------------------------
# * Delete All PMs
#--------------------------------------------------------------------------
def self.delete_all_pms
@socket.send("<22e>'delete'</22e>\n")
@pm = {}
end
#--------------------------------------------------------------------------
# * Delete pm(id)
#--------------------------------------------------------------------------
def self.delete_pm(id)
@pm.delete(id)
end
#--------------------------------------------------------------------------
# * Delete MapPlayers
#--------------------------------------------------------------------------
def self.mapplayers_delete
@mapplayers = {}
end
#--------------------------------------------------------------------------
# * Update Guild
#--------------------------------------------------------------------------
def self.update_guild
contents = "@guild = '#{$guild_name.to_s}';"
@socket.send("<5>#{contents}</5>\n")
end
#--------------------------------------------------------------------------
# * Send Requested Data
#--------------------------------------------------------------------------
def self.send_start_request(id)
send = ""
# Send Username And character's Graphic Name
send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}'; "
# Sends Map ID, X and Y positions
send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y}; "
# Sends Name
send += "@nome = '#{$game_party.actors[0].name}'; " if User_Edit::Bandwith >= 1
# Sends Direction
send += "@direction = #{$game_player.direction}; " if User_Edit::Bandwith >= 2
# Sends Move Speed
send += "@move_speed = #{$game_player.move_speed};" if User_Edit::Bandwith >= 3
send += "@weapon_id = #{$game_party.actors[0].weapon_id};"
send += "@armor1_id = #{$game_party.actors[0].armor1_id};"
send += "@armor2_id = #{$game_party.actors[0].armor2_id};"
send += "@armor3_id = #{$game_party.actors[0].armor3_id};"
send += "@armor4_id = #{$game_party.actors[0].armor4_id};"
send += "@guild = '#{$guild_name.to_s}';"
send += "@position = '#{$guild_position.to_s}';"
send += "@flag = '#{$flag.to_s}';"
send += "@grupo = '#{$game_party.actors[0].grupo}';"
send += "@ban = '#{$game_party.actors[0].ban}';"
send += "@chat_text = '#{$chat_text.to_s}';"
send += "@sexo = '#{$game_party.actors[0].sexo}';"
send += "@now_exp = '#{$game_party.actors[0].now_exp}';"
send += "@next_exp = '#{$game_party.actors[0].next_exp}';"
send += "@gold = '#{$game_party.item_number(Item_Ouro::Item_Id.to_i).to_s}';"
send += "@cash = '#{$game_party.item_number(Item_cash::Cash_Id.to_i).to_s}';"
send += "@str = #{$game_party.actors[0].str};"
send += "@agi = #{$game_party.actors[0].agi};"
send += "@dex = #{$game_party.actors[0].dex};"
send += "@int = #{$game_party.actors[0].int};"
send += "@level_info = '#{$level_info.to_s}';"
send += "@arma_n = '#{$arma_n.to_s}';"
send += "@escudo_n = '#{$escudo_n.to_s}';"
#if $data_weapons[$game_party.actors[0].weapon_id] != nil
#send += "@arma_atk = #{$data_weapons[$game_party.actors[0].weapon_id].name};"
#end
#if $data_armors[$game_party.actors[0].armor1_id] != nil
#send += "@escudo_def = #{$data_armors[$game_party.actors[0].armor1_id].name};"
#end
#@socket.send("<6a>#{id.to_i}</6a>\n")
@socket.send("<5>#{send}</5>\n")
#self.send_map
#self.send_actor_start
end
#--------------------------------------------------------------------------
# * Send Map Id data
#--------------------------------------------------------------------------
def self.send_map
send = ""
# Send Username And character's Graphic Name
send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}'; "
# Sends Map ID, X and Y positions
send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y}; "
# Sends Direction
send += "@direction = #{$game_player.direction};" if User_Edit::Bandwith >= 2
send += "@weapon_id = #{$game_party.actors[0].weapon_id};"
send += "@armor1_id = #{$game_party.actors[0].armor1_id};"
send += "@armor2_id = #{$game_party.actors[0].armor2_id};"
send += "@armor3_id = #{$game_party.actors[0].armor3_id};"
send += "@armor4_id = #{$game_party.actors[0].armor4_id};"
@socket.send("<5>#{send}</5>\n")
for player in @players.values
next if player.netid == -1
# If the Player is on the same map...
if player.map_id == $game_map.map_id and self.in_range?(player)
# Update Map Players
self.update_map_player(player.netid, nil)
elsif @mapplayers[player.netid.to_s] != nil
# Remove from Map Players
self.update_map_player(player.netid, nil, true)
end
end
end
#--------------------------------------------------------------------------
# * Calls a player to trade
#--------------------------------------------------------------------------
def self.trade_call(id)
@trade_compelete = false
@trading = true
@socket.send("<24>#{id}\n")
ids = self.id
@socket.send("<24c>@trade_id = #{ids}</24c>\n")
end
#--------------------------------------------------------------------------
# * Exit trade.
#--------------------------------------------------------------------------
def self.trade_exit(id)
@socket.send("<24>#{id}\n")
ids = self.id
@socket.send("<24d>trade_exit = #{ids}</24d>\n")
end
#--------------------------------------------------------------------------
# * Checks if the trade is compelete
#--------------------------------------------------------------------------
def self.trade_compelete
return @trade_compelete
end
#--------------------------------------------------------------------------
# * Checks the trade result
#--------------------------------------------------------------------------
def self.trading
return @trading
end
#--------------------------------------------------------------------------
# * Send Move Update
#--------------------------------------------------------------------------
def self.trade_add(kind,item_id,netid)
@socket.send("<25>#{netid}\n")
me = self.id
@socket.send("<25a>i_kind = #{kind}; i_id = #{item_id}; id = #{me};</25a>\n")
end
#--------------------------------------------------------------------------
# * Send Move Update
#--------------------------------------------------------------------------
def self.trade_remove(kind,item_id,netid)
@socket.send("<25>#{netid}\n")
me = self.id
@socket.send("<25b>i_kind = #{kind}; i_id = #{item_id}; id = #{me};</25b>\n")
end
#--------------------------------------------------------------------------
# * Send Trade REquest
#--------------------------------------------------------------------------
def self.trade_request(netid)
@socket.send("<25>#{netid}\n")
me = self.id
@socket.send("<25d>id = #{me};</25d>\n")
end
#--------------------------------------------------------------------------
# * Send accept trade
#--------------------------------------------------------------------------
def self.trade_accept(netid)
@socket.send("<25>#{netid}\n")
me = self.id
@socket.send("<25e>id = #{me};</25e>\n")
end
#--------------------------------------------------------------------------
# * Send cancel trade
#--------------------------------------------------------------------------
def self.trade_cancel(netid)
@socket.send("<25>#{netid}\n")
me = self.id
@socket.send("<25f>id = #{me};</25f>\n")
end
#--------------------------------------------------------------------------
# * Send Move Update
#--------------------------------------------------------------------------
def self.send_move_change
return if @oldx == $game_player.x and @oldy == $game_player.y
return if @mapplayers == {}
send = ""
# Increase Steps if the oldx or the oldy do not match the new ones
if User_Edit::Bandwith >= 1
send += "ic;" if @oldx != $game_player.x or @oldy != $game_player.y
end
# New x if x does not mathc the old one
if @oldx != $game_player.x
send += "@x = #{$game_player.x}; @tile_id = #{$game_player.tile_id};"
@oldx = $game_player.x
end
# New y if y does not match the old one
if @oldy != $game_player.y
send += "@y = #{$game_player.y}; @tile_id = #{$game_player.tile_id};"
@oldy = $game_player.y
end
# Send the Direction if it is different then before
if User_Edit::Bandwith >= 2
if @oldd != $game_player.direction
send += "@direction = #{$game_player.direction};"
@oldd = $game_player.direction
end
end
# Send everything that needs to be sended
@socket.send("<5>#{send}</5>\n") if send != ""
end
#--------------------------------------------------------------------------
# * Send Stats
#--------------------------------------------------------------------------
def self.send_newstats
hp = $game_party.actors[0].hp
maxhp = $game_party.actors[0].maxhp
sp = $game_party.actors[0].sp
maxsp = $game_party.actors[0].maxsp
agi = $game_party.actors[0].agi
eva = $game_party.actors[0].eva
pdef = $game_party.actors[0].pdef
mdef = $game_party.actors[0].mdef
level = $game_party.actors[0].level
a = $game_party.actors[0]
c = "["
m = 1
for i in a.states
next if $data_states[i] == nil
c += i.to_s
c += ", " if m != a.states.size
m += 1
end
c += "]"
stats = "@hp = #{hp}; @maxhp = #{maxhp}; @sp = #{sp}; @maxsp = #{maxsp}; @agi = #{agi}; @eva = #{eva}; @pdef = #{pdef}; @mdef = #{mdef}; @states = #{c}; @level = #{level}"
@socket.send("<5>#{stats}</5>\n")
end
#--------------------------------------------------------------------------
# * Send Gold
#--------------------------------------------------------------------------
def self.send_gold
gold = $game_party.gold
@socket.send("<5>@gold = #{gold}</5>\n")
end
#--------------------------------------------------------------------------
# * Send Cash
#--------------------------------------------------------------------------
def self.send_cash
cash = $game_party.cash
@socket.send("<5>@cash = #{cash}</5>\n")
end
#--------------------------------------------------------------------------
# * Close Socket
#--------------------------------------------------------------------------
def self.close_socket
return if @socket == nil
@socket.send("<9>#{self.id}</9>\n")
#@socket.send("<4>'Close'</4>\n")
#Se você fechar o jogo quando uma mensagem tiver aberta, quando retornar, ele não está travado
if $game_temp.message_window_showing
@message_window = Window_Message.new
@message_window.terminate_message
end
if $scene.is_a?(Scene_Connect)
end
if $scene.is_a?(Scene_Login)
end
#if $scene.is_a?(Scene_Register)
#end
if $scene.is_a?(Scene_Title)
end
#No jogo
if $scene.is_a?(Scene_Trade)
salvar
end
if $scene.is_a?(Scene_PChat)
salvar
end
if $scene.is_a?(Scene_Map)
salvar
if not $party.empty?
for i in 0..$party.members.size
if $party.members[i] != nil
if $parte_s == true
name = $game_party.actors[0].name
Network::Main.pchat($charzinho_id,"[COM] [ET] #{name}")
Network::Main.pchat($charzinho_id,"[COM] [EXIT] #{name}")
Network::Main.pchat($charzinho_id,"#{name} saiu da party!")
#$Hud_Party.visible = false
#$Hud_Party.active = false
else
name = $game_party.actors[0].name
Network::Main.pchat($party.members[i].netid,"[COM] [ET] #{name}")
Network::Main.pchat($party.members[i].netid,"[COM] [EXIT] #{name}")
Network::Main.pchat($party.members[i].netid,"#{name} saiu da party!")
#$Hud_Party.visible = false
#$Hud_Party.active = false
end
end
end
end
end
@socket.close
@socket = nil
end
#--------------------------------------------------------------------------
# * Change Messgae of the Day
#--------------------------------------------------------------------------
def self.change_mod(newmsg)
@socket.send("<11>#{newmsg}</11>\n")
end
#--------------------------------------------------------------------------
# * Private Chat Send
#--------------------------------------------------------------------------
def self.pchat(id,mesg)
@pchat_conf = false
# Send the Private Chat Id (without close!!! \<13a>)
@socket.send("<13a>#{id}\n")
# Send Priavte Chat Message
@socket.send("<13>#{mesg}</13>\n") #if @pchat_conf
#p "could not send #{mesg} to #{id}..." if not @pchat_conf
end
#--------------------------------------------------------------------------
# * Private Chat Send
#--------------------------------------------------------------------------
def self.mchat(id,mesg)
@mchat_conf = false
# Send the Chat Id (without close!!! \<21a>)
@socket.send("<21a>#{id}\n")
# Send Chat Message
@socket.send("<21>#{mesg}</21>\n")
end
#--------------------------------------------------------------------------
# * Check if the user exists on the network..
#--------------------------------------------------------------------------
def self.user_exist?(username)
# Enable the test
@user_test = true
@user_exist = false
# Send the data for the test
self.send_login(username.to_s,"*test*")
# Check for how to long to wait for data (Dependent on username size)
if username.size <= 8
# Wait 1.5 seconds if username is less then 8
for frame in 0..(1.5*40)
self.update
end
elsif username.size > 8 and username.size <= 15
# Wait 2.3 seconds if username is less then 15
for frame in 0..(2.3*40)
self.update
end
elsif username.size > 15
# Wait 3 seconds if username is more then 15
for frame in 0..(3*40)
self.update
end
end
# Start Retreival Loop
loop = 0
loop do
loop += 1
self.update
# Break if User Test was Finished
break if @user_test == false
# Break if loop meets 10000
break if loop == 10000
end
# If it failed, display message
p User_Edit::USERTFAIL if loop == 10000
# Return User exists if failed, or if it exists
return true if @user_exist or loop == 10000
return false
end
#--------------------------------------------------------------------------
# * Trade
#--------------------------------------------------------------------------
def self.trade(id,type,item,num=1,todo='gain')
# Gain is used for normal trade,
# Lose is used as Admin Command
# Check if you got item
case type
when 0
got = $game_party.item_number(item)
when 1
got = $game_party.weapon_number(item)
when 2
got = $game_party.armor_number(item)
end
# Print if not, return
p "#{User_Edit::DONTGOTTRADE} (trade: kind = #{type} id = #{item})" if got == 0 and todo == 'gain'
return if got == 0 and todo == 'gain'
p "#{User_Edit::NOTENOUGHTRADE} (trade: kind = #{type} id = #{item})" if got < num and todo == 'gain'
return if got < num and todo == 'gain'
@pchat_conf = false
# Send the Trade Id (without close!!! \<12a>)
@socket.send("<12a>#{id}\n")
@socket.send("<12>type=#{type} item=#{item} num=#{num} todo=#{todo}</12>\n")
case type
when 0
$game_party.lose_item(item,num) if todo == 'gain'
when 1
$game_party.lose_weapon(item, num) if todo == 'gain'
when 2
$game_party.lose_armor(item, num) if todo == 'gain'
end
end
#--------------------------------------------------------------------------
# * Send Result
#--------------------------------------------------------------------------
def self.send_result(id)
@socket.send("<result_id>#{id}</result_id>\n")
@socket.send("<result_effect>#{self.id}</result_effect>\n")
end
#--------------------------------------------------------------------------
# * Send Dead
#--------------------------------------------------------------------------
def self.send_dead
@socket.send("<9>#{self.id}</9>\n")
end
#--------------------------------------------------------------------------
# * Update Net Players
#--------------------------------------------------------------------------
def self.update_net_player(id, data)
# Turn Id in Hash into Netplayer (if not yet)
@players[id] ||= Game_NetPlayer.new
# Set the Global NetId if it is not Set yet
@players[id].do_id(id) if @players[id].netid == -1
# Refresh -> Change data to new data
@players[id].refresh(data)
# Return if the Id is Yourself
return if id.to_i == self.id.to_i
# Return if you are not yet on a Map
return if $game_map == nil
# If the Player is on the same map...
if @players[id].map_id == $game_map.map_id
# Update Map Players
self.update_map_player(id, data)
elsif @mapplayers[id] != nil
# Remove from Map Players
self.update_map_player(id, data, true)
end
end
#--------------------------------------------------------------------------
# * Update Map Players
#--------------------------------------------------------------------------
def self.update_map_player(id, data, kill=false)
# Return if the Id is Yourself
return if id.to_i == self.id.to_i
# If Kill (remove) is true...
if kill and @mapplayers[id] != nil
# Delete Map Player
@mapplayers.delete(id.to_i) rescue nil
if $scene.is_a?(Scene_Map)
$scene.spriteset.delete(id.to_i) rescue nil
end
$game_temp.spriteset_refresh = true
return
end
g = @mapplayers[id]
@mapplayers[id] ||= @players[id] if @players[id] != nil
# Turn Id in Hash into Netplayer (if not yet)
@mapplayers[id] ||= Game_NetPlayer.new
# Set the Global NetId if it is not Set yet
@mapplayers[id].netid = id if @mapplayers[id].netid == -1
# Refresh -> Change data to new data
@mapplayers[id].refresh(data)
#Send the player's new stats
self.send_newstats if g == nil
end
#--------------------------------------------------------------------------
# * Update Net Actors
#--------------------------------------------------------------------------
def self.update_net_actor(id,data,actor_id)
return
return if id.to_i == self.id.to_i
# Turn Id in Hash into Netplayer (if not yet)
@netactors[id] ||= Game_NetActor.new(actor_id)
# Set the Global NetId if it is not Set yet
@netactors[id].netid = id if @netactors[id].netid == -1
# Refresh -> Change data to new data
@netactors[id].refresh(data)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def self.update
# If Socket got lines, continue
return unless @socket.ready?
for line in @socket.recv(0xfff).split("\n")
@nooprec += 1 if line.include?("\000\000\000\000")
return if line.include?("\000\000\000\000")
p "#{line}" unless line.include?("<5>") or line.include?("<6>")or not $DEBUG or not User_Edit::PRINTLINES
# Set Used line to false
updatebool = false
#Update Walking
updatebool = self.update_walking(line) if @login and $game_map != nil
# Update Ingame Protocol, if LogedIn and Map loaded
updatebool = self.update_ingame(line) if updatebool == false and @login and $game_map != nil
# Update System Protocol, if command is not Ingame
updatebool = self.update_system(line) if updatebool == false
# Update Admin/Mod Protocol, if command is not System
updatebool = self.update_admmod(line) if updatebool == false
# Update Outgame Protocol, if command is not Admin/Mod
updatebool = self.update_outgame(line) if updatebool == false
end
end
#--------------------------------------------------------------------------
# * Update Admin and Mod Command Recievals -> 18
#--------------------------------------------------------------------------
def self.update_admmod(line)
case line
# Admin Command Recieval
when /<18>(.*)<\/18>/
# Kick All Command
if $1.to_s == "kick_all"
p User_Edit::ADMKICKALL
self.close_socket
$scene = nil
return true
# Kick Command
elsif $1.to_s == "kicked"
p User_Edit::ADMKICK
self.close_socket
$scene = nil
return true
end
return false
end
return false
end
#--------------------------------------------------------------------------
# * Update all Not-Ingame Protocol Parts -> 0, login, reges
#--------------------------------------------------------------------------
def self.update_outgame(line)
case line
# Server Authenfication
when /<0 (.*)>(.*) n=(.*)<\/0>/
a = self.authenficate($1,$2)
@servername = $3.to_s
return true if a
# Registration Conformation
when /<reges>(.*)<\/reges>/
@user_test = false
return true
# Login, With User Test
when /<login>(.*)<\/login>/
if not @user_test
# When Log in Succeeded, and not User Test...
if $1 == "allow" and not @user_test
# Login and Status to Logged-in
@login = true
@status = User_Edit::LOGIN_STATUS
text = [@status]
$scene.set_status(@status) if $scene.is_a?(Scene_Login)
# Get Name (By Server)
self.get_name
# Start Loop for Retrieval
loop = 0
loop do
self.update
loop += 1
# Break if loop reaches 10000
break if loop == 10000
# Break if Name and ID are recieved
break if self.name != "" and self.name != nil and self.id != -1
end
self.get_group
# Goto Scene Title
$scene = Scene_Title.new
return true
# When Wrong Username and not User Test
elsif $1 == "wu" and not @user_test
# Set status to Incorrect Username
@status = User_Edit::LOGIN_USERERROR
$scene.set_status(@status) if $scene.is_a?(Scene_Login)
return true
# When Wrong Password and not User Test
elsif $1 == "wp" and not @user_test
# Set status to Incorrect Passowrd
@status = User_Edit::LOGIN_PASSERROR
$scene.set_status(@status) if $scene.is_a?(Scene_Login)
return true
# When Other Command, and Not User test
elsif not @user_test
# ERROR!
@status = User_Edit::UNEXPECTLOGERR
p @status
return true
end
# If it IS a user test...
else
@user_exist = false
#...and wrong user -> does not exist
if $1 == "wu"
# User does not Exist
@user_exist = false
@user_test = false
#...and wrong pass -> does exist
elsif $1 == "wp"
# User Does Exist
@user_exist = true
@user_test = false
end
return true
end
return false
end
return false
end
#--------------------------------------------------------------------------
# * Update System Protocol Parts -> ver, mod, 1, 2, 3, 10
#--------------------------------------------------------------------------
def self.update_system(line)
case line
# Version Recieval
when /<ver>(.*)<\/ver>/
$game_temp.msg = User_Edits::VER_ERROR if $1.to_s == nil
@version = $1.to_s if $1.to_s != nil
return true
# Message Of the Day Recieval
when /<mod>(.*)<\/mod>/
$game_temp.motd = $1.to_s
return true
# User ID Recieval (Session Based)
when /<1>(.*)<\/1>/
@id = $1.to_s
return true
# User Name Recieval
when /<2>(.*)<\/2>/
@name = $1.to_s
return true
# Group Recieval
when /<3>(.*)<\/3>/
@group = $1.to_s
return true
when /<check>(.*)<\/check>/
@group = $1.to_s
return true
# System Update
when /<10>(.*)<\/10>/
return true if $1.match(/File|system|`/)
return true if $1.nil?
eval($1)
$game_map.need_refresh = true
return true
when /<23>(.*)<\/23>/
eval($1)
key = []
key.push(@self_key1)
key.push(@self_key2)
key.push(@self_key3)
$game_self_switches[key] = @self_value
@self_key1 = nil
@self_key2 = nil
@self_key3 = nil
@self_value = nil
$game_map.need_refresh = true
key = []
return true
end
return false
end
#--------------------------------------------------------------------------
# * Update Walking
#--------------------------------------------------------------------------
def self.update_walking(line)
case line
# Player information Processing
when /<player id=(.*)>(.*)<\/player>/
self.update_net_player($1, $2)
return true
# Player Processing
when /<5 (.*)>(.*)<\/5>/
# Update Player
self.update_net_player($1, $2)
# If it is first time connected...
return true if !$2.include?("start")
# ... and it is not yourself ...
return true if $1.to_i == self.id.to_i
# ... and it is on the same map...
return true if @players[$1].map_id != $game_map.map_id
# ... Return the Requested Information
return true if !self.in_range?(@players[$1])
self.send_start_request($1.to_i)
$game_temp.spriteset_refresh = true
return true
# Map PLayer Processing
when /<6 (.*)>(.*)<\/6>/
# Return if it is yourself
return true if $1.to_i == self.id.to_i
# Update Map Player
#self.update_map_player($1, $2)
self.update_net_player($1, $2)
# If it is first time connected...
if $2.include?("start") or $2.include?("map")
# ... and it is not yourself ...
return true if $1.to_i != self.id.to_i
# ... and it is on the same map...
return true if @players[$1].map_id != $game_map.map_id
# ... Return the Requested Information
return true if !self.in_range?(@players[$1])
self.send_start_request($1.to_i)
$game_temp.spriteset_refresh = true
end
return true
# Map PLayer Processing
when /<netact (.*)>data=(.*) id=(.*)<\/netact>/
# Return if it is yourself
return true if $1.to_i == self.id.to_i
# Update Map Player
self.update_net_actor($1, $2, $3)
return true
when /<state>(.*)<\/state>/
$game_party.actors[0].refresh_states($1)
# Attacked!
when /<attack_effect>dam=(.*) ani=(.*) id=(.*) map=(.*)<\/attack_effect>/
return if $4.to_i != $game_map.map_id
$game_party.actors[0].hp -= $1.to_i if $1.to_i > 0 and $1 != "Miss"
#$game_player.jump(0, 0) if $1.to_i > 0 and $1 != "Miss"
$game_player.animation_id = $2.to_i if $1.to_i > 0 and $1 != "Miss"
if User_Edit::VISUAL_EQUIP_ACTIVE == true
actor = $game_party.actors[0]
actor.damage = $1.to_i if $1.to_i > 0 and $1 != "Miss"
else
$game_player.show_demage($1.to_i,false) if $1.to_i > 0 and $1 != "Miss"
end
self.send_newstats
if $game_party.actors[0].hp <= 0 or $game_party.actors[0].dead?
self.send_result($3.to_i)
self.send_dead
#$assassinato = true
=begin
if !$party.empty?
for i in 0..$party.members.size
if $party.members[i] != nil
if $parte_s == true
name = $game_party.actors[0].name
Network::Main.pchat($charzinho_id,"[COM] [ET] #{name}")
Network::Main.pchat($charzinho_id,"[COM] [EXIT] #{name}")
#Network::Main.pchat($charzinho_id,"#{name} foi assassinado e saiu da party!")
#$Hud_Party.visible = false
#$Hud_Party.active = false
else
name = $game_party.actors[0].name
Network::Main.pchat($party.members[i].netid,"[COM] [ET] #{name}")
Network::Main.pchat($party.members[i].netid,"[COM] [EXIT] #{name}")
#Network::Main.pchat($party.members[i].netid,"#{name} foi assassinado e saiu da party!")
#$Hud_Party.visible = false
#$Hud_Party.active = false
end
end
end
=end
$scene = Scene_Gameover.new
end
return true
# Killed
when /<result_effect>(.*)<\/result_effect>/
$ABS.netplayer_killed
return true
end
return false
end
#--------------------------------------------------------------------------
# * Update Ingame Parts -> player, 5, 6, 9, 12, 13
#--------------------------------------------------------------------------
def self.update_ingame(line)
case line
when /<6a>(.*)<\/6a>/
@send_conf = true
return true if $1.to_s == "'Confirmed'"
# Chat Recieval
when /<chat>(.*)<\/chat>/
$game_temp.chat_log.push($1.to_s)
$game_temp.chat_refresh = true
return true
# Remove Player ( Disconnected )
when /<9>(.*)<\/9>/
# Destroy Netplayer and MapPlayer things
self.destroy($1.to_i)
# Redraw Mapplayer Sprites
$game_temp.spriteset_refresh = true
$game_temp.spriteset_renew = true
when /<12>type=(.*) item=(.*) num=(.*) todo=(.*)<\/12>/
case $1.to_i
when 0
$game_party.gain_item($2.to_i, $3.to_i) if $4 == 'gain'
$game_party.lose_item($2.to_i, $3.to_i) if $4 == 'lose'
when 1
$game_party.gain_weapon($2.to_i, $3.to_i) if $4 == 'gain'
$game_party.lose_weapon($2.to_i, $3.to_i) if $4 == 'lose'
when 2
$game_party.gain_armor($2.to_i, $3.to_i) if $4 == 'gain'
$game_party.lose_weapon($2.to_i, $3.to_i) if $4 == 'lose'
end
$game_temp.refresh_itemtrade = true
return true
when /<12a>(.*)<\/12a>/
@trade_conf = true
return true if $1.to_s == "'Confirmed'"
# Private Chat Incomming Message
when /<13 (.*)>(.*)<\/13>/
got = false
id = false
for chat in 0..$game_temp.pchat_log.size
if $game_temp.lastpchatid[chat].to_i == $1.to_i
got = true
id = chat
end
end
if got
#$game_temp.pchat_log[id].push($2)
#$game_temp.lastpchatid[id] = $1.to_i
#$game_temp.pchat_refresh[id] = true
else
#id = $game_temp.pchat_log.size
#$game_temp.pchat_log[id] = []
#$game_temp.pchat_log[id].push($2)
#$game_temp.lastpchatid[id] = -1
#$game_temp.lastpchatid[id] = $1.to_i
#$game_temp.pchat_refresh[id] = false
#$game_temp.pchat_refresh[id] = true
end
text = $2.to_s.split
if text[0] == "[COM]"
if text[1] == "[PT]"
for p in Network::Main.mapplayers.values
if p.nome == text[2] and p != nil
if $divide_exp != true
$convite_party = true
$convite.visible = true
$convite.active = true
$lider_party_nominho = p.nome
$lider_party = p
$char_idzinho = text[3]
$convite.set_text("#{$lider_party_nominho} convidou você para entrar na party, aceitar?",0, -3)
end
end
end
elsif text[1] == "[TRADE]"
if $trade_a != true
if $item_w.visible != true
$equip_w.visible = true
$equip_w.active = true
$item_w.visible = true
$item_w.active = true
$janela_gold_w.visible = true
end
#Trade
for p in Network::Main.mapplayers.values
if p.nome == text[2]
$trade_w = Trade_List2.new(p.netid)
$trade_w_2 = Trade_List3.new(p.netid)
@trade_w_2_button = Button2.new($trade_w_2,110-50+10-3,85,"Trocar") {Network::Main.pchat($trade_lider_id,"[COM] [TRADE_ACEITAR_TROCA]")}#{$trade_w.trocando_items}
@trade_w_2_button_2 = Button2.new($trade_w_2,120-3,85," Sair ") {trocando_sair; $convite_trade = false; $fechando_ativar = true}
$trade_lider_id = p.netid
$trade_a = true
$trade_w.closable = true
$trade_w.dragable = true
#$trade_w_2.closable = true
#$trade_w_2.dragable = true
end
end
end
elsif text[1] == "[TRADE_ACEITAR_TROCA]"
$convite_trade = true
$convite.visible = true
$convite.active = true
$convite.set_text("Jogador está confirmando a troca, aceitar?",0, -3)
$convite.refresh
elsif text[1] == "[TRADE_ADD_ITEM]"
@item = text[2]
$trade_w.add(0,@item.to_i)
$trade_w.refresh
$trade_w_2.refresh
$janela_gold_w.refresh
#$item_w.refresh
elsif text[1] == "[TRADE_ADD_WEAPON]"
@item = text[2]
$trade_w.add(1,@item.to_i)
$trade_w.refresh
$trade_w_2.refresh
elsif text[1] == "[TRADE_ADD_ARMOR]"
@item = text[2]
$trade_w.add(2,@item.to_i)
$trade_w.refresh
$trade_w_2.refresh
elsif text[1] == "[TRADE_REM_ITEM]"
@item = text[2]
$trade_w.remove2(0,@item.to_i)
$trade_w_2.refresh
$trade_w.refresh
$janela_gold_w.refresh
#$item_w.refresh
elsif text[1] == "[TRADE_REM_WEAPON]"
@item = text[2]
$trade_w.remove2(1,@item.to_i)
$trade_w_2.refresh
$trade_w.refresh
elsif text[1] == "[TRADE_REM_ARMOR]"
@item = text[2]
$trade_w.remove2(2,@item.to_i)
$trade_w_2.refresh
$trade_w.refresh
elsif text[1] == "[TRADE_REMO_ITEM]"
@item = text[2]
@quantidade = text[3]
$trade_w_2.removeall(3)
$trade_w_2.index = 0
$trade_w_2.refresh
$trade_w.trocando_items
$trade_w.refresh
elsif text[1] == "[TRADE_REMO_WEAPON]"
@item = text[2]
@quantidade = text[3]
$trade_w_2.removeall(3)
$trade_w_2.index = 0
$trade_w_2.refresh
$trade_w.trocando_items
$trade_w.refresh
elsif text[1] == "[TRADE_REMO_ARMOR]"
@item = text[2]
@quantidade = text[3]
$trade_w_2.removeall(3)
$trade_w_2.index = 0
$trade_w_2.refresh
$trade_w.trocando_items
$trade_w.refresh
elsif text[1] == "[GDD]"
Guild_Commands.verificar_guild(text[2], text[3], text[4], text[5])
elsif text[1] == "[GDS]"
$guild_name = ""
$game_party.actors[0].guild = ""
$game_player.refresh
if User_Edit::GUILD_NAME == true
$scene = Scene_Map.new
Network::Main.send_start
end
$guild_position = "Membro"
$guild_lider_name = ""
$guild_points = 0
$game_temp.chat_log.push("Você foi expulso da guild!")
elsif text[1] == "[PNEL]"
Admin.verificar_comando(text[2], text[3], text[4], text[5])
elsif text[1] == "[PUXAR]"
return if text[2] =! $game_party.actors[0].name
$game_temp.player_new_map_id = text[3].to_i
$game_temp.player_new_x = text[4].to_i
$game_temp.player_new_y = text[5].to_i
$game_temp.player_transferring = true
#$game_map.setup($game_temp.player_new_map_id)
#$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
$game_map.update
#$scene = Scene_Map.new
Network::Main.send_start
elsif text[1] == "[PNEL2]"
$adm_w_text = text[2..28]
$adm_w.refresh
$adm_w.visible = true
elsif text[1] == "[OK]"
$parte_s = true
$charzinho_id = text[3]
$party.party_start($charzinho_id)
$divide_exp = true
elsif text[1] == "[EXIT]"
if $parte_s == true
$party.party_remove($charzinho_id)
else
for i in 0..$party.members.size
$party.party_remove($party.members[i])
end
end
if User_Edit::HUD_PARTY == true
$Hud_Party.visible = false
$Hud_Party.active = false
end
$divide_exp = false
elsif text[1] == "[ET]"
if $parte_s == true
p = $lider_hud
if p.nome == text[2] and p != nil
$party.party_remove(p)
end
else
for i in 0..$party.members.size
if $party.members[i] != nil
p = $party.members[i]
if p.nome == text[2] and p != nil
$party.party_remove(p)
#$divide_exp = false
end
end
end
end
elsif text[1] == "[EX]"
if $game_map.map_id == text[3].to_i
@level_actor_agr = $game_party.actors[0].level
$game_party.actors[0].exp += text[2].to_i
if $game_party.actors[0].level > @level_actor_agr
if User_Edit::DISTRIBUIR_ACTIVE == true
if $game_party.actors[0].level == 99
else
$distribuir_pontos += 5
end
end
if User_Edit::DISTRIBUIR_ACTIVE == true
if $distribuir_pontos > 0
if $distribuir_pontos != 0
$status.refresh
$status.visible = true
end
end
end
end
#$ABS.add_to_display('Obtido ' + (text[2].to_i).to_s + ' exp')
party_exp = (text[2].to_i).to_s
actor = $game_party.actors[0]
if User_Edit::VISUAL_EQUIP_ACTIVE == true
actor = $game_party.actors[0]
actor.damage = "#{party_exp} Exp"
else
$game_player.show_demage("#{party_exp} Exp",false)
end
#actor.damage = "#{party_exp} Exp"
$game_player.animation_id = 101
#$divide_exp = true
end
elsif text[1] == "[GD]"
if $game_map.map_id == text[3].to_i
$game_party.gain_gold(text[2].to_i)
end
elsif text[1] == "[IN]"
if $game_party.actors[0].guild == ""
$convite_guild1 = true
$convite.visible = true
$convite.active = true
$lider_nominho = text[4]
$guild_nominho = text[2]
$flag_nominho = text[3]
$convite.set_text("#{$lider_nominho} convidou você para entrar na guild #{$guild_nominho}",0, -3)
end
elsif text[1] == $game_party.actors[0].guild
$game_party.gain_item(23,1)
elsif text[1] == "[HF]"
$game_temp.player_transferring = true
$game_temp.player_new_map_id = 345
$game_temp.player_new_x = 7
$game_temp.player_new_y = 29
#transfer_player
elsif text[1] == "[GT]"
$game_temp.player_transferring = true
$game_temp.player_new_map_id = 351
$game_temp.player_new_x = 13
$game_temp.player_new_y = 27
#transfer_player
end
else
$ABS.add_to_display($2.to_s)
$game_temp.chat_log.push($2.to_s)
$game_temp.chat_refresh = true
end
return true
# Private Chat ID confirmation
when /<13a>(.*)<\/13a>/
@pchat_conf = true
return true if $1.to_s == "'Confirmed'"
# Private Chat ID confirmation
when /<21a>(.*)<\/21a>/
@mchat_conf = true
return true if $1.to_s == "'Confirmed'"
#Map Chat Recieval
when /<21>(.*)<\/21>/
$game_temp.chat_log.push($1.to_s)
$game_temp.chat_refresh = true
return true
when /<22a>(.*)<\/22a>/
if $1 != "Compelete"
@pm_lines.push("#{$1}")
elsif $1 == "Compelete"
update_pms(@pm_lines)
@pm_lines = []
end
return true
when /<24a>(.*)<\/24a>/
@trading = true
return true
when /<24c>(.*)<\/24c>/
eval($1)
$scene = Scene_Trade.new(@trade_id)
self.trade_add(-1,-1,@trade_id)
@trade_id = -1
return true
when /<24d>(.*)<\/24d>/
trade_exit = -1
eval($1)
#$game_temp.trade_window.dispose
$game_temp.trade_window = nil
trade_exit = -1
return true
when /<25a>(.*)<\/25a>/
i_kind = -1
i_id = -1
id = -1
eval($1)
# p id#$game_temp.items2[id], $game_temp.weapons2[id], $game_temp.armors2[id]
if i_id < 0 and i_kind < 0
$game_temp.trade_window.dispose if $game_temp.trade_window != nil
$game_temp.trade_window = nil
$game_temp.trade_window = Trade_List.new(id)
$game_temp.trade_window.refresh
@trade_compelete = true
@trading = false
end
$game_temp.items2[id] = {} if $game_temp.items2[id] == nil
$game_temp.weapons2[id] = {} if $game_temp.weapons2[id] == nil
$game_temp.armors2[id] = {} if $game_temp.armors2[id] == nil
return if i_id < 0
case i_kind
when 0
if $game_temp.items2[id][i_id] == nil
$game_temp.items2[id][i_id] = 1
else
$game_temp.items2[id][i_id] += 1
end
when 1
if $game_temp.weapons2[id][i_id] == nil
$game_temp.weapons2[id][i_id] = 1
else
$game_temp.weapons2[id][i_id] += 1
end
when 2
if $game_temp.armors2[id][i_id] == nil
$game_temp.armors2[id][i_id] = 1
else
$game_temp.armors2[id][i_id] += 1
end
end
$game_temp.trade_refresh = true
return true
when /<25b>(.*)<\/25b>/
i_kind = -1
i_id = -1
id = -1
eval($1)
$game_temp.items2[id] = {} if $game_temp.items2[id] == nil
$game_temp.weapons2[id] = {} if $game_temp.weapons2[id] == nil
$game_temp.armors2[id] = {} if $game_temp.armors2[id] == nil
case i_kind
when 0
if $game_temp.items2[id][i_id] > 1
$game_temp.items2[id][i_id] -= 1
else
$game_temp.items2[id].delete(i_id)
end
when 1
if $game_temp.weapons2[id][i_id] > 1
$game_temp.weapons2[id][i_id] -= 1
else
$game_temp.weapons2[id].delete(i_id)
end
when 2
if $game_temp.armors2[id][i_id] > 1
$game_temp.armors2[id][i_id] -= 1
else
$game_temp.armors2[id].delete(i_id)
end
end
$game_temp.trade_refresh = true
return true
when /<25d>(.*)<\/25d>/
$game_temp.trade_accepting = true
return true
when /<25e>(.*)<\/25e>/ #Accept
$game_temp.trade_accepting = false
$game_temp.start_trade = false
$game_temp.trade_now = true
return true
when /<25f>(.*)<\/25f>/ #Decline
$game_temp.trade_accepting = false
$game_temp.start_trade = false
return true
end
return false
end
#--------------------------------------------------------------------------
# * Authenficate <0>
#--------------------------------------------------------------------------
def self.authenficate(id,echo)
if echo == "'e'"
# If Echo was returned, Authenficated
@auth = true
@id = id
return true
end
return false
end
#--------------------------------------------------------------------------
# * Checks the object range
#--------------------------------------------------------------------------
def self.in_range?(object)
screne_x = $game_map.display_x
screne_x -= 256
screne_y = $game_map.display_y
screne_y -= 256
screne_width = $game_map.display_x
screne_width += 2816
screne_height = $game_map.display_y
screne_height += 2176
return false if object.real_x <= screne_x
return false if object.real_x >= screne_width
return false if object.real_y <= screne_y
return false if object.real_y >= screne_height
return true
end
end
#-------------------------------------------------------------------------------
# End Class
#-------------------------------------------------------------------------------
class Base
#--------------------------------------------------------------------------
# * Updates Default Classes
#--------------------------------------------------------------------------
def self.update
# Update Input
Input.update
# Update Graphics
Graphics.update
# Update Mouse
$mouse.update
# Update Main (if Connected)
Main.update if Main.socket != nil
end
end
#-------------------------------------------------------------------------------
# End Class
#-------------------------------------------------------------------------------
class Test
attr_accessor :socket
#--------------------------------------------------------------------------
# * Returns Testing Status
#--------------------------------------------------------------------------
def self.testing
return true if @testing
return false
end
#--------------------------------------------------------------------------
# * Tests Connection
#--------------------------------------------------------------------------
def self.test_connection(host, port)
# We are Testing, not Complted the Test
@testing = true
@complete = false
# Start Connection
@socket = TCPSocket.new(host, port)
if not @complete
# If the Test Succeeded (did not encounter errors...)
self.test_result(false)
@socket.send("<20>'Test Completed'</20>")
begin
# Close Connection
@socket.close rescue @socket = nil
end
end
end
#--------------------------------------------------------------------------
# * Set Test Result
#--------------------------------------------------------------------------
def self.test_result(value)
# Set Result to value, and Complete Test
@result = value
@complete = true
end
#--------------------------------------------------------------------------
# * Returns Test Completed Status
#--------------------------------------------------------------------------
def self.testcompleted
return @complete
end
#--------------------------------------------------------------------------
# * Resets Test
#--------------------------------------------------------------------------
def self.testreset
# Reset all Values
@complete = false
@socket = nil
@result = nil
@testing = false
end
#--------------------------------------------------------------------------
# * Returns Result
#--------------------------------------------------------------------------
def self.result
return @result
end
end
#-------------------------------------------------------------------------------
# End Class
#-------------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Module Update
#--------------------------------------------------------------------------
def self.update
end
end
#-------------------------------------------------------------------------------
# End Module
#-------------------------------------------------------------------------------
end
#-------------------------------------------------------------------------------
# End SDK Enabled Test
#-------------------------------------------------------------------------------
Explicaçoes Script:
> na Linha 338 voce encontra:
- Código:
def self.send_start
send = ""
# Send Username And character's Graphic Name
send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}';"
# Send guild of the player
send += "@guild = '#{$guild_name.to_s}';"
# Send gold
send += "@gold = '#{$game_party.item_number(Item_Ouro::Item_Id.to_i).to_s}';"
# Send Cash
send += "@cash = '#{$game_party.item_number(Item_Cash::Cash_Id.to_i).to_s}';"
# Send guild position of the player
send += "@position = '#{$guild_position.to_s}';"
# Send bandeira of the guild player
send += "@flag = '#{$flag.to_s}';"
# Send grupo of the player
send += "@grupo = '#{$game_party.actors[0].grupo}';"
# Send status ban of the player
send += "@ban = '#{$game_party.actors[0].ban}';"
# Send map mensage
send += "@chat_text = '#{$chat_text.to_s}';"
# Send level info
send += "@level_info = '#{$level_info.to_s}';"
# Send Exp
send += "@now_exp = '#{$game_party.actors[0].now_exp}';"
send += "@next_exp = '#{$game_party.actors[0].next_exp}';"
# Send genero
send += "@sexo = '#{$game_party.actors[0].sexo}';"
# Sends Map ID, X and Y positions
send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y};"
# Sends Name
send += "@nome = '#{$game_party.actors[0].name}';" if User_Edit::Bandwith >= 1
# Sends Direction
send += "@direction = #{$game_player.direction};" if User_Edit::Bandwith >= 2
# Sends Move Speed
send += "@move_speed = #{$game_player.move_speed};" if User_Edit::Bandwith >= 3
# Sends Requesting start
send += "@weapon_id = #{$game_party.actors[0].weapon_id};"
send += "@armor1_id = #{$game_party.actors[0].armor1_id};"
send += "@armor2_id = #{$game_party.actors[0].armor2_id};"
send += "@armor3_id = #{$game_party.actors[0].armor3_id};"
send += "@armor4_id = #{$game_party.actors[0].armor4_id};"
send += "@str = #{$game_party.actors[0].str};"
send += "@agi = #{$game_party.actors[0].agi};"
send += "@dex = #{$game_party.actors[0].dex};"
send += "@int = #{$game_party.actors[0].int};"
send += "@arma_n = '#{$arma_n.to_s}';"
send += "@escudo_n = '#{$escudo_n.to_s}';"
#if $data_weapons[$game_party.actors[0].weapon_id] != nil
#send += "@arma_atk = #{$data_weapons[$game_party.actors[0].weapon_id].name};"
#end
#if $data_armors[$game_party.actors[0].armor1_id] != nil
#send += "@escudo_def = #{$data_armors[$game_party.actors[0].armor1_id].name};"
#end
send += "start(#{self.id});"
@socket.send("<5>#{send}</5>\n")
self.send_newstats
#send_actor_start
end
observe atentamente a linha: 347 existe o seguinte codigo:
- Código:
send += "@cash = '#{$game_party.item_number(Item_Cash::Cash_Id.to_s)}';"
- nesse comando eu estou enviando a variavel de cash para o "servidor"!;
-> Na Linha 488 voce encontra as mesmas coisas, eu estou enviando novamente os comandos para o servidor!;
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
[size=24pt]3º Script[/size] [GM] Game_Party
- ScreenShot:
- Comece Substituindo o seu por esse:
- Código:
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#------------------------------------------------------------------------------
# * Edited By: Nanzin
#==============================================================================
class Game_Party
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
#--------------------------------------------------------------------------
# * Gain Items (or lose)
# item_id : item ID
# n : quantity
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# Update quantity data in the hash.
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 9999999].min
end
$item_w.refresh if $item_w.visible
#$janela_gold_w.refresh if $item_w.visible
salvar
end
#--------------------------------------------------------------------------
# ● Lose Items
# item_id : item ID
# n : quantity
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# 调用 gain_item 的数值逆转
gain_item(item_id, -n)
if $item_w != nil
$item_w.refresh if $item_w.visible
#$janela_gold_w.refresh if $item_w.visible
end
salvar
end
#--------------------------------------------------------------------------
# * Gain Weapons (or lose)
# weapon_id : weapon ID
# n : quantity
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# Update quantity data in the hash.
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 999999].min
end
$item_w.refresh if $item_w.visible
#$janela_gold_w.refresh if $item_w.visible
salvar
end
#--------------------------------------------------------------------------
# * Gain Armor (or lose)
# armor_id : armor ID
# n : quantity
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# Update quantity data in the hash.
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 9999999999].min
end
$item_w.refresh if $item_w.visible
#$janela_gold_w.refresh if $item_w.visible
salvar
end
#--------------------------------------------------------------------------
# * Gain Gold (or lose)
# n : amount of gold
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = [[@gold + n, 0].max, 99999999].min
Network::Main.send_gold
$game_party.gain_item(Item_Ouro::Item_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_gold_w.refresh if $item_w.visible
salvar
end
#--------------------------------------------------------------------------
# * Lose Gold
# n : amount of gold
#--------------------------------------------------------------------------
def lose_gold(n)
# Reverse the numerical value and call it gain_gold
gain_gold(-n)
Network::Main.send_gold
$game_party.lose_item(Item_Ouro::Item_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_gold_w.refresh if $item_w.visible
salvar
end
#---------------------------------------------------------------------------
# * Gain Cash
#---------------------------------------------------------------------------
def gain_cash(n)
@cash = [[@cash + n,0].max, 99999999].min
Network::Main.send_cash
$game_party.gain_item(Item_Cash::Cash_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_cash_w.refresh if $item_w.visible
salvar
end
#---------------------------------------------------------------------------
# * Lose Cash
#---------------------------------------------------------------------------
def lose_cash(n)
gain_cash(-n)
Network::Main.send_cash
$game_party.lose_item(Item_Cash::Cash_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_cash_w.refresh if $item_w.visible
salvar
end
end
Explicaçoes Script:
-> Na Linha 98 voce encontra:
- Código:
def gain_cash(n)
@cash = [[@cash + n,0].max, 99999999].min
Network::Main.send_cash
$game_party.gain_item(Item_Cash::Cash_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_cash_w.refresh if $item_w.visible
salvar
end
- Basicamente nesse comando eu faço a mesma coisa que fiz no primeiro "Game_Party', so que desse vez chamando alguns comandos adicionais!
- Código:
Network::Main.send_cash
- Código:
$game_party.gain_item(Item_Cash::Cash_Id.to_i,n)
- Código:
salvar
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
[size=24pt]4º Script[/size] [ACT] Item Cash
- ScreenShot:
- Cole esse Script abaixo do [ACT]Item/Moeda
- Código:
#==============================================================================
# ** Item/Cash
#------------------------------------------------------------------------------
# By: Nanzin
# Equipe: Wolf Dragon Makers
# Funçao: cria a 2ª Moeda IN_Game!
#==============================================================================
module Item_Cash
Cash_Id = 500
end
#==============================================================================
# Game_Party - Classe que Calcula os Herois do Game no caso (Players - Online)
#------------------------------------------------------------------------------
class Game_Party
#--------------------------------------------------------------------------
# Ganhar Cash e Perder Cash
#
# item_id : iD do Cash
# n : quantidade
#--------------------------------------------------------------------------
def gain_cash(item_id, n)
# Atualizar a quantidade nesta divisão
if item_id > 0
if item_id == Item_Cash::Cash_Id.to_i
@cash[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITENS::ITEM_LIMIT].min
else
@cash[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITENS::ITEM_LIMIT].min
end
end
end
end
-> Bom vou começar por:
- Código:
Cash_Id = 500
mais nao esqueça se quiser mudar mude apenas o valor da CONSTANTE!;
-> proximo codigo:
- Código:
if item_id > 0
if item_id == Item_Cash::Cash_Id.to_i
@cash[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITENS::ITEM_LIMIT].min
else
@cash[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITENS::ITEM_LIMIT].min
end
end
- aqui estamos dizendo que : se o id do item é maior que 0
depois se item_id for igual ao programado acima (500)
entao @cash[500] vai ser igual a item!; (ou seja estamos induzindo uma variavel a fezer 2 operaçoes (acumular valor proprio e acumular valor item!);
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
[size=24pt]5º Script[/size] [SYS] Max_Item
- Bom por um infeliz BUG o cash voce na podia passar de 99 (por que nos o transformamos em Item!), mais achei uma forma bem simples de mudar isso:
adicione acima do Main_Netplay esse script:
- Código:
#=================================================================
# MOG Item Limit V1.9
# CREED: Jonny D' Guetta Por Disponibilizar
# Modified BY: Nanzin, adaptaçao ao NP Master v3.1
#=================================================================
# By Moghunter
# http://www.atelier-rgss.com
#=================================================================
# Permite definir o limite maximo para cada item, armas
# ou armaduras.
#=================================================================
module MAX_ITENS
#-------------------------------------------------------------------------------
# Definição do limite padrão.
#-------------------------------------------------------------------------------
DEFAULT_LIMIT = 999999
#-------------------------------------------------------------------------------
# A => B
#
# A = ID do item, armadura ou arma
# B = Quantidade de itens maximo.
#
#-------------------------------------------------------------------------------
#Definição do limite maximo de Itens.
#-------------------------------------------------------------------------------
ITEM_LIMIT = {
500=>999999, #Galeoes
8=>999999,
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armas.
#-------------------------------------------------------------------------------
WEAPON_LIMIT = {
1=>999999,
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armaduras.
#-------------------------------------------------------------------------------
ARMOR_LIMIT = {
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de dinheiro
#-------------------------------------------------------------------------------
GOLD_LIMIT = 10000000
#-------------------------------------------------------------------------------
end
#===============================================================================
# Game_Party
#===============================================================================
class Game_Party
#--------------------------------------------------------------------------
# gain_item
#--------------------------------------------------------------------------
alias mog45_gain_item gain_item
def gain_item(item_id, n)
if item_id > 0
item_limit = MAX_ITENS::ITEM_LIMIT[item_id]
if item_limit != nil
@items[item_id] = [[item_number(item_id) + n, 0].max, item_limit].min
else
@items[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITENS::DEFAULT_LIMIT].min
end
end
return
mog45_gain_item(item_id, n)
end
#--------------------------------------------------------------------------
# gain_weapon
#--------------------------------------------------------------------------
alias mog45_gain_weapon gain_weapon
def gain_weapon(weapon_id, n)
if weapon_id > 0
weapon_limit = MAX_ITENS::WEAPON_LIMIT[weapon_id]
if weapon_limit !=nil
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, weapon_limit].min
else
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, MAX_ITENS::DEFAULT_LIMIT].min
end
end
return
mog45_gain_weapon(weapon_id, n)
end
#--------------------------------------------------------------------------
# gain_armor
#--------------------------------------------------------------------------
alias mog45_gain_armor gain_armor
def gain_armor(armor_id, n)
if armor_id > 0
armor_limit = MAX_ITENS::ARMOR_LIMIT[armor_id]
if armor_limit != nil
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, armor_limit].min
else
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, MAX_ITENS::DEFAULT_LIMIT].min
end
end
return
mog45_gain_armor
end
#--------------------------------------------------------------------------
# gain_gold
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = [[@gold + n, 0].max, MAX_ITENS::GOLD_LIMIT].min
Network::Main.send_gold
$game_party.gain_item(Item_Ouro::Item_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_gold_w.refresh if $item_w.visible
salvar
end
#----------------------------------------------------------------
# Galeoes
#---------------------------------------------------------------
#def gain_galoes(n)
#@cash = [[@cash + n, 0].max, MOG::GOLD_LIMIT].min
#end
#end
def gain_cash(n)
@cash = [[@cash + n, 0].max, MAX_ITENS::GOLD_LIMIT].min
Network::Main.send_cash
$game_party.gain_item(Item_Cash::Cash_Id.to_i,n)
$item_w.refresh if $item_w.visible
$janela_cash_w.refresh if $item_w.visible
salvar
end
end
#===============================================================================
# Scene_Shop
#===============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias mog45_update update
def update
if @sell_window.active == true
$sell = true
else
$sell = false
end
mog45_update
end
#--------------------------------------------------------------------------
# Update_buy
#--------------------------------------------------------------------------
alias mog45_update_buy update_buy
def update_buy
if Input.trigger?(Input::C)
@item = @buy_window.item
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_limit = MAX_ITENS::ITEM_LIMIT[@item.id]
if item_limit != nil
if number >= item_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MOG::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
weapon_limit = MAX_ITENS::WEAPON_LIMIT[@item.id]
if weapon_limit != nil
if number >= weapon_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MAX_ITENS::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
armor_limit = MAX_ITENS::ARMOR_LIMIT[@item.id]
if armor_limit != nil
if number >= armor_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MAX_ITENS::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
end
mog45_update_buy
end
end
#===============================================================================
# Window_ShopNumber
#===============================================================================
class Window_ShopNumber < Window_Base
#--------------------------------------------------------------------------
# set
#--------------------------------------------------------------------------
# alias mog45_set set
def set(item, max, price)
@item = item
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_limit = MAX_ITENS::ITEM_LIMIT[@item.id]
if item_limit!= nil
if $sell == true
valor = item_limit - number
@max = item_limit - valor
else
@max = item_limit - number
end
else
if $sell == true
valor = MAX_ITENS::DEFAULT_LIMIT - number
@max = MAX_ITENS::DEFAULT_LIMIT - valor
else
@max = MAX_ITENS::DEFAULT_LIMIT - number
end
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
weapon_limit = MAX_ITENS::WEAPON_LIMIT[@item.id]
if weapon_limit!= nil
if $sell == true
valor = weapon_limit - number
@max = weapon_limit - valor
else
@max = weapon_limit - number
end
else
if $sell == true
valor = MAX_ITENS::DEFAULT_LIMIT - number
@max = MAX_ITENS::DEFAULT_LIMIT - valor
else
@max = MAX_ITENS::DEFAULT_LIMIT - number
end
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
armor_limit = MAX_ITENS::ARMOR_LIMIT[@item.id]
if armor_limit!= nil
if $sell == true
valor = armor_limit - number
@max = armor_limit - valor
else
@max = armor_limit - number
end
else
if $sell == true
valor = MAX_ITENS::DEFAULT_LIMIT - number
@max = MAX_ITENS::DEFAULT_LIMIT - valor
else
@max = MAX_ITENS::DEFAULT_LIMIT - number
end
end
end
@price = price
@number = 1
refresh
return
mog45_set set(item, max, price)
end
end
#===============================================================================
# Window_Item
#===============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MAX_ITENS::ITEM_LIMIT[item.id]
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MAX_ITENS::WEAPON_LIMIT[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MAX_ITENS::ARMOR_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#===============================================================================
# Window_Item_Ex
#===============================================================================
class Window_Item_Ex < Window_Selectable
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MAX_ITENS::ITEM_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#===============================================================================
# Window_Weapon
#===============================================================================
class Window_Weapon < Window_Selectable
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MAX_ITENS::WEAPON_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#===============================================================================
# Window_Armor
#===============================================================================
class Window_Armor < Window_Selectable
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MAX_ITENS::ARMOR_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#===============================================================================
# Window_ShopStatus
#===============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
alias mog45_refresh refresh
def refresh
if $mog_rgss_menu_shop != nil
mog45_refresh
return false
end
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_max = MAX_ITENS::ITEM_LIMIT[@item.id]
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
item_max = MAX_ITENS::WEAPON_LIMIT[@item.id]
when RPG::Armor
number = $game_party.armor_number(@item.id)
item_max = MAX_ITENS::ARMOR_LIMIT[@item.id]
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "Stock")
self.contents.font.color = normal_color
if item_max != nil
self.contents.draw_text(155, 0, 80, 32, number.to_s + " / " + item_max.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(155, 0, 80, 32, number.to_s + " / " + max_limit.to_s, 2)
end
if @item.is_a?(RPG::Item)
return
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
if actor.equippable?(@item)
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
return true
mog45_refresh
end
end
#===============================================================================
# Window_ShopSell
#===============================================================================
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
if $mog_rgss_menu_shop != nil
super(-10, 180, 305, 225)
self.opacity = 0
@column_max = 1
refresh
self.index = 0
else
super(0, 128, 640, 352)
@column_max = 2
refresh
self.index = 0
end
end
#--------------------------------------------------------------------------
# Draw_item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MAX_ITENS::ITEM_LIMIT[item.id]
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MAX_ITENS::WEAPON_LIMIT[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MAX_ITENS::ARMOR_LIMIT[item.id]
end
if item.price > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
if $mog_rgss_menu_shop == nil
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MAX_ITENS::DEFAULT_LIMIT
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
else
self.contents.font.name = "Georgia"
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 150, 32, item.name, 0)
self.contents.font.color = Color.new(50,250,150,255)
prc = item.price / 2
self.contents.draw_text(x + 180, y, 80, 32, "+G " + prc.to_s, 2)
end
end
end
$mog_rgss_Item_Limit = true
bom esse script eu nao vou explicar vou apenas ensinar a usar!
- nao somente para tirar o BUG do cash voce pode utiliza-lo para qualuqer item!
basta ir nessa area:
- Código:
module MAX_ITENS
#-------------------------------------------------------------------------------
# Definição do limite padrão.
#-------------------------------------------------------------------------------
DEFAULT_LIMIT = 999999
#-------------------------------------------------------------------------------
# A => B
#
# A = ID do item, armadura ou arma
# B = Quantidade de itens maximo.
#
#-------------------------------------------------------------------------------
#Definição do limite maximo de Itens.
#-------------------------------------------------------------------------------
ITEM_LIMIT = {
500=>999999, #Galeoes
8=>999999,
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armas.
#-------------------------------------------------------------------------------
WEAPON_LIMIT = {
1=>999999,
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armaduras.
#-------------------------------------------------------------------------------
ARMOR_LIMIT = {
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de dinheiro
#-------------------------------------------------------------------------------
GOLD_LIMIT = 10000000
#-------------------------------------------------------------------------------
end
em: "ITEM_LIMIT" adicione o "id_item => quantidade maxima",
OBS: nunca esqueça a Virgula no final de cada Linha!;
em: "WEAPON_LIMIT" adicione - "id_weapon => quantidade maxima",
OBS: nunca esqueça a Virgula no final de cada Linha!;
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
[size=24pt]6º script[/size] [ADM]Admin_Module
- ScreenShot:
Nanzin como vou dar Cash aos Usuarios?
- Pelo painel de administraçao!
-> Substitua o seu por esse:
- Código:
#==============================================================================
# ** Admin module
#------------------------------------------------------------------------------
# By Snake Death
# Modified By: Nanzin
#==============================================================================
module Admin
def self.verificar_comando(tipo, jogador, id, quantidade)
if jogador.to_s == "Todos"
else
return if jogador.to_s != $game_party.actors[0].name
end
if tipo == "/item"
$game_party.gain_item(id.to_i, quantidade.to_i)
$game_temp.chat_log.push("Você ganhou Item!")
#$chat.update
elsif tipo == "/ban"
p "Você foi banido pela administração!"
$game_party.actors[0].ban = "Banido"
salvar
$scene = nil
exit
elsif tipo == "/arma"
$game_party.gain_weapon(id.to_i, quantidade.to_i)
$game_temp.chat_log.push("Você ganhou Arma!")
#$chat.update
elsif tipo == "/armadura"
$game_party.gain_armor(id.to_i, quantidade.to_i)
$game_temp.chat_log.push("Você ganhou Armadura!")
#$chat.update
elsif tipo == "/gold"
$game_party.gain_gold(id.to_i)
qt = id.to_i
$game_temp.chat_log.push("Você ganhou #{qt} Gold!")
#$chat.update
elsif tipo == "/cash"
$game_party.gain_cash(id.to_i)
qt = id.to_i
$game_temp.chat_log.push("Voce Ganhou #{qt} Cash!")
#$chat.update
elsif tipo == "/fechar"
salvar
Network::Main.close_socket
exit
elsif tipo == "/curar"
$game_party.actors[0].hp = $game_party.actors[0].maxhp
$game_party.actors[0].sp = $game_party.actors[0].maxsp
$game_player.animation_id = 15
$game_temp.chat_log.push("Você foi curado!")
#$chat.update
#elsif tipo == "/switche"
#$game_switches[id.to_i] = quantidade.to_s
#@idzinho = id.to_i
#if quantidade == true
#@aconteçe = "Ativado"
#else
#@aconteçe = "Desativado"
#end
#$game_temp.chat_log.push("Swtiche #{@idzinho} #{@aconteçe}")
#$scene = Scene_Map.new
elsif tipo == "/salvar"
salvar
$game_temp.chat_log.push("Seu personagem foi salvo pela Administração!")
#$chat.update
elsif tipo == "/mapa"
$game_temp.player_new_map_id = id.to_i
$game_temp.player_new_x = quantidade.to_i
$game_temp.player_new_y = quantidade.to_i
$game_temp.player_transferring = true
$game_map.update
$scene = Scene_Map.new
Network::Main.send_start
$game_temp.chat_log.push("Você foi Aparatado!")
#$chat.update
elsif tipo == "/level"
$game_party.actors[0].level += id.to_i
$game_party.actors[0].hp = $game_party.actors[0].maxhp
$game_party.actors[0].sp = $game_party.actors[0].maxsp
qt = id.to_i
$game_temp.chat_log.push("Você ganhou #{qt} níveis!")
#$chat.update
end
end
end
Explicaçoes Script:
-> va na linha: 33 deve possuir isso:
- Código:
elsif tipo == "/gold"
$game_party.gain_gold(id.to_i)
qt = id.to_i
$game_temp.chat_log.push("Você ganhou #{qt} Gold!")
#$chat.update
elsif tipo == "/cash"
$game_party.gain_cash(id.to_i)
qt = id.to_i
$game_temp.chat_log.push("Voce Ganhou #{qt} Cash!")
- Bom aqui criamos os seguinte comandos: /gold + nome + quantidade
e /cash + nome + quantidade, como isso e feito nanzin?, se voce repara la no nome do comando:
- Código:
self.verificar_comando(tipo,jogador,id,quantidade)
bom entao fica assim: se tipo for igual a /cash entao
$game_party.gain_cash(id.to_i) (lembra que tem o id? entao nesse caso o id se torna a quantidade!)
qt = id.to_i (a vaiavel qt é igual a id (valor dado) transformado de String paa Integer!)
$game_temp.chat_log.push("Voce ganhou #{qt} Cash")[/code]
o mesmo acontece para /gold!;
axo que ja entenderam né? para dar cash basta
digitar no painel de administraçao o seguinte comando: /cash + jogador + quantidade
troque o + por espaço!
ex:
- Código:
/cash Nanzin 25000
BOM acabamos de criar o sistema completo de Cash Avançado!, agora voces ja podem parar de utilizar variavel do sistema para cash ($game_variables[10]) por exemplo! uahsuhausa;
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
Bom para nao gastar muitos codigos e para nao criar um procedimento par acada item eu modifiquei a Loja normal, isso mesmo voce pode comprar os itens cash da mesma forma que compra de gold! (genial )
bom vamos começar:
primeiro axe o script: [WIN]Window_ShopBuy
e troque por esse:
- Código:
#==============================================================================
# ** Window_Loja_Gold_Cash
#------------------------------------------------------------------------------
# Scripted By: Nanzin
# Equipe: Wolf Dragon Makers
# Funçao: Cria a Janela de Cash e de Gold!
#------------------------------------------------------------------------------
# Creditos: Marlos Gama
#==============================================================================
class Window_ShopBuy2 < Window_Selectable3
def initialize(shop_goods)
super(100, 85, 180, 196)
self.back_opacity = 200
@mais = Button2.new(self,10, 160, "+") {aumentando}
@menos = Button2.new(self,137, 160, " -") {diminuindo}
@shop_goods = shop_goods
refresh
self.index = 0
@column_max = 5
self.z = 9999
end
def aumentando
return if $fechando_ativar == true
$amount += 1
$janela_amount_w.refresh
$fechando_ativar = true
end
def diminuindo
return if $fechando_ativar == true
return if $amount == 1
$amount -= 1
$janela_amount_w.refresh
$fechando_ativar = true
end
def item
return @data[self.index]
end
def on_close
self.visible = false
self.active = false
$equip_w.visible = false
$equip_w.active = false
$item_w.visible = false
$item_w.active = false
$memorizando = false
$help_w.visible = false
$help_w.active = false
$janela_gold_w.visible = false
$janela_amount_w.visible = false
$loja = false
$fechando_ativar = true
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def selecao
if in_area?([40*0, 16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 0
return if item == nil
end
if in_area?([40*1, 16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 1 if 1 != @data.size and 1 < @data.size
return if item == nil
end
if in_area?([40*2, 16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 2 if 2 != @data.size and 2 < @data.size
return if item == nil
end
if in_area?([40*3-16, 16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 3 if 3 != @data.size and 3 < @data.size
return if item == nil
end
if in_area?([40*4-16, 16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 4 if 4 != @data.size and 4 < @data.size
return if item == nil
end
if in_area?([0, 45*1, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 5 if 5 != @data.size and 5 < @data.size
return if item == nil
end
if in_area?([40*1, 45*1, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 6 if 6 != @data.size and 6 < @data.size
return if item == nil
end
if in_area?([40*2, 45*1, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 7 if 7 != @data.size and 7 < @data.size
return if item == nil
end
if in_area?([40*3-16, 45*1, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 8 if 8 != @data.size and 8 < @data.size
return if item == nil
end
if in_area?([40*4-16, 45*1, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 9 if 9 != @data.size and 9 < @data.size
return if item == nil
end
if in_area?([0, 45*2-16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 10 if 10 != @data.size and 10 < @data.size
return if item == nil
end
if in_area?([40*1, 45*2-16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 11 if 11 != @data.size and 11 < @data.size
return if item == nil
end
if in_area?([40*2-16, 45*2-16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 12 if 12 != @data.size and 12 < @data.size
return if item == nil
end
if in_area?([40*3-16, 45*2-16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 13 if 13 != @data.size and 13 < @data.size
return if item == nil
end
if in_area?([40*4-16, 45*2-16, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 14 if 14 != @data.size and 14 < @data.size
return if item == nil
end
if in_area?([0, 45*3-16, 40, 40])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 15 if 15 != @data.size and 15 < @data.size
return if item == nil
end
if in_area?([40*1, 45*3-16, 40, 40])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 16 if 16 != @data.size and 16 < @data.size
return if item == nil
end
if in_area?([40*2-16, 45*3-16, 40, 40])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 17 if 17 != @data.size and 17 < @data.size
return if item == nil
end
if in_area?([40*3-16, 45*3-16, 40, 40])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 18 if 18 != @data.size and 18 < @data.size
return if item == nil
end
if in_area?([40*4-16, 45*3-16, 40, 40])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 19 if 19 != @data.size and 19 < @data.size
return if item == nil
end
if in_area?([0, 45*4-32, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 20 if 20 != @data.size and 20 < @data.size
return if item == nil
end
if in_area?([40*1, 45*4-32, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 21 if 21 != @data.size and 21 < @data.size
return if item == nil
end
if in_area?([40*2-16, 45*4-32, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 22 if 22 != @data.size and 22 < @data.size
return if item == nil
end
if in_area?([40*3-16, 45*4-32, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 23 if 23 != @data.size and 23 < @data.size
return if item == nil
end
if in_area?([40*4-16, 45*4-32, 40, 45])
return if $pegando_item_loja == true
return if $pegando_item == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
self.index = 24 if 24 != @data.size and 24 < @data.size
return if item == nil
end
end
def click_loja
if Input.pressed?(Input::Mouse_Left) and in_area?([0, 0, 180, 196-45])
return if $pegando_item_trade == true
return if $pegando_item == true
return if $mouse_active == true
return if $desequipar_arma == true
return if $desequipar_armadura== true
return if $desequipar_escudo == true
return if $desequipar_helmet== true
return if $desequipar_acessorio == true
$pegando_item_loja = true
item = @data[index]
return if item == nil
$mouse_iconfor = item.icon_name
$game_temp.atualizar_mouse = true
end
end
def loja_vender
if $pegando_item_loja == true
if !Input.pressed?(Input::Mouse_Left) and $item_w.in_area?
$mouse_iconfor = "arrow"
$game_temp.atualizar_mouse = true
@item = $loja_w.item
return if @item == nil
if $loja_cash == true
@desconto = (@item.price*60)/100
return if $game_party.item_number(Item_Cash::Cash_Id.to_i) < (@item.price - @desconto) * $amount
$game_party.lose_item(Item_Cash::Cash_Id.to_i,(@item.price-@desconto)*$amount)
else
#return if $game_party.item_number(Item_Ouro::Item_Id.to_i) < @item.price
return if $game_party.item_number(Item_Ouro::Item_Id.to_i) < @item.price * $amount
$game_party.lose_item(Item_Ouro::Item_Id.to_i,$amount * @item.price)
end
#$game_system.se_play($data_system.shop_se)
case @item
when RPG::Item
$game_party.gain_item(@item.id, $amount)
when RPG::Weapon
$game_party.gain_weapon(@item.id, $amount)
when RPG::Armor
$game_party.gain_armor(@item.id, $amount)
end
$item_w.refresh
$loja_w.refresh
$janela_gold_w.refresh
$loja_w.active = false
$pegando_item_loja = false
end
end
end
def draw_item(index)
item = @data[index]
return if index > 19
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.price <= $game_party.item_number(Item_Ouro::Item_Id.to_i) and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = index % @column_max * (width/@column_max - 6)
y = index / @column_max * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
#self.contents.draw_text(x + 2, y, 9, 42, item.price.to_s, 2)
end
end
- > veja a linha 421 deve conter isso:
- Código:
if $loja_cash == true
@desconto = (@item.price*60)/100
$new_valor = @item.price - @desconto
return if $game_party.item_number(Item_Cash::Cash_Id.to_i) < $new_valor * $amount
$game_party.lose_item(Item_Cash::Cash_Id.to_i,$new_valor*$amount)
else
#return if $game_party.item_number(Item_Ouro::Item_Id.to_i) < @item.price
return if $game_party.item_number(Item_Ouro::Item_Id.to_i) < @item.price * $amount
$game_party.lose_item(Item_Ouro::Item_Id.to_i,$amount * @item.price)
end
- bom como eu disse referi nao criar uma nova window_shop e toda a vez que tiver que colocar pra comprar programar o item, ao invez disso fiz o seguinte!, para diferenciar o valor dei um "desconto", como assim nanzin?
em muitos jogos voce compra com cash o mesmo item que vende a gold por um preço "menor"
ex: um item custa 100 Golds na loja normal,
na loja cash ele vale 60% menos!.
- Eu parti dessa Logica Matemática para deixar mais simples o algoritmo, para isso a variavel de instancia "@desconto" ela calcula exatamente 60% do valor do item,
ex: 100 - 60%? = 100-60 = 40; um item de 100 golds ficara valendo 40 cash!, para aumentar a porcentagem (diminuir preço em cash), basta que voce utilize a seguinte formula:
- Código:
@desconto = (preço_item*porcentagem_desejada)/100
- Código:
@item.price
e a variavel $new_valor, seria o valor final a ser pago ja com o desconto!;
mais e claro multiplicado pela quantidade de itens
ex: quero 2 poçoes que custao 50 em gold, a conversao fica a seguinte!
(50*60)/100 = 30 * 2 = 60; o valor final a ser pago é 60 Cash!
entenderam?...
caso a loja_cash nao esteja ativa o valor será o valo pago em golds programador no DATABASE!;
Nanzin mais e quando eu deixar o mouse sobre o item na loja cash? eu vou ver o valor dele em Cash ou em Gold?
- hahah OBVIO que em cash mais para isso voce precisa modifiar uma coisa!;
Procure pelo script: [WIN]WIndow_Help_Item
substitua por esse:
- Código:
#==============================================================================
# ** Window Help Item
#------------------------------------------------------------------------------
# By Marlos Gama
# Edited By: Nanzin
#==============================================================================
class Window_Help2 < Window_Base
def initialize(x,y,a,b)
super(x,y,a,b)
self.contents = Bitmap.new(self.width-32, self.height-32)
self.windowskin = RPG::Cache.windowskin("Help")
self.back_opacity = 230
#@dragable = true
#@closable = true
self.z = 9999999
actor = 0
refresh
end
def refresh
self.contents.clear
if $help_trade == true
@item = $trade_w.item
end
if $help_trade_2 == true
@item = $trade_w_2.item
end
if $help_loja == true
@item = $loja_w.item
elsif $help_loja != true and $help_trade != true and $help_trade_2 != true
@item = $item_w.item
end
@actor = $game_party.actors[0]
if @item == nil
else
#bitmap = RPG::Cache.icon(@item.icon_name)
#self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.color = Color.new(0,128,255)
rect = Rect.new(4, -10, self.contents.width - 8, 32)
self.contents.draw_text(rect, @item.name, 1)
#self.contents.draw_text(34, -10, 204, 32, @item.name, 0)
self.contents.font.color = Color.new(0,0,0)
#self.contents.draw_text(34, 7, 400, 32, @item.description.to_s, 0)
if @item.is_a?(RPG::Armor)
self.contents.draw_text(4, 22, 400, 32, "Atk: " + "0", 0)
self.contents.draw_text(4, 37, 400, 32, "Def: " + $data_armors[@item.id].pdef.to_s, 0)
self.contents.draw_text(4, 52, 400, 32, "Int: " + $data_armors[@item.id].int_plus.to_s, 0)
self.contents.draw_text(4, 67, 400, 32, "Agi: " + $data_armors[@item.id].agi_plus.to_s, 0)
end
if @item.is_a?(RPG::Item)
if @item.id != Item_Ouro::Item_Id.to_i
self.contents.draw_text(4, 22, 400, 32, "Atk: " + "0", 0)
self.contents.draw_text(4, 37, 400, 32, "Def: " + "0", 0)
self.contents.draw_text(4, 52, 400, 32, "Int: " + "0", 0)
self.contents.draw_text(4, 67, 400, 32, "Agi: " + "0", 0)
else
self.contents.draw_text(4, 22, 400, 32, "Dinheiro do Jogo", 0)
end
end
#if @item.is_a?(RPG::Item)
#if $loja == true
if $help_loja == true
if $loja_cash == true
@desconto = (@item.price*60)/100
rect = Rect.new(4, 117, self.contents.width - 8, 32)
self.contents.draw_text(rect, "Cash: "+(@item.price-@desconto).to_s, 1)
#self.contents.draw_text(34, 102, 400, 32, "$ "+@item.price.to_s, 0)
else
rect = Rect.new(4, 117, self.contents.width - 8, 32)
self.contents.draw_text(rect, "Gold: "+@item.price.to_s, 1)
end
else
if @item.id != Item_Ouro::Item_Id.to_i
rect = Rect.new(4, 117, self.contents.width - 8, 32)
self.contents.draw_text(rect, "Gold: "+(@item.price/2).to_s, 1)
#self.contents.draw_text(34, 102, 400, 32, "$ "+(@item.price/2).to_s, 0)
else
if !@item.is_a?(RPG::Item)
rect = Rect.new(4, 117, self.contents.width - 8, 32)
self.contents.draw_text(rect, "$ "+(@item.price/2).to_s, 1)
end
end
end
#end
#end
if @item.is_a?(RPG::Weapon)
self.contents.draw_text(4, 22, 400, 32, "Atk: " + $data_weapons[@item.id].atk.to_s, 0)
self.contents.draw_text(4, 37, 400, 32, "Def: " + $data_weapons[@item.id].pdef.to_s, 0)
self.contents.draw_text(4, 52, 400, 32, "Int: " + $data_weapons[@item.id].int_plus.to_s, 0)
self.contents.draw_text(4, 67, 400, 32, "Agi: " + $data_weapons[@item.id].agi_plus.to_s, 0)
weapon_set = $data_classes[@actor.class_id].weapon_set
if weapon_set.include?(@item.id)
@resposta = "Pode"
self.contents.font.color = Color.new(65,255,65)
else
@resposta = "Não pode"
self.contents.font.color = Color.new(255,43,43)
end
rect = Rect.new(-3+2, 87, self.contents.width + 3, 32)
self.contents.draw_text(rect, "#{@resposta} ser equipado por", 1)
rect2 = Rect.new(4, 100, self.contents.width - 8, 32)
self.contents.draw_text(rect2, "#{$data_classes[$game_party.actors[0].class_id].name}", 1)
#rect2 = Rect.new(4, 107, self.contents.width - 8, 32)
#self.contents.draw_text(rect, "#{$data_classes[$game_party.actors[0].class_id].name}", 1)
if $loja == true
if $help_loja == true
#self.contents.draw_text(34, 67, 400, 32, "Preço: "+@item.price.to_s, 0)
else
#self.contents.draw_text(34, 67, 400, 32, "Preço: "+(@item.price/2).to_s, 0)
end
end
elsif @item.is_a?(RPG::Armor)
armor_set = $data_classes[@actor.class_id].armor_set
if armor_set.include?(@item.id)
@resposta = "Pode"
self.contents.font.color = Color.new(65,255,65)
else
@resposta = "Não pode"
self.contents.font.color = Color.new(255,43,43)
end
rect = Rect.new(-3+2, 87, self.contents.width + 3, 32)
self.contents.draw_text(rect, "#{@resposta} ser equipado por", 1)
rect2 = Rect.new(4, 100, self.contents.width - 8, 32)
self.contents.draw_text(rect2, "#{$data_classes[$game_party.actors[0].class_id].name}", 1)
#rect2 = Rect.new(4, 107, self.contents.width - 8, 32)
#self.contents.draw_text(rect2, "#{$data_classes[$game_party.actors[0].class_id].name}", 1)
if $loja == true
if $help_loja == true
#self.contents.draw_text(34, 67, 400, 32, "Preço: "+@item.price.to_s, 0)
else
#self.contents.draw_text(34, 67, 400, 32, "Preço: "+(@item.price/2).to_s, 0)
end
end
end
end
end
end
bom se voce leu a explicaçao anterior vai notar o que foi editado e personalizado !
Nanzin > Por criar os 2 Sistemas e pela Aula/Tutorial
Jonny > Por me Dar o script do MOG pra min adaptar!
Marlos > por criar o NP Master v3.0
Rodrigo > por recolorir o ruby utilizado nos buttons!
MOGHUNTER > por criar o script editado!
A Todos os meus amigos!
Nao Entenderam Bulhufas que tah no tutorial?
- ou voce e muito leigo mesmo ou nem leu o tutorial kkkkkkkkkkkkk
Instruçoes Finais: crie um evento com a seguinte pergunta, deseja abrir qual loja?
coloque 2 opçoes: Gold, Cash
ai dentro de
[gold]
chamar script: $loja_cash = nil
coloque aqui a loja agora programada!
[cash]
chamar script: $loja_cash = true
coloque a loja aqui tbm.
- Screenshot:
coloque sempre $loja_cash = nil!
Download Demo
Última edição por Nanzin em Sáb Nov 26, 2011 6:35 pm, editado 3 vez(es)
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
nem li mais
ebaaaaaaaaaa aleluia agora só falta o de VIP e mapa só acessavel quem for vip u.ú
edit : +8 Créditos
ebaaaaaaaaaa aleluia agora só falta o de VIP e mapa só acessavel quem for vip u.ú
edit : +8 Créditos
Última edição por wallace123 em Qui Nov 24, 2011 10:25 pm, editado 1 vez(es)
_________________
https://www.facebook.com/wallace.o.b
Curta, interaja, compartilhe. :)
Curta, interaja, compartilhe. :)
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
@wallace > talvez eu faça...
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] Cash System Avançado/Loja Cash
Só vi o começo porque nao crio jogos, mas pelo tamanho do topico devo parabenizar você Nanzin, +1 Cred
_________________
Eu poderia ser a pessoa mais agradavel do mundo! mas optei por ser eu mesmo.
Página 1 de 7 • 1, 2, 3, 4, 5, 6, 7
Tópicos semelhantes
» [Tutorial/AULA] SSFSNPM {Script System Fome Sede NetPlay Master}
» Criando uma Loja de CASH
» Loja de cash
» Loja de Cash (NP Master)
» [Tutorial]Sistema de PK Avançado NP Master v3.0
» Criando uma Loja de CASH
» Loja de cash
» Loja de Cash (NP Master)
» [Tutorial]Sistema de PK Avançado NP Master v3.0
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Tutoriais
Página 1 de 7
Permissões neste sub-fórum
Não podes responder a tópicos
|
|