Code:
@name Laser Tag! Press E!
@outputs D1 D2 Text:string
@persist [Players Ingame Inuse UOn Health HoloN Timeout TextA]:array
@persist Max OMax N Slay T Say PSay TOut [CustomCommand CustomMessage]:string
@model models/dav0r/buttons/button.mdl
#INSTRUCTIONS#
#Simply place this at the entrance to your arena, and press E on it.
#You can see your health better if you use a toolgun or pistol.
#OPTIONAL: Create two no-collide doors with the wire nocollide tool for best effect.
#(D1 goes to the outer door, D2 goes to the inner door.)
#OPTIONAL: Wire a text screen's "String" input to "Text" to display a welcoming message to players.
if(first() | duped()) {
#################-----OPTIONS-----###################
#Max Players - Cannot exceed 12
Max = 12
#Time-out Time: (seconds)
TOut = 3
#Choose what to do when someone runs out of health
#(Pick only one)
Slay = 0 #ULX
PSay = 0 #ULX
Say = 1
#Custom command will be CustomCommand+'Loser's name'+CustomMessage
CustomCommand = "" #Enter a console command here.
CustomMessage = "" #Enter a message here.
#####################################################
timer("players",1000)
timer("text",1000)
runOnTick(1)
N=D1=T=1
if(Max>12) {Max=12}
if(Max>7) {M=7, OMax=1} else {M=Max}
for(I=1,M) {
holoCreate(I)
holoAlpha(I,0)
holoAng(I,ang(0,0,0))
}
for(I=Max+1,Max+M) {
holoCreate(I)
holoAlpha(I,0)
holoModel(I,"hqcylinder")
holoScaleUnits(I,vec(7,7,14))
holoAng(I,ang(0,90,90))
holoParent(I,I-Max)
}
for(I=Max*2+1,Max*2+M) {
holoCreate(I)
holoAlpha(I,0)
holoModel(I,"hqcylinder")
holoScaleUnits(I,vec(0.4,0.4,300))
holoColor(I,vec(255,0,0))
holoPos(I,holoEntity(I-Max):pos()+holoEntity(I-Max):up()*150)
holoAng(I,ang(0,90,90))
holoParent(I,I-Max*2)
}
for(I=Max*3+1,Max*3+M) {
holoCreate(I)
holoAlpha(I,0)
holoColor(I,vec(255,0,0))
holoScaleUnits(I,vec(0.5,0.5,10))
holoAng(I,ang(0,90,90))
holoPos(I,holoEntity(I-Max*2):pos()-holoEntity(I-Max*2):right()*3.1)
holoParent(I,I-Max*3)
}
T=1
TextA[T,string] = "Welcome to Laser Tag! Made by AnDrEw.",T++
TextA[T,string] = "Press the Button to join in the fun!",T++
TextA[T,string] = "Press E to fire your laser gun.",T++
TextA[T,string] = "You have 10 health, indicated by the red bar.",T++
hint("Laser Tag made by AnDrEw :D",7)
TextA[T,string] = "If you are hit, you get 5 seconds of safety.",T++
TextA[T,string] = "When you lose, find some way to exit or suicide.",T++
TextA[T,string] = "Enter the entrance one at a time.",T++
TextA[T,string] = "I recommend toolgun or pistol for best results"
T=1
}
if(OMax & holoCanCreate()) {
for(I=8,Max) {
holoCreate(I)
holoAlpha(I,0)
holoAng(I,ang(0,0,0))
}
for(I=Max+8,Max*2) {
holoCreate(I)
holoAlpha(I,0)
holoModel(I,"hqcylinder")
holoScaleUnits(I,vec(7,7,14))
holoAng(I,ang(0,0,0))
holoParent(I,I-Max)
}
for(I=Max*2+8,Max*3) {
holoCreate(I)
holoAlpha(I,0)
holoModel(I,"hqcylinder")
holoScaleUnits(I,vec(0.4,0.4,300))
holoColor(I,vec(255,0,0))
holoPos(I,holoEntity(I-Max):pos()+holoEntity(I-Max):up()*150)
holoAng(I,ang(0,0,0))
holoParent(I,I-Max*2)
}
for(I=Max*3+8,Max*4) {
holoCreate(I)
holoAlpha(I,0)
holoColor(I,vec(255,0,0))
holoScaleUnits(I,vec(0.5,0.5,10))
holoAng(I,ang(0,90,90))
holoPos(I,holoEntity(I-Max*2):pos()-holoEntity(I-Max*2):right()*3.1)
holoParent(I,I-Max*3)
}
}
for(I=1,Players:count()) {
Player = Players[I,entity]
if(Player:keyUse() & Player:aimEntity()==entity() & N<Max & !Ingame[I,number]) {
N++
Ingame[I,number]=1
UOn[I,number]=1
Health[I,number]=10
D1=0
D2=1
stoptimer("close")
timer("close",2000)
for(J=1,Max) {
if(!Inuse[J,number]) {
Inuse[J,number]=1
HoloN[I,number]=J
break
}
}
holoScaleUnits(J+Max*3,vec(0.5,0.5,Health[I,number]))
holoAng(J,Player:attachmentAng("anim_attachment_RH"))
holoPos(J,Player:attachmentPos("anim_attachment_RH"))
holoColor(J+Max,vec(0,255,0))
holoAlpha(J+Max,255)
holoAlpha(J+Max*3,255)
}
if(Ingame[I,number]) {
J = HoloN[I,number]
Eye=(Player:aimPos()-holoEntity(J):pos())
holoAng(J,Eye:toAngle())
holoPos(J,Player:attachmentPos("anim_attachment_RH"))
if(Player:keyUse() & !UOn[I,number] & !Timeout[I,number]) {
if(Player:aimEntity()==entity()) {
D1=0
D2=1
stoptimer("close")
timer("close",2000)
}
UOn[I,number]=1
holoAlpha(J+Max*2,255)
holoEntity(J+Max):soundPlay(J+Max,0,"buttons/blip1.wav")
soundPitch(J+Max,200)
rangerFilter(Player)
R=rangerOffset(1000,holoEntity(J+Max):pos(),holoEntity(J+Max):up())
if(R:hit()) {
for(K=1,Players:count()) {
L = HoloN[K,number]
if(R:entity()==Players[K,entity] & Ingame[K,number] & !Timeout[K,number]) {
Health[K,number] = Health[K,number]-1
if(Health[K,number]==0) {
Ingame[K,number]=0
HoloN[K,number]=0
Inuse[L,number]=0
N--
if(Slay) {concmd("ulx slay "+Players[K,entity]:name())}
elseif(PSay) {concmd("ulx psay "+Players[K,entity]:name()+" You have run out of health. Please either exit or suicide.")}
elseif(Say) {concmd("say "+Players[K,entity]:name()+", you have run out of health. Please either exit or suicide.")}
elseif(CustomCommand) {concmd(CustomCommand+Players[K,entity]:name()+CustomMessage)}
holoAlpha(L+Max,0)
holoAlpha(L+Max*2,0)
holoAlpha(L+Max*3,0)
} else {
holoScaleUnits(L+Max*3,vec(0.5,0.5,Health[K,number]))
holoColor(L+Max,vec(0,0,0))
Timeout[K,number]=1
soundStop(L)
holoEntity(L):soundPlay(L,0,"items/suitchargeno1.wav")
timer("timein"+K,TOut*1000)
}
break
}
}
holoScaleUnits(J+Max*2,vec(0.4,0.4,min(R:distance(),500)))
holoPos(J+Max*2,holoEntity(J+Max):pos()+holoEntity(J+Max):up()*min(R:distance()/2,250))
} else {
holoScaleUnits(HoloN[I,number]+Max*2,vec(0.4,0.4,500))
holoPos(J+Max*2,holoEntity(J+Max):pos()+holoEntity(J+Max):up()*250)
}
timer("off"+I,100)
} elseif (!Player:keyUse() & UOn[I,number]) {
UOn[I,number]=0
soundStop(J+Max)
}
if(!Player:isAlive()) {
Ingame[I,number]=0
HoloN[I,number]=0
Inuse[J,number]=0
N--
holoAlpha(J+Max,0)
holoAlpha(J+Max*2,0)
holoAlpha(J+Max*3,0)
}
}
if(clk("off"+I)) {holoAlpha(HoloN[I,number]+Max*2,0)}
if(clk("timein"+I)) {
holoColor(HoloN[I,number]+Max,vec(0,255,0))
Timeout[I,number]=0
soundStop(HoloN[I,number])
holoEntity(HoloN[I,number]):soundPlay(HoloN[I,number],0,"items/suitchargeok1.wav")
}
}
if(clk("text")) {
if(N>=Max) {
Text = "Max Players Reached, please wait!"
} else {
Text = TextA[T,string]
T++
if(T>TextA:count()) {T=1}
}
timer("text",2000)
}
if(clk("close")) {
D1=1
D2=0
}
if(clk("players")) {
timer("players",30000)
findByClass("player")
Players = findToArray()
}
Bookmarks