• Print

Author Topic: chat.addtext closes Dframe with chat  (Read 5094 times)

0 Members and 1 Guest are viewing this topic.

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
chat.addtext closes Dframe with chat
« on: April 11, 2015, 04:00:08 pm »
Hello guys.
What I have:
my script that output in chat: Player joined from "coutry"
Code: Lua
  1. if SERVER then
  2.         AddCSLuaFile()
  3.         util.AddNetworkString("chat_AddText")
  4.         chat = {}
  5.         function chat.AddText(...)
  6.                 net.Start("chat_AddText")
  7.                         net.WriteTable({...})
  8.                 net.Broadcast()
  9.         end
  10.         function get_geoip(ply)
  11.         ip = ply:IPAddress():match( "%d+%.%d+%.%d+%.%d+" ) or ""
  12.     query_string = "http://www.telize.com/geoip/" .. ip
  13.         http.Fetch( query_string,
  14.         function( body, len, headers, code )
  15.                 TheReturnedHTML = body
  16.                 TheReturnedCode = code
  17.                 if TheReturnedCode == 200 then
  18.                 country = string.match(TheReturnedHTML,"\"country\":\"%a+%\"") or string.match(TheReturnedHTML,"\"country\":\"%a+% %a+%\"")
  19.                 if country != nil then
  20.                 country = string.match(country,":\"%a+%\"") or string.match(country,":\"%a+% %a+%\"")
  21.                 country = string.gsub(country,":","")
  22.                 else
  23.                 country = "\"unknown\""
  24.                 end
  25.                 chat.AddText(Color(255,0,0), "[Server] ", Color(255,255,255), ply:Nick().." connected from: ", Color(0,255,0),""..country)
  26.                
  27.                 end
  28.         end,
  29.         function( error )
  30.                 TheReturnedHTML  = "We failed. =("
  31.                 TheReturnedCode = "1"
  32.         end
  33.     )  
  34.         end
  35.                 hook.Add( "PlayerInitialSpawn", "Spawn_Notification", function( ply )
  36.            get_geoip(ply)      
  37. end )
  38.                 hook.Add( "PlayerDisconnected", "playerDisconnected", function(ply)
  39.                 chat.AddText(Color(255,0,0), "[Server] ", Color(255,255,255), ply:Nick().." disconnected from")
  40.        
  41.                
  42. end)
  43. else
  44.         net.Receive("chat_AddText", function(len)
  45.                 chat.AddText(unpack(net.ReadTable()))
  46.         end)
  47. end
and prophunters gamemode end round board https://github.com/mechanicalmind/prophunters/blob/master/gamemode/cl_endroundboard.lua
Problem: When end round board displaying and new player finished loading on server, it(endroundboard) disappears
Its very big problem,especially when map voting in progress.
When player disconnected endroundboard do not disappears.
So where problem? In hook, or in function get_geoip() or in http.Fetch and what can I do to solve it?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: chat.addtext closes Dframe with chat
« Reply #1 on: April 11, 2015, 09:59:48 pm »
I'm sorry, but I have no idea what you're asking help with?  Maybe I'm misunderstanding, but could you explain it better?

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: chat.addtext closes Dframe with chat
« Reply #2 on: April 11, 2015, 11:32:28 pm »
At the end of round prophunters calling cl_endroundboard . It is Dframe with statistics, name of winner team, and chat box. If someone spawned on server when endroundboard displaying then endround board will closed and in standart chat added message player connected from country.

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: chat.addtext closes Dframe with chat
« Reply #3 on: April 12, 2015, 03:28:11 am »
fixed by myself
Problem in cl_rounds, new player, that spawned on server calling Gamemode function to close menu
Code: [Select]
if GAMEMODE.GameState != 2 then
GAMEMODE:CloseEndRoundMenu()
end
changing to GAMEMODE.GameState == 1
fix this.

  • Print