General > Developers Corner

Need some help with a ULX LUA command.

<< < (11/14) > >>

Megiddo:
As far as the Ulysses team, we contact you if we'd like you to join. We'll keep in mind that you're interested.

Not to sound cruel, but if you're looking to be a programmer you'll need a lot more practice (Hey, we all started from nothing!). There's plenty of project ideas floating around to sink your teeth into. I'm almost always willing to help someone who needs help with the ULX/ULib API and sometimes other programming questions... as long as they've made an honest attempt to research the solution on their own first.

If you were looking to contribute to the team some other way, where do you see yourself helping out?

Edit: Also, on the issue of post length: This is a relatively slow forum, as long as your post is contributing to the conversation we don't mind short posts.

LuaTenshi:
OK, sorry for the delay but it will take some time untill I can test it again.


--- 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, 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.zomb:CallOnRemove( DespawnZomb, pl, pl.zomb)
pl:Spectate( OBS_MODE_IN_EYE )
pl:SpectateEntity( pl.zomb )
if not ( pl.zomb:Alive() ) then DespawnZomb( pl, pl.zomb ) end
if ( pl.zomb:Alive() ) then
timer.Create( "zombRemove_"..CurTime(), ztime, 1, DespawnZomb, pl, pl.zomb )
end

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, ztime )

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, ztime )

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." )

--- End code ---

This is what I have so far I have not tested but please tell me if you see any thing that may be messing it up.
I believe my call on remove function may break it. I also think I should add a timer stop.

ADDITION: I would like to know how I would call data out of UTime like getting how long a player has played on a server.

Edit:


--- Code: ---[addons\ulx_sv-hellfox_15\lua\ulx\modules\sh\sh_zombify.lua:36] attempt to call method 'GetPos' <a nil value>

--- End code ---

Aaron113:
ply:GetUTimeSessionTime()
ply:GetUTimeTotalTime()
I believe.

LuaTenshi:
I have edited my last post specifying the error that I got, I did try to fix this but to no avail. Well guess I will keep trying.

JamminR:

--- Quote from: HeLLFox_15 on July 13, 2011, 11:54:44 PM ---
--- Code: ---[addons\ulx_sv-hellfox_15\lua\ulx\modules\sh\sh_zombify.lua:36] attempt to call method 'GetPos' <a nil value>

--- End code ---

--- End quote ---

You're trying to get a position on a table of players, even if you only specify one.
Your ULX command setup uses cmds.PlayersArg - plural, which passes a table of player objects. It allows for multiple targets, but you have to loop through that table to get them even if it's only one.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version