Last active
June 7, 2020 22:20
-
-
Save mozi-h/e3e343c764be161398dac6c824d0eb60 to your computer and use it in GitHub Desktop.
A Garry's Mod Expression 2 Chip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Coded by mozi_h (STEAM_0:1:51783286) | |
@name Kitchen Gun | |
@persist [Props Bullets]:array [Handle Chef]:entity R NoclipProps | |
if(first()) { | |
function number shouldCollide(Player:entity) { | |
#return 1 #Enable for everyone | |
#if(Player==owner()) {return 1} #Enable for yourself | |
#if(!Player:isAdmin()) {return 1} #Enable for Admins | |
#if(Player:steamID()=="STEAM_0:1:51783286") {return 1} #Enable for someone else | |
return 0 | |
} | |
propSpawnUndo(0) | |
propSpawnEffect(0) | |
Handle=propSpawn("models/props_interiors/pot02a.mdl",entity():pos()+vec(0,0,10),0) | |
Props=array( | |
"models/props_wasteland/cargo_container01.mdl", | |
"models/props_c17/furnitureStove001a.mdl", | |
"models/props_c17/FurnitureFridge001a.mdl", | |
"models/props_interiors/pot02a.mdl", | |
"models/props_interiors/pot01a.mdl", | |
"models/props_interiors/refrigeratorDoor02a.mdl", | |
"models/props_interiors/refrigeratorDoor01a.mdl", | |
"models/props_interiors/refrigerator01a.mdl", | |
"models/props_junk/garbage_coffeemug001a.mdl", | |
"models/props_junk/garbage_newspaper001a.mdl", | |
"models/props_c17/FurnitureSink001a.mdl", | |
"models/props_junk/garbage_milkcarton002a.mdl", | |
"models/food/burger.mdl", | |
"models/food/hotdog.mdl", | |
"models/noesis/donut.mdl", | |
"models/props_phx/misc/potato.mdl", | |
"models/props_lab/cactus.mdl" | |
) | |
function tell(E:entity,S:string) { | |
if(E==owner()) {printColor(vec(0,161,255),"[Kitchen Gun] ",vec(255,255,255),S)} | |
else { | |
E:sendMessageColor(vec(0,161,255),"[Kitchen Gun] ",vec(255,255,255),S) | |
#E:sendMessage("[Kitchen Gun] "+S) | |
} | |
} | |
timer("checkForChef",500) | |
} | |
elseif(clk("checkForChef")) { | |
if(!Handle:isValid()) {reset()} | |
if(Handle:isPlayerHolding()) { | |
findByClass("player") | |
Chef=findClosest(Handle:pos()) | |
runOnKeys(Chef,1) | |
if(shouldCollide(Chef)) {NoclipProps=0 S=" Props are NOT nocollided."} | |
else {NoclipProps=1 S=" Props are nocollided."} | |
tell(Chef,"Press R to fire the Kitchen Gun!"+S) | |
Handle:soundPlay(0,0,"ambient/music/piano2.wav") | |
holoCreate(1) | |
holoModel(1,"models/holograms/hq_sphere.mdl") | |
holoScale(1,vec(0.5)) | |
holoColor(1,vec(0,255,0)) | |
timer("checkIfChefGone",100) | |
} | |
else { | |
timer("checkForChef",100) | |
} | |
if(Handle:isFrozen()) {Handle:propFreeze(0)} | |
} | |
elseif(clk("checkIfChefGone")) { | |
if(!Handle:isPlayerHolding()) { | |
soundStop(0) | |
holoDelete(1) | |
runOnKeys(Chef,0) | |
timer("checkForChef",100) | |
} | |
else { | |
timer("checkIfChefGone",100) | |
local RD=rangerOffset(Handle:pos()+Handle:right()*-20,Handle:pos()+Handle:right()*-2500) | |
holoPos(1,RD:position()) | |
} | |
if(Handle:isFrozen()) {Handle:propFreeze(0)} | |
} | |
elseif(keyClk()) { | |
if(keyClkPressed()=="r") { | |
if(!R) { | |
R=1 | |
if(Bullets:count()>=5) {Bullets[1,entity]:propDelete() stoptimer("1") Bullets:remove(1)} | |
B=Bullets[Bullets:count()+1,entity]=propSpawn(Props[randint(1,Props:count()),string],Handle:pos()+Handle:right()*-20,Handle:angles(),0) | |
if(B:mass()<500) {B:setMass(500)} | |
if(NoclipProps) {noCollideAll(B,NoclipProps)} | |
B:applyForce( Handle:right()*-2500*B:mass() ) | |
timer(B:id():toString(),5000) | |
Handle:soundPlay(randint(1,50000),5,"ambient/alarms/klaxon1.wav") | |
} | |
else { | |
R=0 | |
} | |
} | |
} | |
else { | |
local ID=clkName():toNumber() | |
for(I=1,Bullets:count()) { | |
if(Bullets[I,entity]:id()==ID) { | |
entity(ID):propDelete() | |
Bullets:remove(I) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment