hello there folks,
i'm having trubble to get the system.getCountry syntax to get running in a script that i own.
Cogameevent.Listen("player_disconnect")
hook.Add("player_disconnect", "atlaschat.DisconnectMessage", function(data)
local filtered = atlaschat.filterJoinDisconnect:GetBool()
if (!filtered) then
chat.AddText(color_white, ":offline: Player ", color_red, data.name, color_grey, " (" .. data.networkid .. ") ", color_white, "has left the server: " .. data.reason)
end
end)
net.Receive("atlaschat.plcnt", function(bits)
local name = net.ReadString()
local steamID = net.ReadString()
local filtered = atlaschat.filterJoinDisconnect:GetBool()
if (!filtered) then
chat.AddText(color_white, ":online: Player ", color_limegreen, name, color_grey, " (" .. steamID .. ") " , color_white, "has joined the game.")
end
--------------------------------------------------------------------------------------------------------------------------------------
This parts are spperatet above is cl and below is sh stuff
---------------------------------------------------------------------------------------------------------------------------------------
util.AddNetworkString("atlaschat.plcnt")
gameevent.Listen("player_connect")
hook.Add("player_connect", "atlaschat.PlayerConnect", function(data)
net.Start("atlaschat.plcnt")
net.WriteString(data.name)
net.WriteString(data.networkid)
net.Broadcast()
end)
i tried some things out like to add it in the sever side like system.getCountry(data.country) and than at the client side : .... color_limegreen , data.country,.... etc.
i have no to little knowledge in .lua so pls have a little understanding if i question some basic things
thank you and sorry for my poor english
You would have to call system.GetCountry on the connecting client and have them respond back to the server or use a geoip api on the server to determine the country.
Atlas Chat is a paid addon.
yes it is but the help the dev provides is a**... the only thing that he was telling me is to go system.GetCountry and look up foor myself... the problem is my my verry little understanding of lua. now im
here to search for help. if u dont trust me i can show u the chat on the store and my bought licens. Like dubb said how would l get it to work? befor the hook.add an sstem.GetCountry? after? this are things im not sure off .
thanks diff im going to try this method.
okay i got something that dosent spit ou Errors together... but it still dosent post anything in the massage. Does anyone have a clue?
local GEOIP_QUERY_URL = "https://get.geojs.io/v1/ip/country.json"
if SERVER then
util.AddNetworkString("geoip_data")
end
if CLIENT then
net.Receive("geoip_data",
function(len)
local rawdata = net.ReadString()
local data = util.JSONToTable(rawdata)
PrintTable(data)
end
)
end
local function geoip_capture(ply, callback, errcallback)
local ip = ply:IPAddress():match("%d+%.%d+%.%d+%.%d+") or ""
local query_string = string.format(GEOIP_QUERY_URL, ip)
http.Fetch(query_string,
function(json, len, headers, status)
callback(json)
end,
function(err)
errcallback(err)
end
)
end
gameevent.Listen("player_disconnect")
hook.Add("player_disconnect", "atlaschat.DisconnectMessage", function(data)
local filtered = atlaschat.filterJoinDisconnect:GetBool()
if (!filtered) then
chat.AddText(color_white, ":offline: Spieler ", color_red, data.name, color_grey, " (" .. data.networkid .. ") ",geoip_data, color_white, "hat das Spiel verlassen: " .. data.reason)
end
end)
net.Receive("atlaschat.plcnt", function(bits)
local name = net.ReadString()
local steamID = net.ReadString()
local filtered = atlaschat.filterJoinDisconnect:GetBool()
if (!filtered) then
chat.AddText(color_white, ":online: Spieler ", color_limegreen, name, color_grey, " (" .. steamID .. ") ",geoip_data, color_white, "hat das Spiel betreten.")
end
end)
It's not my responsibility help you implement new things. My support is for issues with my chatbox and how you can use existing functionality.
I made this at like 5am so don't ask why I'm using goto.
-- country_codes.lua
local codes = setmetatable({}, {
__index = function(self, k)
return k
end,
})
local function FetchCountryCodes()
if (file.Exists("country_codes.txt", "DATA")) then
local a = file.Read("country_codes.txt")
if not (a) then goto GET end
a = util.JSONToTable(a)
if not (a) then goto GET end
table.Merge(codes, a)
goto END
end
::GET::
http.Fetch("http://country.io/names.json",
function(body)
local a = util.JSONToTable(body)
table.Merge(codes, a)
file.Write("country_codes.txt", body)
end,
function()
print("Failed to fetch country codes! Retrying in 5 seconds!")
timer.Simple(5, FetchCountryCodes)
end
)
::END::
end
FetchCountryCodes()
return codes
-- autorun/sh_join_message.lua
if (CLIENT) then goto CLIENT end
do
local CountryCodes = include("country_codes.lua")
util.AddNetworkString("Country Roads")
net.Receive("Country Roads", function(_, client)
if not (client.ExpectingCC) then return end
client.ExpectingCC = false
local cc = net.ReadString()
local country = CountryCodes[cc]
net.Start("Country Roads")
net.WriteEntity(client)
net.WriteString(country)
net.Broadcast()
end)
hook.Add("PlayerAuthed", "Take Me Home", function(client)
client.ExpectingCC = true
end)
goto END
end
::CLIENT::
do
timer.Simple(0, function()
net.Start("Country Roads")
net.WriteString(system.GetCountry())
net.SendToServer()
end)
net.Receive("Country Roads", function()
local ply = net.ReadEntity()
local country = net.ReadString()
chat.AddText(string.format("%s (%s) has joined the server from %s!", ply:Nick(), ply:SteamID(), country))
end)
end
::END::
you are right it isn't but the small line between "good support" and "Scripter dosen't care" is just simply help the people. If i had the knowledge i woudn't had ask you and this forum for Help and coded it for myself. I mean comon.. Richard and other sellers are way more supportive in this regards. they listen and try to get some little custom edits done. Like i said im very thankfull for any help to get the geoip api running in Chewgum awsome script. I don't want to front you in any way but i saw other sellers much more friendly and helpfull. So I'm searching for a 3rd party solution to make your script better for my needs.
Good support doesn't mean at all that we have to add features that do you want because you paid for the base script.
And don't come and me with adam/michael or whoever, there are really shitty developers and not for that i have to be shitty with people that asks supports, as developer I know the difference between someone that requires helps in something and someone that wants extra time from me for their needings, if you need something extra in one of my scripts, you can either hire me or hire anyone else and people been okay with that the whole time
You own the script, not the developer
The community generally frown on people who don't put any effort in making their scripts.
The reason being that spoon-feed people return to get spoon-feed again.
You need to watch some lua tutorials or hire a dev.
Here is a helpful chard I've made (by my morals):
https://files.facepunch.com/forum/upload/107119/9b09c310-54b7-47f6-93c5-f2b038dd8205/billede.png
You're not entitled to demand more features on a product.
The same way I'm not entitled to demand more computer parts when I buy one from a store.
You guys totaly miss my point here. A dev is not forced to help likewise the facepunch com is not but sometimes a friendly and helpfull soul stands up and helps rookies and beginners like me. The key is communication... Just say " im not going to help you forther" an d not "just figure it out for yourself", in my understanding the last one is a way to say idk in a more polite maner. Like i said i'm looking for someone who has the time and the patience to help me out. In the end i'm not an singele cm further than 2 days ago even trying it out dont brought me the needed resaults or the knowledge. In that case this Forum post did 0 to contribute to an person (me) who was enganged to learn something new but the lack of information about this topic. I would like to do it by myself but you cant skip the basics
and go straight to an endgame skill.. but you can try to rush it and get help of some strangers who push you. Like in every other opinion based centario you can agree with me or not and tell me why i'm
wrong in my perspective... in my opinion is this a very sensless doing because no one is helped with this. to be honest i dont have the time to learn the steps in lua in a month or two to get to the level where i can code it my myself so i am asking for a white knight who is willingly helping me and explaining me how i can do it by myself. sometimes kind people exist and if not than welp...
You are correct but you can go to an pc store and question how to build in hardware (what was provided) and where to get the parts as an option. If you are lucky the guy shows you how to install the
hardware part because he has an open pc he is working on laing infront of him and wants to inform you about this because its an minor issue for someone who is doing it for a living or the extra bucks.
You called him an ass for saying no. Sounds like a demand to me.
One of the rules on this forum are; no spoon-feeding.
A lot of users on this site are helpful and want to help. A few comments have already been helpful at guiding you:
The function: system.GetCountry() returns the clients country when run. (by: dubb ,This is CLIENT-side)
A lot of services like GeoIP, allows you to lookup an incoming IP's location. (by: diff360 ,Can be done on both SERVER or CLIENT-side)
beaner posted 2 lua files ( Not fully working .. but should show how to retrieve website data, post a message and basic networking )
We all replied that you need to learn the basics of Lua before the community will fully engage with code, along with a few helpful hints and ideas how to tackle the feature.
A basic Lua script like a message, takes ½-2 days to learn. (Its one of the first Lua scripts I ever made.)
I know you can do better than what you have posted.
You won't get anywhere by saying the forum did no contribution and calling a developer an ass.
Instead I can recommend you watching 4-5 short YouTube videos:
Coding environments
Hello World!
The Wiki (You can skip this if you know the wiki-page)
Class types
Hooks (Everything is controlled by hooks. You'll be looking for InitPostEntity )
Now we learned from beaner's script that chat.AddText( .. ) is a CLIENT-side function and dubb pointed out that system.GetCountry() is a useful function ( I didn't even know it existed ).
chat.AddText( "My country is" .. system.GetCountry() )
tf you mean not working
my 5am caffeine induced shitcode never fails
Sorry, you need to Log In to post a reply to this thread.