Thomads

Stavox - Smart Guard [CLIENT]

Dec 26th, 2018
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.80 KB | None | 0 0
  1. @name Guard_Subject
  2. @inputs [Ranger]:entity EGP:wirelink [User]:entity
  3. @outputs
  4. @persist [Gname,MSGTag,OwnerSteamID,Location]:string [CooldownR,CooldownA,GangAccess]:number [MSGTagColor]:vector [Blacklist,QueueTable]:table
  5. @trigger
  6.  
  7. runOnChat(1)
  8.    
  9. if(first() | dupefinished() | duped()) {
  10.    
  11.    
  12.     OwnerSteamID = ""
  13.     Location = ""
  14.     MSGTag = "[SG] "
  15.     MSGTagColor = vec(0,220,220)
  16.     CooldownR = 0
  17.     CooldownA = 0
  18.     GangAccess = 1
  19.     Gname = "msg"
  20.     Gscope = 2
  21.    
  22.     dsJoinGroup(Gname)
  23.     dsSetScope(Gscope)
  24.    
  25.     function void addQueue(PlayerSteamID:string, Text:string) {
  26.         QueueTable:insertArray(1,array(PlayerSteamID,Text))
  27.     }
  28.        
  29.     function void playQueue() {
  30.         if(QueueTable:exists(1)){
  31.             concmd("say /pm "+QueueTable[1,array][1,string]+" "+QueueTable[1,array][2,string])
  32.             QueueTable:remove(1)      
  33.         }
  34.         timer("PlayQueue",3000)
  35.     }
  36.     function void oMSG(Text:string, Color:vector) {
  37.         printColor(MSGTagColor,MSGTag,Color,Text)
  38.     }
  39.    
  40.     function string trimName(Text:string) {
  41.         if(Text:length()>17){return Text:sub(1,17)}
  42.         else{ return Text}
  43.     }
  44.     function void createID() {
  45.         if(findPlayerBySteamID(OwnerSteamID):name() == "") {
  46.             oMSG("Skriv !sted for at tilf"+oe()+"jede den nuv"+ae()+"rende lokalisation for vagtposten.",vec(255,255,255))
  47.             oMSG("Skriv herefter !navn for at tilf"+oe()+"je indehaveren af vagtposten.",vec(255,255,255))      
  48.         }else{
  49.             dsSend("add",Gname,"Tilf"+oe()+"jede ny klient ["+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> "+Location+"]")
  50.             addQueue(OwnerSteamID,"!tilf"+oe()+"j / !fjern navn ("+ae()+"ndrer baseadgang) | !gangs (aktiver/deaktiver gangadgang)")
  51.             addQueue(OwnerSteamID,"[SG] Velkommen til SmartGuard. Du har nu f"+oe()+"lgende kommandoer:")
  52.             timer("pm",200)
  53.         }
  54.     }
  55.    
  56.     function number egpClick(Index, Cursor:vector2){
  57.         EPos = EGP:egpPos(Index)
  58.         ESize = EGP:egpSize(Index)
  59.         if(inrange(Cursor, (EPos - ESize/2), (EPos + ESize/2))){
  60.             return 1
  61.         }
  62.         return 0
  63.     }    
  64.  
  65.     function entity string:retrievePlayer(){
  66.         if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
  67.                 local Player = findPlayerBySteamID(This)
  68.                 if (Player:isValid())
  69.                 {
  70.                     return Player
  71.                 }
  72.         }
  73.         else
  74.         {
  75.             return findPlayerByName(This)
  76.         }
  77.         return noentity()
  78.     }
  79.    
  80.    
  81.     function number string:isBlacklisted(){
  82.         local Player = This:retrievePlayer()
  83.         return Blacklist[Player:isValid() ? Player:steamID() : This, number]
  84.     }
  85.    
  86.  
  87.     function number string:blacklist(){
  88.         local Player = This:retrievePlayer()
  89.         if (Player:isValid()){
  90.             Blacklist[Player:steamID(), number] = 1
  91.         }
  92.         else
  93.         {
  94.             if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
  95.                 Blacklist[This, number] = 1
  96.             }
  97.         }
  98.        
  99.         return This:isBlacklisted()
  100.     }
  101.    
  102.     function number string:whitelist(){
  103.         local Player = This:retrievePlayer()
  104.         if (Player:isValid()){
  105.             Blacklist:remove(Player:steamID())
  106.         }
  107.         else
  108.         {
  109.             if (This:findRE("^STEAM_[0-5]:[0-1]:%d+$")){
  110.                 Blacklist:remove(This)
  111.             }
  112.         }
  113.         return !This:isBlacklisted()
  114.     }
  115.    
  116.     function void wirelink:drawScreen1() {
  117.         This:egpClear()
  118.         This:egpBox( 1,vec2(0,0),vec2(1024,1024) )
  119.         This:egpMaterial(1,"console/background06")
  120.         Jump = 100
  121.         ##
  122.         This:egpBox( 12,vec2(255,45),vec2(512,90) ) This:egpColor(12,vec4(0,0,0,150))
  123.         This:egpText(13,"SMART GUARD",vec2(256,10)) This:egpAlign(13,1) This:egpSize(13,70)
  124.        
  125.         ##
  126.         This:egpBox( 2,vec2(132,70+Jump),vec2(233.5,100) ) This:egpColor(2,vec4(0,0,0,100))
  127.         This:egpBox( 3,vec2(379,70+Jump),vec2(233.5,100) ) This:egpColor(3,vec4(0,0,0,100))
  128.        
  129.         This:egpBox( 4,vec2(132,30+Jump),vec2(233.5,30) ) This:egpColor(4,vec4(255,255,255,200))
  130.         This:egpBox( 5,vec2(379,30+Jump),vec2(233.5,30) ) This:egpColor(5,vec4(255,255,255,200))
  131.        
  132.         ##
  133.         This:egpBox( 6,vec2(132,195+Jump),vec2(233.5,100) ) This:egpColor(6,vec4(0,0,0,100))
  134.         This:egpBox( 7,vec2(379,195+Jump),vec2(233.5,100) ) This:egpColor(7,vec4(0,0,0,100))
  135.        
  136.         This:egpBox( 8,vec2(132,155+Jump),vec2(233.5,30) ) This:egpColor(8,vec4(255,255,255,200))
  137.         This:egpBox( 9,vec2(379,155+Jump),vec2(233.5,30) ) This:egpColor(9,vec4(255,255,255,200))
  138.  
  139.         ##
  140.         This:egpBox( 11,vec2(255,327+Jump),vec2(450,120) ) This:egpColor(11,vec4(200,0,0,150))
  141.        
  142.         timer("draw2",1000)
  143.     }
  144.    
  145.     function void wirelink:drawScreen2() {
  146.         This:egpText(21,"Vagtmand", vec2(131,116+Jump)) This:egpColor(21,vec4(0,0,0,250)) This:egpSize(21,25)  This:egpAlign(21,1)
  147.         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)
  148.        
  149.         This:egpText(22,"Husejer", vec2(379,116+Jump)) This:egpColor(22,vec4(0,0,0,250)) This:egpSize(22,25)  This:egpAlign(22,1)
  150.         This:egpText(28,"-||-", vec2(381,167+Jump)) This:egpColor(28,vec4(255,255,255,250)) This:egpSize(28,30) This:egpAlign(28,1)
  151.        
  152.         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)
  153.         This:egpText(30,"Aktiveret", vec2(130,285+Jump)) This:egpColor(30,vec4(255,255,255,250)) This:egpSize(30,40) This:egpAlign(30,1)
  154.        
  155.         This:egpText(31,"Lokalisation", vec2(379,241+Jump)) This:egpColor(31,vec4(0,0,0,250)) This:egpSize(31,25)  This:egpAlign(31,1)
  156.         This:egpText(32,"-||-",vec2(381,290+Jump)) This:egpColor(32,vec4(255,255,255,250)) This:egpSize(32,30) This:egpAlign(32,1)
  157.        
  158.        
  159.         This:egpText(33,"N"+oeL()+"DOPKALD",vec2(256,388)) This:egpAlign(33,1) This:egpSize(33,68)
  160.     }
  161.    
  162.     EGP:drawScreen1()
  163.     createID()  
  164. }
  165. if(dupefinished()) {
  166.    
  167.  
  168. }
  169. Cursor = EGP:egpCursor(User)
  170. if(~User & User:keyUse() & ops()<100){
  171.     if(User:name():isBlacklisted()) {
  172.         if(egpClick(11,Cursor) &  CooldownA == 0) {
  173.             moneyRequest(User,500,"N"+oe()+"dhj"+ae()+"lp.")
  174.         }
  175.     }
  176. }
  177.  
  178.  
  179. if(!Ranger:name():isBlacklisted() & Ranger:isPlayer() & OwnerSteamID != "" & CooldownR == 0 ) {
  180.     if(GangAccess == 1 & Ranger:getGangID() == findPlayerBySteamID(OwnerSteamID):getGangID()){
  181.     }else{
  182.         dsSend("ranger",Gname,"Uautoriseret person er registreret. ["+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> " + Location +"]")
  183.         CooldownR = 1
  184.         timer("cooldownR",10000)
  185.     }
  186. }
  187.    
  188.     if(chatClk(owner())){
  189.         A = owner():lastSaid():lower():explode(" ")
  190.         if(A[1,string]=="!navn") {
  191.             if(Location != "") {
  192.                 if(OwnerSteamID == "") {
  193.                     if(owner():lastSaid():replace("!navn ",""):length()<16 & owner():lastSaid():replace("!navn ",""):length()>=2) {
  194.                         if(findPlayerByName(A[2,string]):steamID()!="") {
  195.                             OwnerSteamID = findPlayerByName(A[2,string]):steamID()
  196.                             createID()
  197.                             findPlayerBySteamID(OwnerSteamID):name():blacklist()
  198.                             EGP:egpSetText(28,trimName(findPlayerBySteamID(OwnerSteamID):name()))
  199.                         }else{
  200.                             oMSG("Ugyldig spiller.",vec(200,0,0))
  201.                         }
  202.                     }else{
  203.                     oMSG("Ugyldigt navn. V"+ae()+"lg mellem 2-16 tegn.",vec(255,255,255))
  204.                     }
  205.                 }
  206.             }else {
  207.                 oMSG("Tilf"+oe()+"j venligst f"+oe()+"rst en lokalisation for vagtposten ved at skrive !sted lokalisation.",vec(200,0,0))
  208.             }
  209.         }
  210.         elseif(A[1,string]=="!sted") {
  211.             if(Location == "") {
  212.                 if(owner():lastSaid():replace("!sted ",""):length()<16 & owner():lastSaid():replace("!sted ",""):length()>=2) {
  213.                     Location = trimName(owner():lastSaid():replace("!sted ",""))
  214.                     EGP:egpSetText(32,Location)
  215.                 }else{
  216.                     oMSG("Ugyldig lokalisation. V"+ae()+"lg mellem 2-16 tegn.",vec(255,255,255))
  217.                 }
  218.             }
  219.         }
  220.     }
  221.    
  222.     if(chatClk(findPlayerBySteamID(OwnerSteamID))) {
  223.         B = findPlayerBySteamID(OwnerSteamID):lastSaid():lower():explode(" ")
  224.        
  225.         if(B[1,string]=="!tilf"+oe()+"j") {
  226.             hideChat(1)
  227.             local Success = findPlayerByName(B[2,string]):name():blacklist()
  228.             if (Success & B[2,string]!= ""){
  229.                 addQueue(OwnerSteamID,"[SG] Tilf"+oe()+"jede " +trimName(findPlayerByName(B[2,string]):name())+" til din base.")
  230.             }
  231.             else
  232.             {
  233.                 oMSG("Der skete en fejl.",vec(200,0,0))
  234.             }
  235.            
  236.         }elseif(B[1,string]=="!fjern") {
  237.             hideChat(1)
  238.             local Success = findPlayerByName(B[2,string]):name():whitelist()
  239.             if (Success & B[2,string] != ""){
  240.                 addQueue(OwnerSteamID,"[SG] Fjernede "+findPlayerByName(B[2,string]):name()+ " fra listen over tilladte personer.")
  241.             }
  242.             else
  243.             {
  244.                 oMSG("Der skete en fejl.",vec(200,0,0))
  245.             }    
  246.            
  247.         }elseif(B[1,string]=="!check") {
  248.             hideChat(1)
  249.             print(B[2,string]:isBlacklisted() ? "Spilleren: " + B[2,string] + " er blacklisted" : "Spilleren: " + B[2,string] + " er ikke blacklisted")
  250.            
  251.         }elseif(B[1,string]=="!gangs") {
  252.             if(GangAccess == 0) {
  253.                 GangAccess = 1
  254.                 EGP:egpSetText(30,"Aktiveret")
  255.                 addQueue(OwnerSteamID,"[SG] Aktiverede gangadgang.")
  256.             }else{
  257.                 GangAccess = 0
  258.                 EGP:egpSetText(30,"Deaktiveret")
  259.                 addQueue(OwnerSteamID,"[SG] Deaktiverede gangadgang.")
  260.             }
  261.         }
  262.     }  
  263.  
  264. if(clk("cooldownR")) {
  265.     CooldownR = 0
  266. }elseif(clk("draw2")) {
  267.     EGP:drawScreen2()
  268.     playQueue()
  269. }elseif(clk("Reset")) {
  270.     CooldownA = 0
  271.     EGP:egpSetText(33,"N"+oeL()+"DOPKALD")
  272. }elseif(clk("PlayQueue")){playQueue()}
  273.  
  274. if(moneyClk("N"+oe()+"dhj"+ae()+"lp.")) {
  275.     EGP:egpSetText(33,"AFVENT HJ"+aeL()+"LP")
  276.     CooldownA = 1
  277.     timer("Reset",2000)
  278.     dsSend("emergency",Gname,""+trimName(findPlayerBySteamID(OwnerSteamID):name())+" -> " + Location +"")
  279.     oMSG(trimName(findPlayerBySteamID(OwnerSteamID):name()) + " har kaldt efter hj"+ae()+"lp -> "+ Location,vec(255,0,0))
  280. }
Add Comment
Please, Sign In to add comment