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)