Advertisement
comniemeer

GK-Funktion

Aug 10th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. gk(id, store := "", showGK := false) {
  2.     result := URLDownloadToVar(baseURL . "api/newgk.php?gk=" . id)
  3.    
  4.     if (result == "ERROR_CONNECTION") {
  5.         SendClientMessage(PREFIX . "{FF0000}Fehler bei der Verbindung zum Server!")
  6.     } else if (result == "ERROR_BAD_LINK") {
  7.         SendClientMessage(PREFIX . "{FF0000}Fehlerhafte Parameterübergabe!")
  8.     } else if (result == "ERROR_ACCESS_DENIED") {
  9.         SendClientMessage(PREFIX . "{FF0000}Zugriff verweigert, das Passwort ist falsch!")
  10.     } else if (result == "ERROR_WRONG_FORMAT") {
  11.         SendClientMessage(PREFIX . "{FF0000}Fehlerhaftes Format!")
  12.     } else if (result == "ERROR_NOT_FOUND") {
  13.         SendClientMessage(PREFIX . "{FF0000}Der Komplex wurde nicht in der Datenbank gefunden!")
  14.     } else {
  15.         if (store == "") {
  16.             SendClientMessage(PREFIX . "Gebäudekomplex {FF0000}" . id . "{FFFFFF}:")
  17.         }
  18.        
  19.         try {
  20.             data := JSON.Load(result)
  21.         } catch {
  22.             SendClientMessage(PREFIX . "{FF0000}Es ist ein unbekannter Fehler aufgetreten!")
  23.             FormatTime, time, , dd.MM.yyyy HH:mm:ss
  24.             FileAppend, [%time%] Beim Laden des GK ist ein Fehler aufgetreten: %result%`n, log.txt
  25.             return
  26.         }
  27.        
  28.         for index, entry in data {
  29.             name := entry["name"]
  30.             location := ""
  31.            
  32.             if (entry["type"] == "public") {
  33.                 color := "{00FF00}"
  34.                 location := " (" . calculateZone(entry["x"], entry["y"], 0.0) . ", " . calculateCity(entry["x"], entry["y"], 0.0) . ")"
  35.             } else if (entry["type"] == "house") {
  36.                 color := "{00FFFF}"
  37.                
  38.                 if (name == "Nobody") {
  39.                     name := "Haus (frei)"
  40.                 } else if (name == "Auktion im CP") {
  41.                     name := "Haus (" . name . ")"
  42.                 } else {
  43.                     name := "Haus von " . name
  44.                 }
  45.                
  46.                 location := " (" . calculateZone(entry["x"], entry["y"], 0.0) . ", " . calculateCity(entry["x"], entry["y"], 0.0) . ")"
  47.             } else if (entry["type"] == "faction") {
  48.                 color := "{7F00FF}"
  49.                 location := " (" . calculateZone(entry["x"], entry["y"], 0.0) . ", " . calculateCity(entry["x"], entry["y"], 0.0) . ")"
  50.             } else if (entry["type"] == "vehicle") {
  51.                 color := "{FF00FF}"
  52.             }
  53.            
  54.             if (entry["x"] == -5000 || entry["y"] == -5000) {
  55.                 location := ""
  56.             }
  57.            
  58.             if (store != "") {
  59.                 if (store == "BS" && name == "Burger Shot") {
  60.                 } else if (store == "SM" && name == "24/7") {
  61.                 } else if (store == "CB" && name == "Clucking Bell") {
  62.                 } else if (store == "CS" && name == "Binco") {
  63.                 } else if (store == "PS" && name == "Well Stacked Pizza") {
  64.                 } else {
  65.                     continue
  66.                 }
  67.                
  68.                 SendClientMessage(PREFIX . SECCOL . "[GK " . id . "] " . color . "[ID: " . entry["type"] . "." . entry["id"] . "] " . name . location)
  69.                
  70.                 if (showGK) {
  71.                     Sleep, 50
  72.                    
  73.                     showGK(entry["type"] . "." . entry["id"], true)
  74.                 }
  75.             } else {
  76.                 SendClientMessage(PREFIX . SECCOL . "[GK] " . color . "[ID: " . entry["type"] . "." . entry["id"] . "] " . name . location)
  77.             }
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement