From fe25f62a6e5c3a61d067c1c70be5e696f8ca534b Mon Sep 17 00:00:00 2001 From: "Ben Russell (300178622)" Date: Sun, 30 Jun 2013 09:39:24 +1200 Subject: [PATCH] /resetgame --- pkg/base/commands.lua | 12 ++++------- pkg/base/obj_intent.lua | 47 +++++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/pkg/base/commands.lua b/pkg/base/commands.lua index 81f2911..230f561 100644 --- a/pkg/base/commands.lua +++ b/pkg/base/commands.lua @@ -120,15 +120,11 @@ command_register({ }) command_register({ - command = "me", - permission = "me", - usage = "/me ", + command = "resetgame", + permission = "kick", -- TODO: give own permission for this + usage = "/resetgame", func = function(plr, plrid, neth, prms, msg) - if table.getn(prms) > 0 then - net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFFFFFFFF, "* "..plr.name.." "..string.sub(msg,5))) - else - commands["help"].func(plr, plrid, neth, {"me"}) - end + reset_game_ctf() end }) diff --git a/pkg/base/obj_intent.lua b/pkg/base/obj_intent.lua index 9743f66..c37df6a 100644 --- a/pkg/base/obj_intent.lua +++ b/pkg/base/obj_intent.lua @@ -15,6 +15,34 @@ along with Ice Lua Components. If not, see . ]] +function reset_game_ctf() + local i + for i=1,players.max do + if players[i] ~= nil then + players[i].spawn() + net_broadcast(nil, common.net_pack("BBfffBB", + PKT_PLR_SPAWN, i, + players[i].x, players[i].y, players[i].z, + players[i].angy*128/math.pi, players[i].angx*256/math.pi)) + end + end + for i=1,#intent do + intent[i].spawn() + local x,y,z + x,y,z = intent[i].get_pos() + intent[i].player = nil + net_broadcast(nil, common.net_pack("BHhhhB", PKT_ITEM_POS, + i, x,y,z, intent[i].get_flags() )) + net_broadcast(nil, common.net_pack("BHB", PKT_ITEM_CARRIER, i, 0)) + end + for i=0,teams.max do + if teams[i] ~= nil then + teams[i].score = 0 + net_broadcast(nil, common.net_pack("Bbh", PKT_TEAM_SCORE, i, teams[i].score)) + end + end +end + if client then mdl_tent, mdl_tent_bone = skin_load("pmf", "tent.pmf", DIR_PKG_PMF), 0 mdl_intel, mdl_intel_bone = skin_load("pmf", "intel.pmf", DIR_PKG_PMF), 0 @@ -106,6 +134,8 @@ function new_intel(settings) end function this.intel_drop() + if not this.player then return end + this.visible = true this.x = math.floor(this.player.x+0.5)+0.5 this.y = math.floor(this.player.y+0.5) @@ -126,22 +156,7 @@ function new_intel(settings) teams[this.player.team].score = teams[this.player.team].score + 1 net_broadcast(nil, common.net_pack("Bbh", PKT_TEAM_SCORE, this.player.team, teams[this.player.team].score)) if teams[this.player.team].score >= TEAM_INTEL_LIMIT then - local i - for i=1,players.max do - if players[i] ~= nil then - players[i].spawn() - net_broadcast(nil, common.net_pack("BBfffBB", - PKT_PLR_SPAWN, i, - players[i].x, players[i].y, players[i].z, - players[i].angy*128/math.pi, players[i].angx*256/math.pi)) - end - end - for i=0,teams.max do - if teams[i] ~= nil then - teams[i].score = 0 - net_broadcast(nil, common.net_pack("Bbh", PKT_TEAM_SCORE, i, teams[i].score)) - end - end + reset_game_ctf() else local i for i=1,players.max do