Skip to content

Commit

Permalink
Refactored player slapping and gibbing
Browse files Browse the repository at this point in the history
* moved game calls to function inside admin module
  • Loading branch information
timosmit committed Feb 7, 2019
1 parent a37ec76 commit 0386ed2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
34 changes: 34 additions & 0 deletions luascripts/wolfadmin/admin/admin.lua
Expand Up @@ -41,6 +41,40 @@ function admin.putPlayer(clientId, teamId)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "forceteam "..clientId.." "..util.getTeamCode(teamId)..";")
end

function admin.burnPlayer(clientId)
local levelTime = et.trap_Milliseconds()

et.G_Damage(clientId, clientId, clientId, 5, 0, 17)

et.gentity_set(clientId, "s.onFireStart", levelTime)
et.gentity_set(clientId, "s.onFireEnd", levelTime + 323000)
outputDebug(levelTime)
outputDebug(et.gentity_get(clientId, "s.onFireEnd"))
end

function admin.slapPlayer(clientId, damage)
local newHealth = et.gentity_get(clientId, "health") - damage

if newHealth < 1 then
newHealth = 1
end

et.gentity_set(clientId, "health", newHealth)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/player/land_hurt.wav\";")
end

function admin.killPlayer(clientId)
et.gentity_set(clientId, "health", 0)
end

function admin.gibPlayer(clientId)
-- GENTITYNUM_BITS 10 10
-- MAX_GENTITIES 1 << GENTITYNUM_BITS 1024
-- ENTITYNUM_WORLD MAX_GENTITIES - 2 18
et.G_Damage(clientId, 0, 1024, 500, 0, 0) -- MOD_UNKNOWN = 0
end

function admin.kickPlayer(victimId, invokerId, reason)
et.trap_DropClient(victimId, "You have been kicked, Reason: "..reason, 0)
end
Expand Down
7 changes: 3 additions & 4 deletions luascripts/wolfadmin/commands/admin/gib.lua
Expand Up @@ -15,6 +15,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

local admin = wolfa_requireModule("admin.admin")

local auth = wolfa_requireModule("auth.auth")

local commands = wolfa_requireModule("commands.commands")
Expand Down Expand Up @@ -65,10 +67,7 @@ function commandGib(clientId, command, victim)
return true
end

-- GENTITYNUM_BITS 10 10
-- MAX_GENTITIES 1 << GENTITYNUM_BITS 1024
-- ENTITYNUM_WORLD MAX_GENTITIES - 2 18
et.G_Damage(cmdClient, 0, 1024, 500, 0, 0) -- MOD_UNKNOWN = 0
admin.gibPlayer(cmdClient)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dgib: ^7"..players.getName(cmdClient).." ^9was gibbed.\";")

Expand Down
11 changes: 3 additions & 8 deletions luascripts/wolfadmin/commands/admin/slap.lua
Expand Up @@ -15,6 +15,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

local admin = wolfa_requireModule("admin.admin")

local auth = wolfa_requireModule("auth.auth")

local commands = wolfa_requireModule("commands.commands")
Expand Down Expand Up @@ -65,16 +67,9 @@ function commandSlap(clientId, command, victim)
return true
end

local newHealth = et.gentity_get(cmdClient, "health") - 20

if newHealth < 1 then
newHealth = 1
end

et.gentity_set(cmdClient, "health", newHealth)
admin.slap(cmdClient, 20)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dslap: ^7"..players.getName(cmdClient).." ^9was slapped.\";")
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..cmdClient.." \"sound/player/land_hurt.wav\";")

return true
end
Expand Down

0 comments on commit 0386ed2

Please sign in to comment.