Skip to content

Instantly share code, notes, and snippets.

@Xp3r7
Created August 12, 2014 21:05
Show Gist options
  • Save Xp3r7/aa850da9ecd5d0585d72 to your computer and use it in GitHub Desktop.
Save Xp3r7/aa850da9ecd5d0585d72 to your computer and use it in GitHub Desktop.
Put this in your "GarrysMod > garrysmod > data > expression2" folder as a .txt file! This is a fairy I created not very complex requires PlyCore and Doragon's AdminCore
@name Companion Cube V2.6.4
@persist PN:string TP:entity BO:entity Color:vector Col:table
@persist Pos:table Prop:entity P:entity Feed HM Spiral
@persist Vec:vector Tick
#Makes the chip run
runOnChat(1)
runOnTick(1)
#Multy Statement Variables
O = owner()
E = entity()
S = owner():lastSaid():explode(" ")
GG = (O:pos() - E:pos() + vec(0,0,100))
# For apply force ^
#Settings
if(first()){
holoCreate(1)
holoModel(1, "hq_cube")
holoColor(1, vec4(0,255,0,255))
holoMaterial(1, "models/props_combine/portalball001_sheet")
holoPos(1, (O:pos()+ vec(0,0,100)))
holoParent(1, E)
holoEntity(1):setTrails(5,5,3,"trails/laser",vec(0,255,0),255)
print(3, "Made by Wire King (STEAM_0:0:22117849)")
print(3, "http://steamcommunity.com/profiles/76561198004501426")
print(3, "Type !help for all of your commands")
E:setMass(50000)
# The apply force can kill on some servers depending on the
# settings if the server has FPP (Falco's Prop Protection)
# E:applyForce((GG + $GG*5)*E:mass())
# E:setAng(ang(0,0,0))
PN = "Ezio Jr"
Feed = 20
HM == 0
}
timer("feed", 60000)
timer("prop", 1000)
# Holds the prop above your head for old command instead of
# a holo we could use a prop this causes lag on some servers
#if(Hold == 1){Prop:setPos(O:pos() + vec(0,0,100))}
if(tickClk()){
holoPos(1, O:pos() + vec(0,0,100))
holoAng(1, ang(0,O:angles():yaw(),0))
}
# Gets the String and sets the name
if(S[1,string]=="!name" & chatClk(owner())){
hideChat(1)
PN = S[2,string]
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"My name is now "+PN+"!")
}
# Kills the found player
if(S[1,string]=="!kill" & chatClk(owner())){
hideChat(1)
TP = findPlayerByName(S[2, string])
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"Yes Sir! Killing "+TP:name()+"!")
BO = propSpawn("models/props_c17/oildrum001_explosive.mdl", TP:pos(), 1)
BO:propBreak()
BO:setMass(50000)
# TP:dmgApplyDamage(100000)
# VT = ( ( ( TP:pos() + vec(0,0,45) ) - E:pos() ) * 15 - E:vel() / 2 ) * E:mass()
# E:applyForce(VT)
}
#Saves the current Pos with a string as an index
if(S[1, string]=="!savepos" & chatClk(O)){
hideChat(1)
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"Position saved as "+S[2, string]+"!")
Pos[S[2, string], vector] = O:pos()
}
if(S:string(1)=="!color" & chatClk(O)){
hideChat(1)
Red = S:string(2):toNumber()
Green = S:string(3):toNumber()
Blue = S:string(4):toNumber()
holoColor(1, vec(Red,Green,Blue))
holoEntity(1):setTrails(5,5,5,"trails/laser",vec(Red,Green,Blue),255)
}
if(S:string(1)=="!material"){
hideChat(1)
Mat = S:string(2)
holoMaterial(1, Mat)
}
if(S[1, string]=="!removepos"){
hideChat(1)
Vec = Pos[S[2, string], vector]
if(Vec){
Pos:removeVector(S[2, string])
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"Removing position"+Vec+"!")
}
}
# Prints all the saved positions
if(O:lastSaid()=="!printpos" & chatClk(O)){
hideChat(1)
printColor(vec(255,255,255),""+Pos:toString())
}
# Sends you to the position but it has to
# be the exact string that you saved in the table
if(S[1, string]=="!gotopos" & chatClk(O)){
hideChat(1)
Vec = Pos[S[2, string], vector]
if(Vec) {
print(3, PN+": Yes Sir! Sending us to "+S[2, string])
O:plySetPos(Vec)
}else{
printColor(vec(0,255,0),PN,vec(255,255,255),":",vec(255,0,0)," There is no position saved under the name \"" + S[2,string] + "\"!")
}
}
if(clk("feed") & HM == 1){
Feed -= 1
print(3, PN+": My hunger is now "+Feed)
}
# This is to feed the Pet cube sp he doesn't die with hungermod
if(O:lastSaid()=="!feed" & chatClk(O)){
hideChat(1)
Feed += 5
if(Feed > 20){
Feed = 20
}
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),""+Feed)
}
# This show's his hunger in points
if(O:lastSaid()=="!hunger" & chatClk(O) & HM == 1){
hideChat(1)
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),""+Feed)
}
# These are just warnings
if(Feed == 1 & clk("feed")){
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"Feed me! I am about to die!")
}
# Another warning
if(Feed == 0 & clk("feed")){
printColor(vec(0,255,0),PN,vec(255,255,255),": ",vec(255,0,0),"I have died! You will have to respawn me!")
selfDestruct()
}
# This sets the hunger number
if(S[1, string]=="!hset" & chatClk(O)& HM == 1){
hideChat(1)
if(S[2, string]:toNumber() <= 20){
Feed = S[2, string]:toNumber()
}
}
# This is to enable the hunger mod
if(O:lastSaid()=="!hon" & chatClk(O)){
hideChat(1)
HM == 1
hint("Hungermod enabled",5)
}
# This disables it
if(O:lastSaid()=="!hoff" & chatClk(O)){
hideChat(1)
HM == 0
hint("Hunger mod disabled",5)
}
if(S:string(1)=="!spawn" & chatClk(O)){
hideChat(1)
Ent = S:string(2)
entSpawn(Ent, O:aimPos())
}
if(O:keyPressed("x") & clk("prop")){
BO = propSpawn("models/props_c17/oildrum001_explosive.mdl", O:aimPos(), 1)
BO:propBreak()
}
if(O:lastSaid()=="!help" & chatClk(O)){
hideChat(1)
print(3,"See Console for details!")
print(1,"****************************Companion Cube****************************")
print(1,"!kill <playername> - Kills specified player.")
print(1,"!name <name> - Names your pet.")
print(1,"!savepos - Save's position for you to teleport to later!")
print(1,"!gotopos - Goes to saved position!")
print(1,"!color R G B - R G and B are numbers 0 - 255 They set the color of the cube!")
print(1,"!material <material> - Sets the material of the cube!")
print(1,"!printpos - Prints all the positions you have saved")
print(1,"!feed - Feed your pet he gets hungry! (Goes up by 5)")
print(1,"!hunger - Prints what the hunger is so far")
print(1,"X - Press X to spawn and break an explosive barrel")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment