• List all affected players with prop freezing command?
    2 replies, posted
Hello, I am some-what new to lua and had a question, before you ask, yes i've google ways to do this and found nothing. I made a ULX command to freeze all props on the server. But I would like to incorporate a message that states the amount of props that were frozen belong to each person. I.e.: 2 of zacklogan's props were frozen, so on for each player that has a prop that was frozen. Here's my command: [CODE]function ulx.lag( calling_ply ) total = 0 for k, v in ipairs( ents.FindByClass( "prop_physics" ) ) do local phys = v:GetPhysicsObject() if (phys and phys:IsValid()) then local owner = v:GetOwner() if(phys:IsMotionEnabled() == true) then if(owner != "world") then total = total + 1 phys:EnableMotion(false) end end end end ulx.fancyLogAdmin( calling_ply, "#A froze a total of #i props!", total ) end local lag = ulx.command( CATEGORY_NAME, "ulx lag", ulx.lag, "!lag" ) lag:defaultAccess( ULib.ACCESS_ADMIN ) lag:help( "Freezes all props." )[/CODE] Thanks to anyone that attempts to help me, it really means a lot!
make a table [CODE] function ulx.lag( calling_ply ) total = 0 track = {}; for k, v in ipairs( ents.FindByClass( "prop_physics" ) ) do local phys = v:GetPhysicsObject() if (phys and phys:IsValid()) then local owner = v:GetOwner() if(phys:IsMotionEnabled() == true) then if(owner != "world") then total = total + 1 phys:EnableMotion(false) if( track[ owner:Nick() ] ) then track[ owner:Nick() ] = track[ owner:Nick() ] + 1; else track[ owner:Nick() ] = 1; end end end end end for i, v in pairs( track ) do PrintMessage( HUD_PRINTTALK, v .. " of " .. i .. "s props were frozen" ); end ulx.fancyLogAdmin( calling_ply, "#A froze a total of #i props!", total ) end local lag = ulx.command( CATEGORY_NAME, "ulx lag", ulx.lag, "!lag" ) lag:defaultAccess( ULib.ACCESS_ADMIN ) lag:help( "Freezes all props." ) [/CODE]
Worked great, thanks!
Sorry, you need to Log In to post a reply to this thread.