Skip to content

Instantly share code, notes, and snippets.

@codeliger
Last active August 29, 2015 14:12
Show Gist options
  • Save codeliger/3014334e5cf4bd527427 to your computer and use it in GitHub Desktop.
Save codeliger/3014334e5cf4bd527427 to your computer and use it in GitHub Desktop.
@name Le Radio
@persist Players:array NumberKeys:array Keys:table PlayersCounter PlayerData:table
@model models\props/cs_office/radio.mdl
interval(60)
#TODO: Add Sounds, and limit range to 250m
if( first() ){
Players = players()
PlayersCounter = 0
NumberKeys = array("PAD_0","PAD_1","PAD_2","PAD_3","PAD_4","PAD_5","PAD_6","PAD_7","PAD_8","PAD_9")
CancelKeys = array("PAD_DECIMAL","PAD_DIVIDE","PAD_MINUS","PAD_MULTIPLY","PAD_PLUS")
}
function output(Ply:entity, K:string){
print( Ply:name() + ": " + K)
}
if(perf()){
foreach(Index, Player:entity = Players){
local PlayerKeys = PlayerData[Player:steamID(), table]
if(Player:aimEntity():model() == "models/props_lab/keypad.mdl" && entity():pos():distance(Player:aimEntity():pos()) < 150 ){
for(I = 0, NumberKeys:count()){
if( Player:keyPressed(NumberKeys[I,string]) ){
PlayerKeys[NumberKeys[I,string],number] = 1
}
elseif(!Player:keyPressed(NumberKeys[I,string]) && PlayerKeys[NumberKeys[I,string],number]){
PlayerKeys[NumberKeys[I,string],number] = 0
output(Player, NumberKeys[I,string])
entity():soundPlay("static",0,"Geiger.BeepLow")
}
}
if(perf()){
for(I = 0, CancelKeys:count()){
if( Player:keyPressed(CancelKeys[I,string]) ){
PlayerKeys[CancelKeys[I,string],number] = 1
}
elseif(!Player:keyPressed(CancelKeys[I,string]) && PlayerKeys[CancelKeys[I,string],number]){
PlayerKeys[CancelKeys[I,string],number] = 0
output(Player, CancelKeys[I,string])
}
}
}
if( Player:keyPressed("PAD_ENTER") ){
PlayerKeys["PAD_ENTER",number] = 1
}elseif(!Player:keyPressed("PAD_ENTER") && PlayerKeys["PAD_ENTER",number]){
PlayerKeys["PAD_ENTER",number] = 0
output(Player, "PAD_ENTER")
entity():soundPlay("static",0,"Geiger.BeepHigh")
}
} #end ifmodel
PlayerData[Player:steamID(), table] = PlayerKeys
} #endforeach
if(PlayersCounter == 600 && perf()){
Players = players()
print(2,"Player list has been refreshed.")
PlayersCounter = 0
}else{
PlayersCounter++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment