Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name PreFab 1 v1
- @persist C PreFabs:table Selected:table Tempname:string Cat Temp:table
- if (first() | duped() | dupefinished())
- {
- runOnTick(1)
- runOnChat(1)
- runOnFile(1)
- C = 1
- Cat = 1
- }
- if (owner():weapon():type() == "weapon_crowbar")
- {
- local Props = Selected[1,array]
- local Colors = Selected[2,array]
- local Mats = Selected[3,array]
- local Alphas = Selected[4,array]
- local Poses = Selected[5,array]
- local Angs = Selected[6,array]
- local Models = Selected[7,array]
- local Prop = owner():aimEntity()
- if (owner():keyAttack2())
- {
- if (Prop:isValid())
- {
- stoptimer("select")
- timer("select",10)
- }
- }
- if (clk("select"))
- {
- local Color = Prop:getColor()
- local Mat = Prop:getMaterial()
- local Alpha = Prop:getAlpha()
- local Pos = entity():toLocal(Prop:pos())
- local Ang = entity():toLocal(Prop:angles())
- local Model = Prop:model()
- Prop:setColor(vec(0,0,255))
- Prop:setAlpha(100)
- Props[Props:count()+1,entity] = Prop
- Colors[Colors:count()+1,vector] = Color
- Mats[Mats:count()+1,string] = Mat
- Alphas[Alphas:count()+1,number] = Alpha
- Poses[Poses:count()+1,vector] = Pos
- Angs[Angs:count()+1,angle] = Ang
- Models[Models:count()+1,string] = Model
- }
- if (owner():keyUse())
- {
- if (Prop:isValid())
- {
- stoptimer("deselect")
- timer("deselect",10)
- }
- }
- if (clk("deselect"))
- {
- for (I=1,Props:count())
- {
- if (Props[I,entity] == Prop)
- {
- Prop:setColor(Colors[I,vector])
- Prop:setAlpha(Alphas[I,number])
- Props:remove(I)
- Colors:remove(I)
- Mats:remove(I)
- Alphas:remove(I)
- Poses:remove(I)
- Angs:remove(I)
- Models:remove(I)
- }
- }
- }
- Selected[1,array] = Props
- Selected[2,array] = Colors
- Selected[3,array] = Mats
- Selected[4,array] = Alphas
- Selected[5,array] = Poses
- Selected[6,array] = Angs
- Selected[7,array] = Models
- }
- if (chatClk(owner()))
- {
- local SS = owner():lastSaid():explode(" ")
- if (SS[1,string]:lower() == ".psave" & SS[2,string] != "" & SS[2,string] != " ")
- {
- if (fileCanWrite())
- {
- local Prefab = vonEncode(Selected)
- fileWrite(">e2shared/presets_" + SS[2,string]:lower() + ".txt" , Prefab)
- local Props = Selected[1,array]
- local Colors = Selected[2,array]
- local Alphas = Selected[4,array]
- for (I=1,Props:count())
- {
- Props[I,entity]:setColor(Colors[I,vector])
- Props[I,entity]:setAlpha(Alphas[I,number])
- }
- Selected:remove(1)
- Selected:remove(2)
- Selected:remove(3)
- Selected:remove(4)
- Selected:remove(5)
- Selected:remove(6)
- Selected:remove(7)
- hideChat(1)
- print("File Saved")
- }
- else
- {
- hideChat(1)
- print("File Saving on cooldown")
- }
- }
- if (SS[1,string]:lower() == ".pdsave" & SS[2,string] != "" & SS[2,string] != " ")
- {
- if (fileCanWrite())
- {
- local Prefab = vonEncode(Selected)
- fileWrite(">e2shared/presets_" + SS[2,string]:lower() + ".txt" , Prefab)
- local Props = Selected[1,array]
- for (I=1,Props:count())
- {
- Props[I,entity]:propDelete()
- }
- Selected:remove(1)
- Selected:remove(2)
- Selected:remove(3)
- Selected:remove(4)
- Selected:remove(5)
- Selected:remove(6)
- Selected:remove(7)
- hideChat(1)
- print("File Saved and props removed")
- }
- else
- {
- hideChat(1)
- print("File Saving on cooldown")
- }
- }
- if (SS[1,string]:lower() == ".premsel")
- {
- local Props = Selected[1,array]
- for (I=1,Props:count())
- {
- Props[I,entity]:propDelete()
- }
- Selected:remove(1)
- Selected:remove(2)
- Selected:remove(3)
- Selected:remove(4)
- Selected:remove(5)
- Selected:remove(6)
- Selected:remove(7)
- hideChat(1)
- print("Selection has been removed")
- }
- if (SS[1,string]:lower() == ".punsel")
- {
- local Props = Selected[1,array]
- local Colors = Selected[2,array]
- local Alphas = Selected[4,array]
- for (I=1,Props:count())
- {
- Props[I,entity]:setColor(Colors[I,vector])
- Props[I,entity]:setAlpha(Alphas[I,number])
- }
- Selected:remove(1)
- Selected:remove(2)
- Selected:remove(3)
- Selected:remove(4)
- Selected:remove(5)
- Selected:remove(6)
- Selected:remove(7)
- hideChat(1)
- print("Selection deselected")
- }
- if (SS[1,string]:lower() == ".pload")
- {
- if (fileCanLoad() & !fileLoading())
- {
- fileLoad(">e2shared/presets_" + SS[2,string]:lower()+".txt")
- print("Loading Preset...")
- Tempname = SS[2,string]:lower()
- }
- else
- {
- print("File cannot be loaded")
- }
- hideChat(1)
- }
- if (SS[1,string]:lower() == ".phelp")
- {
- print("Commands and descriptions are as following:")
- print(".phelp - Displays this help message")
- print(".psave - Saves the current selection to the given name")
- print(".pdsave - Saves selection to the given name and removes afterwards")
- print(".punsel - Unselects all selected props without saving")
- print(".premsel - Removes currently selected props without saving")
- hideChat(1)
- }
- }
- if (fileClk() & fileLoaded())
- {
- local CC = PreFabs:count()
- local Temptable = table()
- Temptable[1,string] = Tempname
- local Pref = vonDecodeTable(fileRead())
- local Tem = Temptable:merge(Pref)
- PreFabs[CC+1,table] = Tem
- timer("init",100)
- print("Loaded preset " + Tempname)
- }
- if (clk("init"))
- {
- if (propCanCreate())
- {
- if (Temp:count() > 0)
- {
- local Props = Temp[1,array]
- local Colors = Temp[2,array]
- local Mats = Temp[3,array]
- local Alphas = Temp[4,array]
- local Poses = Temp[5,array]
- local Angs = Temp[6,array]
- local Models = Temp[7,array]
- if (C<Models:count()+1)
- {
- if (!Props[C,entity]:isValid())
- {
- Props[C,entity] = propSpawn(Models[C,string],1)
- Props[C,entity]:setColor(Colors[C,vector])
- Props[C,entity]:setAlpha(Alphas[C,number])
- Props[C,entity]:setMaterial(Mats[C,string])
- Props[C,entity]:setPos(entity():toWorld(Poses[C,vector]))
- Props[C,entity]:setAng(entity():toWorld(Angs[C,angle]))
- }
- else
- {
- C++
- }
- }
- else
- {
- C = 2
- Cat++
- if (Cat > PreFabs:count())
- {
- Cat = 1
- }
- Temp[1,array] = PreFabs[Cat,table][2,array]
- Temp[2,array] = PreFabs[Cat,table][3,array]
- Temp[3,array] = PreFabs[Cat,table][4,array]
- Temp[4,array] = PreFabs[Cat,table][5,array]
- Temp[5,array] = PreFabs[Cat,table][6,array]
- Temp[6,array] = PreFabs[Cat,table][7,array]
- Temp[7,array] = PreFabs[Cat,table][8,array]
- }
- }
- else
- {
- Temp[1,array] = PreFabs[Cat,table][2,array]
- Temp[2,array] = PreFabs[Cat,table][3,array]
- Temp[3,array] = PreFabs[Cat,table][4,array]
- Temp[4,array] = PreFabs[Cat,table][5,array]
- Temp[5,array] = PreFabs[Cat,table][6,array]
- Temp[6,array] = PreFabs[Cat,table][7,array]
- Temp[7,array] = PreFabs[Cat,table][8,array]
- }
- }
- timer("init",100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement