Ulysses
General => Developers Corner => Topic started by: Sea Cucumber on March 26, 2014, 01:49:02 AM
-
Hello :)
currently I'm using serverguard on my server but have realized that I prefer ulx much more. I have a command in serverguard that will revive players when they are dead and bring them to life where they spawned with everything they had before they died. I'm a beginner so I don't have the best knowledge on how to port this and make it work in ULX but if someone could shed some light and help me that would be greatly appreciated!
-snip-
Problem has been solved, thread can be closed.
-
Untested, but try this:
function ulx.revive( calling_ply, target_ply )
local wepstab = target_ply.savedweapons or nil
local savedpos = target_ply.savedpos or nil
if not ( wepstab and savedpos ) then
calling_ply:ChatPrint( "This player does not have any saved data." )
return
end
if not target_ply:IsValid() then
return
end
target_ply:Spawn()
target_ply:SetPos( savedpos )
target_ply:SetLocalVelocity( Vector( 0, 0, 0, ) )
target_ply:StripWeapons()
for k, v in next, wepstab do
target_ply:Give( v )
end
ulx.fancyLogAdmin( calling_ply, "#A revived #T", target_ply )
end
local rw = ulx.command( "Utility", "ulx revive", ulx.revive, { "!restore", "!revive" } )
rw:addParam{ type=ULib.cmds.PlayerArg }
rw:defaultAccess( ULib.ACCESS_SUPERADMIN )
rw:help( "Restore a player's weapons" )
if ( SERVER ) then
hook.Add( "PlayerDeath", "SaveWeapons", function( ply )
ply.savedweapons = {}
for k, v in next, ply:GetWeapons() do
table.insert( ply.savedweapons, v:GetClass() )
end
ply.savedpos = ply:GetPos()
end )
end
-
You had an extra comma on target_ply:SetLocalVelocity( Vector( 0, 0, 0, ) ) but I fixed that and the code works. You don't know how much this helps me. Thanks man.
-
You had an extra comma on target_ply:SetLocalVelocity( Vector( 0, 0, 0, ) ) but I fixed that and the code works. You don't know how much this helps me. Thanks man.
Cool, glad I could help!