Author Topic: Need some help with a ULX LUA command.  (Read 28384 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Need some help with a ULX LUA command.
« Reply #60 on: July 22, 2011, 04:44:40 PM »
Try it out and see if it works or not. :)
Experiencing God's grace one day at a time.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Need some help with a ULX LUA command.
« Reply #61 on: July 23, 2011, 02:57:58 PM »
Now it says the following...

Code: [Select]
[addons\ulx_sv-hellfox_15\lua\ulx\modules\sh\sh_zombify.lua:15] attempt to call method 'Alive' <a nil value>
Edit: apparently 'Alive()' only works on players, what would I use to get if the zombie is alive or not?

I am going to try to use Entity:health() instead.
« Last Edit: July 23, 2011, 03:02:37 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Need some help with a ULX LUA command.
« Reply #62 on: July 23, 2011, 10:30:29 PM »
I think when an entity is killed or removed its entity is removed. So a simple if Entity then should work.


or Entity:IsValid()

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Need some help with a ULX LUA command.
« Reply #63 on: July 26, 2011, 05:07:34 AM »
[OLD](May-be) You may think this is odd but when I use my command on a player, they lose the ability to move and ULX does not recognize them as being in the server. They also lose any ranks they had on the server.
------------

My new code...

Code: [Select]
-- ULX Zombify for ULX SVN/ULib SVN by HeLLFox_15 with assistance from MrPresident, Megiddo, and JamminR
-- Organized by MrPresident
function Spawnzomb( pl, pos, ang, ztime )
R = { "npc_fastzombie", "npc_zombie", "npc_zombie_torso", "npc_zombine", "npc_fastzombie_torso" }

pl.zomb = ents.Create( R[math.random(1,5)] )
pl.zomb:SetAngles( ang )
pl.zomb:SetPos( pos )
pl.zomb:Spawn()
pl.zomb:Activate()
pl.zomb:SetNPCState(3)
pl:Spectate( OBS_MODE_DEATHCAM )
pl:SpectateEntity( pl.zomb )
if not ( pl.zomb ) then DespawnZomb( pl, pl.zomb, pos ) end
if ( pl.zomb ) then
timer.Create( "zombRemove_"..CurTime(), ztime, 1, DespawnZomb, pl, pl.zomb, pos )
end

end

function DespawnZomb( pl, zomb, pos )

if ( zomb and zomb:IsValid() ) then
pl:UnSpectate()
zomb:Remove()
end 
pl:Spawn()
pl:SetPos( pos )

end

function ulx.zombify( calling_ply, target_ply, ztime )

for _,pl in pairs( target_ply ) do
local pos = pl:GetPos()
local ang = pl:GetAngles()
local Effect = EffectData()
Effect:SetOrigin(pos)
Effect:SetStart(pos)
Effect:SetMagnitude(512)
Effect:SetScale(128)
util.Effect("cball_explode", Effect)

pl:EmitSound( "ambient/creatures/town_zombie_call1.wav", 100, 100 )
pl:StripWeapons()

Spawnzomb( pl, pos, ang, ztime )
end
ulx.fancyLogAdmin( calling_ply, "#A zombified #T for #s seconds", target_ply, ztime )
end
local zombify = ulx.command( "Fun", "ulx zombify", ulx.zombify, "!zombify" )
zombify:addParam{ type=ULib.cmds.PlayersArg }
zombify:addParam{ type=ULib.cmds.NumArg, hint="ztime", min=10, max=60, default=10, ULib.cmds.optional }
zombify:defaultAccess( ULib.ACCESS_SUPERADMIN )
zombify:help( "Turn a players into zombies." )

It seems to work...

Code: [Select]
L 07/26/2011 - 07:01:03: Log file started (file "logs\L0726000.log") (game "C:\srcds\orangebox\garrysmod") (version "4616")
L 07/26/2011 - 07:01:28: "Bot01<2><BOT><>" connected, address "none"
L 07/26/2011 - 07:01:28: "Bot01<2><BOT><>" entered the game
L 07/26/2011 - 07:01:29: server_cvar: "sv_tags" "alltalk,garrysmod125,gm:sandbox,gravhull,scriptenforcer,wiresvn2463"
L 07/26/2011 - 07:02:02: [ULX] (Console) zombified Bot01 for 10 seconds
L 07/26/2011 - 07:06:14: Log file closed

How ever I would like a ulx.fancyLogAdmin() to tell every one that the player you ran it on has been "unzombified".
I cry every time I see that I am not a respected member of this community.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given