General > Developers Corner
Need some help with a ULX LUA command.
JamminR:
What do those commands do?
(No need for explanation of the TF command. IMO, our "maul" was much better for punishments like that)
LuaTenshi:
--- Quote from: JamminR on June 26, 2011, 08:24:07 PM ---What do those commands do?
(No need for explanation of the TF command. IMO, our "maul" was much better for punishments like that)
--- End quote ---
give: Gives a specified weapon to a specified player.
arm: The opposite of strip.
spawn: Re-spawns a player.
Edit: I may be converting ABAH in the future so yea.
Back On Topic: Still did not test the zombify command. :( . Hope the server owner lets me test it tomorrow, I just co-own. Should I add pl.zomb:SetNPCState( 3 )?
LuaTenshi:
Ok, changed the code and I am going to test it now.
--- Code: ----- 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, command )
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_CHASE )
pl:SpectateEntity( pl.zomb )
timer.Create( "zombRemove_"..CurTime(), command, 1, DespawnZomb, pl, pl.zomb )
end
function DespawnZomb( pl, zomb )
if zomb then
zomb:Remove()
end
pl:UnSpectate()
pl:Freeze( false )
pl:Spawn()
end
function ulx.zombify( calling_ply, target_ply )
local pl = target_ply
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, own )
ulx.fancyLogAdmin( calling_ply, "#A zombified #T for #s seconds", target_ply, command )
end
local zombify = ulx.command( "Fun", "ulx zombify", ulx.zombify, "!zombify" )
zombify:addParam{ type=ULib.cmds.PlayerArg }
zombify:addParam{ type=ULib.cmds.NumArg, hint="command", min=10, max=60, default=10, ULib.cmds.optional }
zombify:defaultAccess( ULib.ACCESS_SUPERADMIN )
zombify:help( "Turn a single player into a zombie." )
--- End code ---
Please notice...
local Effect = EffectData()
Effect:SetOrigin(pos)
Effect:SetStart(pos)
Effect:SetMagnitude(512)
Effect:SetScale(128)
util.Effect("cball_explode", Effect)
LuaTenshi:
This script works, but I am missing one more part, how would I make the zombie kill-able and if the zombie dies the player re-spawns.
I have discovered that I can not specify the time that the player is zombified for. How ever it all seems correct and I am not getting an error exept when I run the command it says "HeLLFox_15 zombified Bot01 for (null) seconds"
Megiddo:
You need to add "command" to the function parameter list.
As far as how to make the player respawn when the zombie is killed, there's a callback on entity destroyed function somewhere. Maybe in the ents library? Or on the ent directly? Anyways, you can find it on the gmod wiki.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version