mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-23 21:17:45 +00:00
Make //gm exp functional again
Not sure where it went, I guess it got lost in the Lua transition.
This commit is contained in:
parent
bcff4cd957
commit
9a188e1e7a
3 changed files with 29 additions and 0 deletions
|
@ -0,0 +1,9 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
command_sender = "[exp] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local amount = args[1]
|
||||
|
||||
player:add_exp(amount)
|
||||
printf(player, "Added %s exp.", amount)
|
||||
end
|
|
@ -1007,6 +1007,15 @@ impl ZoneConnection {
|
|||
Task::UpdateBuyBackList { list } => {
|
||||
self.player_data.buyback_list = list.clone();
|
||||
}
|
||||
Task::AddExp { amount } => {
|
||||
let current_exp;
|
||||
{
|
||||
let mut game_data = self.gamedata.lock().unwrap();
|
||||
current_exp = self.current_exp(&mut game_data);
|
||||
}
|
||||
self.set_current_exp(current_exp + amount);
|
||||
self.update_class_info().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.queued_tasks.clear();
|
||||
|
|
|
@ -80,6 +80,9 @@ pub enum Task {
|
|||
UpdateBuyBackList {
|
||||
list: BuyBackList,
|
||||
},
|
||||
AddExp {
|
||||
amount: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
|
@ -439,6 +442,10 @@ impl LuaPlayer {
|
|||
self.create_segment_self(op_code, data);
|
||||
}
|
||||
}
|
||||
|
||||
fn add_exp(&mut self, amount: u32) {
|
||||
self.queued_tasks.push(Task::AddExp { amount });
|
||||
}
|
||||
}
|
||||
|
||||
impl UserData for LuaPlayer {
|
||||
|
@ -589,6 +596,10 @@ impl UserData for LuaPlayer {
|
|||
Ok(())
|
||||
},
|
||||
);
|
||||
methods.add_method_mut("add_exp", |_, this, amount: u32| {
|
||||
this.add_exp(amount);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
|
||||
|
|
Loading…
Add table
Reference in a new issue