Nice Lol.
haha. i still don't know why my brain decides 1am is a good time to learn programming languages... same thing occurred with expression2.
anyways. I Bring You Semi Pointless Expression 2 Extensions...
haha, i really do need to learn how to limit functions to the owner or if your admin, everybody...Code:/****************************************************************************/ /******** Some Usefull Extensions By dracotonisamond A.K.A. SPiRALFACToR ********/ /*********** Why Do I Always Run Headlong Into New Stuff At 1AM... ***********/ /*Thanks To Whoever wrote the player.lua extensions in e2, tis where i got the syntax :D*/ /****************************************************************************/ //my first forrey into lua really. im using this to rewrite the syntax over and over to pound it into my head sorta speak. //i like this. has a few uses off the top of my head, such as holo lasers lol. or just annother key you can trigger from. e2function number entity:keyFlashlight() if not validEntity(this) then return 0 end if not this:IsPlayer() then return 0 end if this:FlashlightIsOn() then return 1 else return 0 end end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getAIM() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetAIM() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getEmail() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetEmail() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getGTalk() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetGTalk() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getMSN() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetMSN() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getWebsite() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetWebsite() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getXFire() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetXFire() end //heh, may use this in some sort of owner identification/authentication system. e2function string entity:getLocation() if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:GetLocation() end //dont know wtf i could use this for, but it looked interesting. //then again, i wonder if it will pickup if a client is timing out. that has a use. e2function number entity:packetLoss() if(!validEntity(this)) then return 0 end if(this:IsPlayer()) then return this:PacketLoss() else return 0 end end //i thought this one was neat e2function array entity:getWeapons() if not validEntity(this) then return {} end if not this:IsPlayer() then return {} end return this:GetWeapons() end //hmm... not sure if this is needed, or safe. but i thought of a use. Wire Socket Radio Setup Before The Person Leaves. //No Need To Check Whatsmyip.com or w/e e2function string entity:ipAdress() if(!self.player:IsAdmin()) then return "You Are Not Admin Terminating Function" end if(!validEntity(this)) then return "" end if(!this:IsPlayer()) then return "" end return this:IPAddress() end //pointless function is pointless xD //my brain said i needed it at 4:30am //made it admin only lols e2function void entity:flashMyLight() if not self.player:IsAdmin() then return end if not validEntity(this) then return end if not this:IsPlayer() then return end this:Flashlight(!this:FlashlightIsOn()) end //Set Stuff On FIRE >:D e2function void entity:ignite(number length) if not validPhysics(this) then return end if not isOwner(self, this) then return end this:Ignite(length) end //put the fire out :( //what the crap? if you set a duration, it just postpones the fire lol. e2function void entity:postponeFire() if not validPhysics(this) then return end if not isOwner(self, this) then return end this:Extinguish() end //Will It Float xD e2function void entity:buoyancy(number ratio) if not validPhysics(this) then return end if not isOwner(self, this) then return end if(this:IsPlayer()) then return end local ratio = math.Clamp( ratio, 0.001, 1000) local phys = this:GetPhysicsObject() phys:SetBuoyancyRatio(ratio) end //i found out that if you set the mass after you call buoyancy in the e2, the buoyancy WILL fail... so i made this one for lazy peeps. e2function void entity:buoyancyMass(number mass, number ratio) if not validPhysics(this) then return end if not isOwner(self, this) then return end if(this:IsPlayer()) then return end local ratio = math.Clamp(ratio, 0.001, 1000) local mass = math.Clamp(mass, 0.001, 50000) local phys = this:GetPhysicsObject() phys:SetMass(mass) phys:SetBuoyancyRatio(ratio) end //Sound DSP's sound fun :P //heres a list of all the valid DSP's //http://wiki.garrysmod.com/?title=DSP_list //made sure you couldn't run "presets" it said it was BAD for some reason. //i assume it would crash your shit if the engine tried to utilize the said preset slots and you had already filled them or something. //Thanks to ACProdigy for the help with blacklisting logic. its and not & >.< e2function number entity:setDsp(number dsp) if not validEntity(this) then return 0 end if not this:IsPlayer() then return 0 end local dsp = math.Clamp(dsp, 0, 133) if(dsp>40 and dsp<55) or (dsp>59 and dsp<102) then return 0 end this:SetDSP( dsp, false ) return 1 end //Kill Things >:D // wrote this because divrans extension was causing a script error from finding to fast or something. e2function number entity:killTarget() if not self.player:IsAdmin() then return 0 end if not validEntity(this) then return 0 end if not this:IsPlayer() or this:IsNPC() then return 0 end this:Kill() return 1 end
as of now, the flashlight code could theoretically flash anybodys light at the tickrate of the server xD.
so, please. C&C and assistance would be awesome. as this is my first lua project...
heres some instructions on how to use them.
E:keyFlashlight()
basically, its a toggled input key like keyUse()
E:getAIM()
E:getEmail()
E:getGTalk()
E:getMSN()
E:getWebsite()
E:getXFire()
E:getLocation()
These All Return The Entity's Info On The Scoreboard.
E:packetLoss()
Returns Dropped Packets From The Player Entity.
E:getWeapons()
This Returns An Array Of An Entities Currently Held Weapons
E:ipAdress()
Returns The Player Entities IP Adress If The Owner Of The Chip Is An Admin
E:ignite(Duration)
light stuff on fire ofcourse! does not work on players from what i can test.
E:postponeFire()
can anyone tell me why Extinguish() doesn't put it out all the way when an entity is ignited with a set duration?
E:buoyancy(ratio)
This is something I've always wanted in e2. i mean, you have a regular stool, a Wire Buoyancy stool. But wheres the love for e2? Be sure if you use this you set the mass BEFORE you set the buoyancy because the way lua runs this command. apparently mass over rides buoyancy.
E:buoyancyMass(Mass, Buoyancy Ratio)
I made this one so if you want to set mass AND buoyancy. it will do it in the correct order every time. so no sunk ships from bad e2 coding lol.
Note on buoyancy. The higher the ratio, the more likely it will freak out and go past earth's escape velocity. kinda funny. example. i used a mass of 50k and a buoyancy of 50 to make a pipe float. the more mass the floaty object has(constrained objects count i think.) the higher ratio you will need. to high, and it will freak out.
E:setDsp(number)
Sets The Player Entities Soundscape.
use these as the numbers
DSP list - GMod Wiki
E:killTarget()
Kills the entity if you are an admin, and returns one when the unlucky recipient receives its present of death.
this is a duplicate of divrans kill function, but i wrote it in e2function format.
his function would script error if it was fed a variety of NPC's and players very quickly for some reason. and a regular player was using it in his turret and showed me this error. i have not been able to replicate it with mine.
and last but not least. My obligatory Retarded Cheese Poof Function.
E:flashMyLight()
i promised myself i would make one function that i could laugh at if i learned something tonight... sooo. every time the loop is run it will toggle your flashlight... or anyones flashlight...
don't know if it was the excess caffeine of just sleep deprivation. but i thought a whole map full of people wtf'ing about why there light was blinking on and off at the speed of lulz is a setup for hilarity.
EDIT: HAHA! this happened today with predictable results... i silently installed this today and reloaded the expression2 extensions on my server with 8 people connected. then proceeded to write a while loop that cycled through all the players and ran this function at an interval of 50... hilarity was epic.
EDIT2: made it admin only because someone else found it funny as hell xD.
so, any pointers, or Holy Crap WTF DONT DO THAT's are totally welcome.
attached the lua file for people who are copypasta illiterate.
EDIT: the attachment system doesnt like opera. it kinda b0rked the filename...
Random functions are random =P
Make a lag-detector and AIM-spammer E2 =P
Well if we're posting random E2 functions, take a look at my old ones. Made like half a year ago when I knew next to nothing of lua. Expect wierd shit.
Note that I did not steal anyone's ideas when making this. I don't know if setPos even existed when I made it. Probably did, but I didn't know that then.
I also think e2functon didn't exist then (that's why they're all registerFunction).
(Check out the boom function hehehhh)
Code:AddCSLuaFile("DivransE2Stuff.lua") /* Hello and thank you for using my E2 plugin! :D Here are all the syntaxes: E:freeze(N) "E:N" - if N != 1, unfreezes entity E. If N == 1, freezes entity E. - You can only target your own props. - You cannot target players or NPCs. E:setHealth(N) "E:N" - Sets player E's health to N. Is admin only. (It's esentially a Godmode) E:setArmor(N) "E:N" - Sets player E's armor to N. Is admin only. E:setSpeed(N) "E:N" - Sets player E's movement speed to N. Is admin only. - If N is 0 or lower, it will reset that player's movement speed to deafult instead of making it 0 or negative. E:setJump(N) "E:N" - Sets player E's jump strength to N. Is admin only. - If N is 0 or lower, it will reset that player's jump strength to deafult instead of making it 0 or negative. E:kill() "E:" - Kills the player or NPC. Is admin only (Obviously). boom(V,N1,N2) "VNN" - Creates an explosion at position V, dealing N1 damage with a radius of N2. Is admin only (Obviously). E:setPos(V) "EV" - Instantly teleports entity E to position V. Is admin only. E:setAngle(A) "E:A" E:setAngle(V) "E:V" - Instantly sets the entity E's angle to A or V. (Basically, a Wire Facer) chatPrint(N,S) "NS" - Prints the message S in chat for everyone to see. N can be 0, or 1 or 2. - If N is 0, it will print the exact message. - If N is 1, it will print "[E2] " + Message. - If N is 2, it will print "[ " + Owner of Expression's Name + "'s E2]" + Message chatPrint(S) "S" - Same as chatPrint(0,S) E:chatPrint(N,S) "E:NS" - Prints the message S in chat for E to see. N is the same as in chatPrint(N,S) E:chatPrint(S) "E:S" - Same as E:chatPrint(0,S) */ //SET FRAGS registerFunction("setFrags", "e:n", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!validEntity(rv1)) then return end if (!rv1:IsPlayer()) then return end local Target = rv1 local Number = rv2 if (Number < 0) then Number = 0 end Target:SetFrags( Number ) end) //SET FRAGS END //SET DEATHS registerFunction("setDeaths", "e:n", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!validEntity(rv1)) then return end if (!rv1:IsPlayer()) then return end local Target = rv1 local Number = rv2 if (Number < 0) then Number = 0 end Target:SetDeaths( Number ) end) //SET DEATHS END //PRINT TO CHAT VERSION 1 registerFunction("chatPrint", "ns", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!self.player:IsAdmin()) then return end local Msg = rv2 local Number = rv1 if (Number == 0) then Msg = Msg elseif (Number == 1) then Msg = "[E2] "..Msg elseif (Number == 2) then Msg = "[".. self.player:GetName() .."'s E2] ".. Msg else self.player:PrintMessage( HUD_PRINTTALK, "You can only use 0, 1 or 2. This message tells you that you entered the wrong number. This cannot be seen by others." ) return end for k,v in pairs ( player.GetAll() ) do v:PrintMessage( HUD_PRINTTALK, Msg ); end end) //PRINT TO CHAT VERSION 1 END //PRINT TO CHAT VERSION 2 registerFunction("chatPrint", "s", "", function(self,args) local op1 = args[2] local rv1 = op1[1](self,op1) if (!self.player:IsAdmin()) then return end local Msg = rv1 for k,v in pairs ( player.GetAll() ) do v:PrintMessage( HUD_PRINTTALK, Msg ); end end) //PRINT TO CHAT VERSION 2 END //PRINT TO CHAT VERSION 3 registerFunction("chatPrint", "e:s", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!self.player:IsAdmin()) then return end if (!validEntity(rv1)) then return end rv1:PrintMessage( HUD_PRINTTALK, rv2 ); end) //PRINT TO CHAT VERSION 3 END //PRINT TO CHAT VERSION 4 registerFunction("chatPrint", "e:ns", "", function(self,args) local op1, op2, op3 = args[2], args[3], args[4] local rv1, rv2, rv3 = op1[1](self,op1), op2[1](self,op2), op3[1](self,op3) if (!self.player:IsAdmin()) then return end if (!validEntity(rv1)) then return end local Number = rv2 local Msg = rv3 if (Number == 0) then Msg = Msg elseif (Number == 1) then Msg = "[E2] "..Msg elseif (Number == 2) then Msg = "[".. self.player:GetName() .."'s E2] ".. Msg else self.player:PrintMessage( HUD_PRINTTALK, "You can only use 0, 1 or 2. This message tells you that you entered the wrong number. This message cannot be seen by others." ) return end rv1:PrintMessage( HUD_PRINTTALK, Msg ); end) //PRINT TO CHAT VERSION 4 END //FREEZE registerFunction("freeze", "e:n", "n", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) local FrzTrgt = rv1 local Numbarz = rv2 if (FrzTrgt:IsPlayer() or FrzTrgt:IsNPC() or !isOwner(self,rv1)) then return 0 end if (!validEntity(FrzTrgt)) then return 0 end if (CLIENT) then return end Numbarz = math.Round(Numbarz) local POb = FrzTrgt:GetPhysicsObject() if (Numbarz == 1) then if (POb:IsMoveable()) then POb:EnableMotion(false) POb:Wake( ) end else if (!POb:IsMoveable()) then POb:EnableMotion(true) POb:Wake( ) end end return 1 end) //FREEZE END //SET HEALTH registerFunction("setHealth", "e:n", "n", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!validEntity(rv1)) then return 0 end if (!rv1:IsPlayer()) then return 0 end if (!self.player:IsAdmin()) then return 0 end local Target = rv1 local Health = rv2 if (CLIENT) then return end if(!Health) then return 0 end Target:SetHealth( math.Clamp(Health, 1, 99999) ) return 1 end) //SET HEALTH END //SET ARMOR registerFunction("setArmor", "e:n", "n", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if (!validEntity(rv1)) then return 0 end if (!rv1:IsPlayer()) then return 0 end if (!self.player:IsAdmin()) then return 0 end local Target = rv1 local Armor = rv2 if (CLIENT) then return end if(!Armor) then return 0 end Target:SetArmor( math.Clamp(Armor, 1, 99999) ) return 1 end) //SET ARMOR END //KILL registerFunction("kill", "e:", "n", function(self,args) local op1 = args[2] local rv1 = op1[1](self,op1) if(!rv1:IsPlayer() and !Target:IsNPC()) then return 0 end if (!validEntity(rv1)) then return 0 end if (!self.player:IsAdmin()) then return 0 end local Target = rv1 if (CLIENT) then return end Target:Kill() Target:AddFrags(1) return 1 end) //KILL END //SET SPEED registerFunction("setSpeed", "e:n", "n", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if(!rv1:IsPlayer()) then return 0 end if (!self.player:IsAdmin()) then return 0 end local Target = rv1 local Speed = rv2 if (CLIENT) then return end if (Speed < 1) then Target:SetWalkSpeed(250) Target:SetRunSpeed(500) else if (Speed > 999999) then Speed = 999999 end Target:SetWalkSpeed(Speed) Target:SetRunSpeed(Speed+250) end return 1 end) //SET SPEED END //SET JUMP registerFunction("setJump", "e:n", "n", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self,op1), op2[1](self,op2) if(!rv1:IsPlayer()) then return 0 end if (!self.player:IsAdmin()) then return 0 end local Target = rv1 local Jump = rv2 if (CLIENT) then return end if (Jump < 1) then Target:SetJumpPower(160) else if (Jump > 999999) then Jump = 999999 end Target:SetJumpPower(Jump) end return 1 end) //SET JUMP END //BOOM registerFunction("boom", "vnn", "", function(self,args) local op1, op2, op3 = args[2], args[3], args[4] local rv1, rv2, rv3 = op1[1](self, op1), op2[1](self, op2), op3[1](self, op3) local Positionz = Vector( rv1[1], rv1[2], rv1[3] ) if (!self.player:IsAdmin() or !util.IsInWorld(Positionz)) then return end util.BlastDamage( self.entity, self.player, Positionz, math.Clamp( rv3, 1, 1000 ), math.Clamp( rv2 / 2, 1, 10000 ) ) local effectdata = EffectData() effectdata:SetOrigin( Positionz ) util.Effect( "Explosion", effectdata, true, true ) end) //BOOM END //Teleport registerFunction("setPos", "e:v", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self, op1), op2[1](self, op2) local Pos = Vector( rv2[1], rv2[2], rv2[3] ) if (!validEntity(rv1)) then return end if (!self.player:IsAdmin()) then if (rv1:IsPlayer() or !isOwner(self,rv1)) then return end end if (!util.IsInWorld(Pos)) then return end rv1:SetPos( Pos ) end) //Teleport //Set Angle registerFunction("setAngle", "e:a", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self, op1), op2[1](self, op2) local Ang = Angle( rv2[1], rv2[2], rv2[3] ) rv1:SetAngles( Ang ) end) registerFunction("setAngle", "e:v", "", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self, op1), op2[1](self, op2) local Ang = (Vector( rv2[1], rv2[2], rv2[3] )):Angle() rv1:SetAngles( Ang ) end) //Set Angle End
SVN Tutorial
My SVN:Get dropbox and get 250 MB extra space: DropboxCode:http://divranspack.googlecode.com/svn/trunk/%20divranspack/
Make some to get data from the server, such as something for showing game-frames per second for the server (not fps, as srv isnt graphical).
heh, just what i need. some challenges. thanks guys. i like the idea of getting server fps. ill see what i can do.
and i just edited the code to add an ignite function >:D aand apparently a postponeFire function... any clue why Extinguish() doesn't stop fire if you ignite it with a duration?
and p.s. divran, those functions are hilarious. they were my main inspiration to learn how to do this.
hmm. im not quite sure if or how i could return the server fps/tickrate. but i did find a command that could return the clients render time. so that might be useful.
but i think i have something useful here. e2 buoyancy lol.
I've always wondered why e2 couldn't control buoyancy.
my use is to use e2 derma sliders to adjust the buoyancy of a boat until i have it perfect. always was a pain to do this with the regular stool(which sometimes servers DONT HAVE >:| ) or the wired buoyancy tool.
or maybe an automatic leveler for submarines without the pile of buoyancy controllers in the ass end.
New Function, E:setDsp(number). it modifies your soundscape to different predefined effects. and is a primer into a tad bit deeper programming for me atleast.(woo i used blacklisting)
Thanks to ACProdigy for helping me with my fail. its and not & >.<
EDIT: 50 post GET!
I saw the flashlight and ignite on your server. These are kinda pointless, but fun.
Bookmarks