Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Guard_Subject
- @inputs [Ranger]:entity EGP:wirelink [User]:entity
- @outputs
- @persist [Gname,MSGTag,OwnerSteamID,Location]:string [CooldownR,CooldownA,GangAccess]:number [MSGTagColor]:vector [Blacklist,QueueTable]:table
- @trigger
- runOnChat(1)
- if(first() | dupefinished() | duped()) {
- OwnerSteamID = ""
- Location = ""
- MSGTag = "[SG] "
- MSGTagColor = vec(0,220,220)
- CooldownR = 0
- CooldownA = 0
- GangAccess = 1
- Gname = "msg"
- Gscope = 2
- dsJoinGroup(Gname)
- dsSetScope(Gscope)
- function void addQueue(PlayerSteamID:string, Text:string) {
- QueueTable:insertArray(1,array(PlayerSteamID,Text))
- }
- function void playQueue() {
- if(QueueTable:exists(1)){
- concmd("say /pm "+QueueTable[1,array][1,string]+" "+QueueTable[1,array][2,string])
- QueueTable:remove(1)
- }
- timer("PlayQueue",3000)
- }
- function void oMSG(Text:string, Color:vector) {
- printColor(MSGTagColor,MSGTag,Color,Text)
- }
- function string trimName(Text:string) {
- if(Text:length()>17){return Text:sub(1,17)}
- else{ return Text}
- }
- function void createID() {
- if(findPlayerBySteamID(OwnerSteamID):name() == "") {
- oMSG("Skriv !sted for at tilf"+oe()+"jede den nuv"+ae()+"rende lokalisation for vagtposten.",vec(255,255,255))
- oMSG("Skriv herefter !navn for at tilf"+oe()+"je indehaveren af vagtposten.",vec(255,255,255))
- }else{
- dsSend("add",Gname,"Tilf"+oe()+"jede ny klient ["+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> "+Location+"]")
- addQueue(OwnerSteamID,"!tilf"+oe()+"j / !fjern navn ("+ae()+"ndrer baseadgang) | !gangs (aktiver/deaktiver gangadgang)")
- addQueue(OwnerSteamID,"[SG] Velkommen til SmartGuard. Du har nu f"+oe()+"lgende kommandoer:")
- timer("pm",200)
- }
- }
- function number egpClick(Index, Cursor:vector2){
- EPos = EGP:egpPos(Index)
- ESize = EGP:egpSize(Index)
- if(inrange(Cursor, (EPos - ESize/2), (EPos + ESize/2))){
- return 1
- }
- return 0
- }
- function entity string:retrievePlayer(){
- if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
- local Player = findPlayerBySteamID(This)
- if (Player:isValid())
- {
- return Player
- }
- }
- else
- {
- return findPlayerByName(This)
- }
- return noentity()
- }
- function number string:isBlacklisted(){
- local Player = This:retrievePlayer()
- return Blacklist[Player:isValid() ? Player:steamID() : This, number]
- }
- function number string:blacklist(){
- local Player = This:retrievePlayer()
- if (Player:isValid()){
- Blacklist[Player:steamID(), number] = 1
- }
- else
- {
- if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
- Blacklist[This, number] = 1
- }
- }
- return This:isBlacklisted()
- }
- function number string:whitelist(){
- local Player = This:retrievePlayer()
- if (Player:isValid()){
- Blacklist:remove(Player:steamID())
- }
- else
- {
- if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
- Blacklist:remove(This)
- }
- }
- return !This:isBlacklisted()
- }
- function void wirelink:drawScreen1() {
- This:egpClear()
- This:egpBox( 1,vec2(0,0),vec2(1024,1024) )
- This:egpMaterial(1,"console/background06")
- Jump = 100
- ##
- This:egpBox( 12,vec2(255,45),vec2(512,90) ) This:egpColor(12,vec4(0,0,0,150))
- This:egpText(13,"SMART GUARD",vec2(256,10)) This:egpAlign(13,1) This:egpSize(13,70)
- ##
- This:egpBox( 2,vec2(132,70+Jump),vec2(233.5,100) ) This:egpColor(2,vec4(0,0,0,100))
- This:egpBox( 3,vec2(379,70+Jump),vec2(233.5,100) ) This:egpColor(3,vec4(0,0,0,100))
- This:egpBox( 4,vec2(132,30+Jump),vec2(233.5,30) ) This:egpColor(4,vec4(255,255,255,200))
- This:egpBox( 5,vec2(379,30+Jump),vec2(233.5,30) ) This:egpColor(5,vec4(255,255,255,200))
- ##
- This:egpBox( 6,vec2(132,195+Jump),vec2(233.5,100) ) This:egpColor(6,vec4(0,0,0,100))
- This:egpBox( 7,vec2(379,195+Jump),vec2(233.5,100) ) This:egpColor(7,vec4(0,0,0,100))
- This:egpBox( 8,vec2(132,155+Jump),vec2(233.5,30) ) This:egpColor(8,vec4(255,255,255,200))
- This:egpBox( 9,vec2(379,155+Jump),vec2(233.5,30) ) This:egpColor(9,vec4(255,255,255,200))
- ##
- This:egpBox( 11,vec2(255,327+Jump),vec2(450,120) ) This:egpColor(11,vec4(200,0,0,150))
- timer("draw2",1000)
- }
- function void wirelink:drawScreen2() {
- This:egpText(21,"Vagtmand", vec2(131,116+Jump)) This:egpColor(21,vec4(0,0,0,250)) This:egpSize(21,25) This:egpAlign(21,1)
- This:egpText(27,owner():name(), vec2(130,167+Jump)) This:egpColor(27,vec4(255,255,255,250)) This:egpSize(27,30) This:egpAlign(27,1)
- This:egpText(22,"Husejer", vec2(379,116+Jump)) This:egpColor(22,vec4(0,0,0,250)) This:egpSize(22,25) This:egpAlign(22,1)
- This:egpText(28,"-||-", vec2(381,167+Jump)) This:egpColor(28,vec4(255,255,255,250)) This:egpSize(28,30) This:egpAlign(28,1)
- This:egpText(29,"Gang-adgang", vec2(131,241+Jump)) This:egpColor(29,vec4(0,0,0,250)) This:egpSize(29,25) This:egpAlign(29,1)
- This:egpText(30,"Aktiveret", vec2(130,285+Jump)) This:egpColor(30,vec4(255,255,255,250)) This:egpSize(30,40) This:egpAlign(30,1)
- This:egpText(31,"Lokalisation", vec2(379,241+Jump)) This:egpColor(31,vec4(0,0,0,250)) This:egpSize(31,25) This:egpAlign(31,1)
- This:egpText(32,"-||-",vec2(381,290+Jump)) This:egpColor(32,vec4(255,255,255,250)) This:egpSize(32,30) This:egpAlign(32,1)
- This:egpText(33,"N"+oeL()+"DOPKALD",vec2(256,388)) This:egpAlign(33,1) This:egpSize(33,68)
- }
- EGP:drawScreen1()
- createID()
- }
- if(dupefinished()) {
- }
- Cursor = EGP:egpCursor(User)
- if(~User & User:keyUse() & ops()<100){
- if(User:name():isBlacklisted()) {
- if(egpClick(11,Cursor) & CooldownA == 0) {
- moneyRequest(User,500,"N"+oe()+"dhj"+ae()+"lp.")
- }
- }
- }
- if(!Ranger:name():isBlacklisted() & Ranger:isPlayer() & OwnerSteamID != "" & CooldownR == 0 ) {
- if(GangAccess == 1 & Ranger:getGangID() == findPlayerBySteamID(OwnerSteamID):getGangID()){
- }else{
- dsSend("ranger",Gname,"Uautoriseret person er registreret. ["+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> " + Location +"]")
- CooldownR = 1
- timer("cooldownR",10000)
- }
- }
- if(chatClk(owner())){
- A = owner():lastSaid():lower():explode(" ")
- if(A[1,string]=="!navn") {
- if(Location != "") {
- if(OwnerSteamID == "") {
- if(owner():lastSaid():replace("!navn ",""):length()<16 & owner():lastSaid():replace("!navn ",""):length()>=2) {
- if(findPlayerByName(A[2,string]):steamID()!="") {
- OwnerSteamID = findPlayerByName(A[2,string]):steamID()
- createID()
- findPlayerBySteamID(OwnerSteamID):name():blacklist()
- EGP:egpSetText(28,trimName(findPlayerBySteamID(OwnerSteamID):name()))
- }else{
- oMSG("Ugyldig spiller.",vec(200,0,0))
- }
- }else{
- oMSG("Ugyldigt navn. V"+ae()+"lg mellem 2-16 tegn.",vec(255,255,255))
- }
- }
- }else {
- oMSG("Tilf"+oe()+"j venligst f"+oe()+"rst en lokalisation for vagtposten ved at skrive !sted lokalisation.",vec(200,0,0))
- }
- }
- elseif(A[1,string]=="!sted") {
- if(Location == "") {
- if(owner():lastSaid():replace("!sted ",""):length()<16 & owner():lastSaid():replace("!sted ",""):length()>=2) {
- Location = trimName(owner():lastSaid():replace("!sted ",""))
- EGP:egpSetText(32,Location)
- }else{
- oMSG("Ugyldig lokalisation. V"+ae()+"lg mellem 2-16 tegn.",vec(255,255,255))
- }
- }
- }
- }
- if(chatClk(findPlayerBySteamID(OwnerSteamID))) {
- B = findPlayerBySteamID(OwnerSteamID):lastSaid():lower():explode(" ")
- if(B[1,string]=="!tilf"+oe()+"j") {
- hideChat(1)
- local Success = findPlayerByName(B[2,string]):name():blacklist()
- if (Success & B[2,string]!= ""){
- addQueue(OwnerSteamID,"[SG] Tilf"+oe()+"jede " +trimName(findPlayerByName(B[2,string]):name())+" til din base.")
- }
- else
- {
- oMSG("Der skete en fejl.",vec(200,0,0))
- }
- }elseif(B[1,string]=="!fjern") {
- hideChat(1)
- local Success = findPlayerByName(B[2,string]):name():whitelist()
- if (Success & B[2,string] != ""){
- addQueue(OwnerSteamID,"[SG] Fjernede "+findPlayerByName(B[2,string]):name()+ " fra listen over tilladte personer.")
- }
- else
- {
- oMSG("Der skete en fejl.",vec(200,0,0))
- }
- }elseif(B[1,string]=="!check") {
- hideChat(1)
- print(B[2,string]:isBlacklisted() ? "Spilleren: " + B[2,string] + " er blacklisted" : "Spilleren: " + B[2,string] + " er ikke blacklisted")
- }elseif(B[1,string]=="!gangs") {
- if(GangAccess == 0) {
- GangAccess = 1
- EGP:egpSetText(30,"Aktiveret")
- addQueue(OwnerSteamID,"[SG] Aktiverede gangadgang.")
- }else{
- GangAccess = 0
- EGP:egpSetText(30,"Deaktiveret")
- addQueue(OwnerSteamID,"[SG] Deaktiverede gangadgang.")
- }
- }
- }
- if(clk("cooldownR")) {
- CooldownR = 0
- }elseif(clk("draw2")) {
- EGP:drawScreen2()
- playQueue()
- }elseif(clk("Reset")) {
- CooldownA = 0
- EGP:egpSetText(33,"N"+oeL()+"DOPKALD")
- }elseif(clk("PlayQueue")){playQueue()}
- if(moneyClk("N"+oe()+"dhj"+ae()+"lp.")) {
- EGP:egpSetText(33,"AFVENT HJ"+aeL()+"LP")
- CooldownA = 1
- timer("Reset",2000)
- dsSend("emergency",Gname,""+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> " + Location +"")
- oMSG(trimName(findPlayerBySteamID(OwnerSteamID):name()) + " har kaldt efter hj"+ae()+"lp -> "+ Location,vec(255,0,0))
- }
Add Comment
Please, Sign In to add comment