PDA

View Full Version : ELEMENT|Live Weather with windage cvar. (Updated AUG 14TH 2022.)


DJEarthQuake
07-28-2014, 15:44
Click below for Snow demo.
https://i.imgur.com/2wpV1d0.gif (https://cdn.discordapp.com/attachments/664798281057959937/936349556474515506/snow.gif)
Modern Amxx weather feed and generation for all mods.

This is a fork of Autoweather (https://forums.alliedmods.net/showthread.php?t=80143) by TeddyDesTodes. (https://forums.alliedmods.net/member.php?u=42572)

Some things that makes this weather plugin unique.

It works on all mods.
Attempts to make weather on mods that do not have it in the dll have been strenuously made.
Sophisticated debugger.
Windage.
Companion plugin (https://forums.alliedmods.net/showthread.php?t=314896) 'clientemp' gets the temperature for clients as they connect and speaks it. Same API token.

https://i.imgur.com/nkEUUL4.gif (https://forums.alliedmods.net/showthread.php?t=314896)

Rain, snow, skies, dusk, dawn, and wind are all brought into your server.


Commands, Cvars, FAQ, and known limits.

CL_COMMANDS
say /temp, /time, /weather, or /climate.................|displays HUD and console weather feed

CS1.6 and equivalent engines:
say /mytemp....................................... |for your very own local temp (different)
say /news......................................... ..|for local and International news (different)


----- AMX Mod X Help: Commands -----


1: element_dry -Removes all HL1 weather.
2: element_feed -Refreshes weather feed.
3: element_flash -Creates random lights.
4: element_fog -Creates HL1 fog.
5: element_snow -Creates HL1 snow.
6: element_wet -Creates HL1 rain.
----- Entries 1 - 6 of 6 -----


CVARS:

CVARS:
dark <0-25> D: 24 | The higher the number, the darker after sunset.
*
lums <0-25> D: 0 | The lower the number, the brighter it gets at noon.
*
time <0-24> D: 0 | Manually sets time of day in military format. 0 = off
*
region <region> | "region" is "4887398" Get from openweathermap.org by looking at weather in your city click a pager deeper on something and copy the ID from end of URL.
*
day <0-24> D: 0 | Override sunrise hour Y38K futureproof. Dark is unpopular smaller darktimeframe keeps 'most' players!
*
night <0-24> D: 0 | Override sunset hour Y38K futureproof.
*
sv_region <regioncode> | 616411 <https://openweathermap.org/find?q=>
*
sv_units <metric|imperial> | Simply pick what unit you prefer for weather readings.
*
weather_code <#> D: 0 |Override the weatherfeed to any openweathermap.org code from <https://openweathermap.org/weather-conditions> (https://github.com/djearthquake/amxx/blob/main/scripting/valve/elements/element.sma#L39-L56)



Known limits:

Day and night is based off the server's actual real time.
Skychanging plugins compete for sky changes. Disable them.
Started to utilize the wind direction and make use of windage. On Half-Life and Gearbox all weapons are affected. On CS, CZ, Dod only pistols are immune. Staying crouched will fix windage.


Servers testing. (http://www.gametracker.com/search/?search_by=server_variable&search_by2=element_version&query=&loc=_all&sort=&order=)

FAQ:
Q: How to make it night time?
A: CVARS::dark 25;lums 24;time 3

QUICK INSTALL INSTRUCTIONS AND OVERVIEW
Download Script
Get this from Github. (https://github.com/djearthquake/amxx/tree/main/scripting/valve/elements)
Compile script locally and install the skies as well as plugin.

Once running plugin checks if there is an openweathermap.org key added as CVAR.
Server will then produce weather automatically based on locale from CVAR, sv_region (https://openweathermap.org/find?q=).
Incompatible with Amxx 1.82.

internel
07-28-2014, 18:05
Thank you so much for updating that plugin. I couldn't answer your PM, but you know, If you want to add ML support, I'll be glad to help with Spanish ^^

I'm going to test it!

DJEarthQuake
07-28-2014, 22:01
You are most welcome internal.

internel
07-29-2014, 17:42
This is AWESOME!! I just tested it, and it works perfectly!! :D, you sir did a great job here ! :crab:

thank ye!

Vivo
07-29-2014, 22:34
Sounds great :D

DJEarthQuake
07-31-2014, 04:49
Ironically I almost forgot the earthquake condition. I have seen maps with such an effect that will be perfect here. Those are rare. Therefore this is placed at an extremely low priority.

A proposed windy condition will make us have to check the wind direction and compensate at range.

Already existing plugin Shot Administration (by Nomexous) (https://forums.alliedmods.net/showthread.php?t=66101) or similar will be used to handle the trigger of high wind.
Accuracy fix (https://forums.alliedmods.net/showthread.php?p=1549133) could be used then disabled when it gets windy. I also noticed ever since CS 1.6 got to Steam it wasn't accurate.

The sky is off at noon and shows a night sky still. This will be corrected too. Let me know what else. I appreciate the salutations.

zmd94
08-01-2014, 21:43
Ironically I almost forgot the earthquake condition.

A proposed windy condition will make us have to check the wind direction and compensate at range.So, epic. :up:

I will wait for this update. Just let we all know, when it is ready.

DJEarthQuake
08-22-2014, 15:40
I made an update to the source. Debugging was enabled. Now it is disabled. Majority of the log is currently too cryptic. I had an update earlier this week. I promptly took it down. Sky tuning is still underway. IE | Night sky showing at noon.

DJEarthQuake
08-26-2014, 01:15
I like how OpenWeatherMap.org has current wind condition.

$~telnet api.openweathermap.org 80
Trying 162.243.53.59...
Connected to api.openweathermap.org.
Escape character is '^]'.
[GET /data/2.5/weather?id=4887398&units=imperial&APPID=register-for-a-openweathermap&u=c HTTP/1.0

...PRESS ENTER TWICE...

HTTP/1.1 200 OK
Server: openresty
Date: Sun, 02 Apr 2017 00:57:51 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 438
Connection: close
X-Cache-Key: /data/2.5/weather?APPID=register-for-a-openweathermap=4887398&u=c&units=imperial
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST

{"coord":{"lon":-87.65,"lat":41.85},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":50,"pressure":1022,"humidity":46,"temp_min":46.4,"temp_max":53.6},"visibility":16093,"wind":{"speed":6.93,"deg":110},"clouds":{"all":1},"dt":1491093300,"sys":{"type":1,"id":1007,"message":0.1218,"country":"US","sunrise":1491132670,"sunset":1491178654},"id":4887398,"name":"Chicago","cod":200}
Connection closed by foreign host.

This is a good start. If anybody else wanted to collaborate or spin-off with the sniping section! Hint hint wink wink nudge n u d g e.

Dare.Devil
08-27-2014, 15:54
where exactly in yahoo can I find the region code??..

you said in first post e.g chicago 2379574 ..

how do I get this serial code??

thanks in advance

DJEarthQuake
08-27-2014, 19:50
Go to Yahoo, click weather, or weather.yahoo.com, enter city. Number appears at end of address.

Dare.Devil
08-28-2014, 02:14
Go to Yahoo, click weather, or weather.yahoo.com, enter city. Number appears at end of address.

found it thanks :).. by the way great app hope the weather changes soon :) in London don't want to wait until December :P

xairgeo
10-26-2014, 04:37
Players, weapons and some objects are very dark how do i fix this? the cvars minlight and maxlight only makes the game bright.

Edit: okay, when i step into a shadow or when im inside a building i can see my weapon and other players perfectly but as soon as i step outside into the light my gun model becomes very dark and when players move into the light they also become very dark, again the cvars don't help.

DJEarthQuake
10-26-2014, 13:47
If night vision or flashlight isn't available use weather_minlight 20.

juanjotoronja
04-10-2015, 15:58
Hi this can be used directly with CS 1.6 or is it only for half-life?

DJEarthQuake
04-10-2015, 16:45
It works best with 1.6 and similar.

juanjotoronja
04-10-2015, 16:57
This is my weather info https://weather.yahoo.com/argentina/autonomous-city-of-buenos-aires/buenos-aires-468739/ So should i put those 6 digits in this line? g_cvar_region = register_cvar("region","2379574");When i use the command say /mytemp it says in the motd that it couldn't recognize my IP and then shows google search results, also in the game i think time zone is wrong because when i tested it was 4 pm and in game was night. I don't know if this has anything to do with this error but in windows in regional settings for unicode i have english united states and not spanish argentina how it should be.

DJEarthQuake
04-11-2015, 13:46
rcon region 468739 sets locale as buenos aires.
That daily eclipse is being fixed.
/mytemp initializes: "If we can not determine your country off your IP then this will display generic weather page..." Google weather loads in any event.
AMXX uses GEOIP. WHOIS (http://en.wikipedia.org/wiki/Whois) over SOCKETS (http://amxmodx.org/doc/index.html?page=source%2Ffunctions%2Fsockets% 2Findex.htm) resolves GEOIP (http://amxmodx.org/doc/index.html?page=source%2Ffunctions%2Fgeoip%2F index.htm) antiquation.

GET http://api.hackertarget.com/whois/?q=8.8.8.8 | grep -w "Country"
Country: US
Country: US

GET http://api.hackertarget.com/whois/?q=8.8.8.8 | grep -w "City"
City: Broomfield
City: Mountain View

DJEarthQuake
03-20-2017, 15:24
Since Yahoo got exploited (https://www.nytimes.com/2017/03/17/technology/yahoo-hack-data-indictments.html?&_r=0) they treat petty weather feeds like something they are not (https://www.nytimes.com/topic/company/yahoo-inc?inline=nyt-org) it disabled the plug-in!

SAN FRANCISCO — For sale: one billion accounts, $200,000 or best offer. The passwords don’t work, but the dates of birth, telephone numbers and security questions could still be useful to an adept cyberthief.

edon1337
03-20-2017, 15:52
I haven't tested but this sounds cool :)

DJEarthQuake
04-01-2017, 17:56
Eclipse is fixed. A run-time error and segment fault are both now eliminated.
Weather is in real time for the Spring of 2017. Last release was hourly in 2014. Original was 3 day a decade ago.

Openweathermap (https://openweathermap.org/appid) has an ID to register for and use like Yahoo (https://developer.yahoo.com/oauth/) but easier to code.
Epoch.inc (https://forums.alliedmods.net/showthread.php?t=91915) that might be augmented into this in near future.

Chicago tested.

region "4887398&units=imperial&APPID=getyourown32-bitregistration"Mets Masrik, Armenia tested.

region "616411&units=metric&APPID=getyourown32-bitregistration" We have to use this long string now instead of a simple region due to New World Order of weather feed security!

Krtola
04-04-2017, 08:50
map name from first post please?

JusTGo
05-12-2017, 09:07
afaik that bug got fixed long time ago what hlds version you use ?

SpawnerF
07-12-2017, 18:52
The idea is good but the code is messy, you need to clean it first.

DJEarthQuake
07-25-2017, 07:31
Will do.

FR0NTLINE
08-13-2017, 01:29
I thought Okapi was never working correctly?
and what kind of file is this? extract in cstrike_folder.tar.lzma

DJEarthQuake
04-10-2018, 00:45
Since major upgrade of server I had to use amxmodx-1.8.3-dev-git5151-base instead of amxmodx-1.8.2-base-linux. First time using Apple Hardware for server. I like grepping with amx_search so much I prefer it over the non-developer version. If you are using PC this might not ever happen. Apple's chips are 'unique'.

chuttenjr
09-15-2018, 12:29
#DJEarthQuake ,have you found a fix for the silent footsteps while outside bug??,i experienced it and thought my pl_steps where corrupted or that they were of a very high bitrate annd frequency and did a fresh vanilla cs reinstall and after that i read that know bug.... hehehe

Cheers

Eduardo

DJEarthQuake
09-15-2018, 15:33
There's more inherited stuff that's wrong. When it is raining I hear snow steps instead of puddle splashes. I really hadn't been bothered by it enough to resolve it yet.

chuttenjr
09-16-2018, 17:15
No problem at all,i understand it.
Getting my cs back to normal mod madness wasnt that hard at all.
Also tested again both auto weather and auto weather yahoo and they both have the same issue with the outside muted footsteps.
I will post a request to see if someone wants to dig into the code (doubt it) to see where the problem is.
It was a joy to see the different light settings, skies and such , a really great idea for such a limited game engine :(.

DJEarthQuake
09-16-2018, 17:52
There aren't any Yahoo versions out there with working weather feeds which is what the mod is about not footsteps. I was the one looking for a stats plugin, found this and changed it from BBC to Yahoo, then to openweathermap. If the feed does not work then the weather is static and never changes. The footsteps work great outside only when it's snowing. I wasn't joking about it being an inherited bug within plugin. I gave my shot out to Autoweather on front page here.

HamletEagle
09-17-2018, 09:15
I can review it, but please intend it properly first. It's a total mess.
Also use spaces in functions. A function should not be just one huge block of code. It's completely unreadable(example daylight).

HamletEagle
09-17-2018, 11:39
I find it hard to believe you were a developer for so many years and think this is fine:

log_amx("darkness %d",light);
//log_amx("%s %s %s",g_LightLevel[get_pcvar_num(g_cvar_minlight)],g_LightLevel[light],g_LightLevel[get_pcvar_num(g_cvar_maxlight)]); // old works all ltrs
log_amx("dark %d phase %d lums %d",get_cvar_num("dark"),light,get_cvar_num("lums"));
log_amx("darkness added to max light is %d out of 25 total darkness",light);



new num[10];
num_to_str(g_sunrise,num,10);
nvault_set(g_vault,"sunrise",num);
g_sunrise = str_to_num(out);



new num[1];
num_to_str(g_env,num,1);
nvault_set(g_vault,"env",num);



if(containi(buf,"temp_min")>= 0 && g_temp_min == 0) {
new out[32];
copy(out,4,buf[strfind(buf,"temp_min")+10]);
replace(out,4,",",""); //was 5 both
replace(out,4,"#","");
#if defined DEBUG
log_amx("Low of: %s",out);
#endif
nvault_set(g_vault,"mintemp",out);
g_temp_min = str_to_num(out);
}
if(containi(buf,"visibility")>= 0){
new out[32];
copyc(out,32,buf[containi(buf,"visibility")+12],'"');
#if defined DEBUG
log_amx("Visibility: %s",out);
#endif
nvault_set(g_vault,"visi",out);
g_visi = str_to_num(out);
}
if(containi(buf,"humidity")>= 0 && g_hum == 0) {
new out[32];
copyc(out,32,buf[containi(buf,"humidity")+10],'"'); // was 10
#if defined DEBUG
log_amx("Humidity: %s",out);
#endif
nvault_set(g_vault,"humidity",out);
g_hum = str_to_num(out);

}


I also don't see the point in that wall of text, mentioning what plugins you did before or what other people did or didn't do. It's off-topic.
You asked for a review. The first thing that should be fixed is the indentation, make it consistent.

edon1337
09-17-2018, 13:06
You asked for a review.

Why can't everyone ask for that?

HamletEagle
09-17-2018, 13:55
Why can't everyone ask for that?

Can you elaborate? Everyone can ask.

edon1337
09-17-2018, 14:53
Can you elaborate? Everyone can ask.

What I was pointing at was that you agreed to review his code just because he asked for a review meanwhile there's tons of older or quicker-to-review codes out there, not my problem but just saying.

Improvements:

1. Give your variables better naming, for ex: g_cvar_uplink should be g_szCvar_Uplink as it holds a string meanwhile g_cvar_maxlight should be g_iCvar_Maxlight because it holds an integer.

2. The same goes to your functions, you should give some special attention to naming your functions, as it's going to help the readers a lot if the functions are named accordingly.

3.
public fwd_PlayerPreThink(id)
{
if(!is_user_alive(id))
return FMRES_IGNORED;
static Float:fGmTime ; fGmTime = get_gametime();
if(g_fNextStep[id] < fGmTime)
{
if(fm_get_user_speed(id) && (pev(id, pev_flags) & FL_ONGROUND) && is_user_outside(id))
{
set_pev(id, pev_flTimeStepSound, 999);
if(g_env == 3){
engfunc(EngFunc_EmitSound, id, CHAN_AUTO, g_szSnowStepSound[random_num(0, sizeof g_szSnowStepSound - 1)], 0.5, ATTN_NORM, 0, PITCH_NORM);
}
g_fNextStep[id] = fGmTime + STEP_DELAY;
}
}
return FMRES_IGNORED;
}

Playing sounds on PreThink? Is that really needed?

4. stock Float:fm_get_user_speed(id)
{
if(!is_user_connected(id))
return 0.0;
static Float:fVelocity[3];
pev(id, pev_velocity, fVelocity);
fVelocity[2] = 0.0;
return vector_length(fVelocity);
}

get_user_maxspeed?

5. }
public ClCmd_TemP(id, level, cid) {
new motd[512];
format(motd, 511, "<html><meta http-equiv='Refresh' content='0; URL=https://google.com/search?q=weather'><body BGCOLOR='#FFFFFF'><br><center>If we can not determine your country off your IP then this will display generic weather page...</center></HTML>");
show_motd(id, motd, "Weather Browser");
}

a. Use formatex
b. Use charsmax() instead of directly putting the size.

edon1337
09-17-2018, 14:58
If it's not broken then don't fix it. 5 years ago I cared. Now a day late and dollar short. It's amusing you picked the source I fixed and stopped the divide by zero and noon eclipse of why not to approve. I will work on known issue but not the prose. I did the port and some refinements. Try playing with mod first then critique please. Adding windage is all that interests me now.

Just because it works, doesn't mean it's good.

JusTGo
09-17-2018, 16:15
Improvements:

1. Give your variables better naming, for ex: g_cvar_uplink should be g_szCvar_Uplink as it holds a string meanwhile g_cvar_maxlight should be g_iCvar_Maxlight because it holds an integer.



this is a bad advice. read this :
https://github.com/alliedmodders/amxmodx/pull/567#issuecomment-420452301

edon1337
09-17-2018, 16:21
this is a bad advice. read this :
https://github.com/alliedmodders/amxmodx/pull/567#issuecomment-420452301

It depends on each coder, but what he stated doesn't really make sense, size can be integer, float or even a string, it really depends on your situation.

JusTGo
09-17-2018, 16:24
It depends on each coder, but what he stated doesn't really make sense, size can be integer, float or even a string, it really depends on your situation.

did you read the other posts your question is answered too

DJEarthQuake
09-18-2018, 10:28
I'm not even going to bother, I have better things to do.

You cannot back peddle out of this HamletEagle. You can change what you write but cannot change how you really feel.

HamletEagle
09-18-2018, 11:59
I'm not back pedalling, what I was saying by "I'm not even going to bother" is that I'm not gonna invest time in arguing with you as I don't think it will lead to anything. The reason why I edited is because I thought maybe it's just too harsh.

When you asked for a review I supposed you are willing to improve your plugin and have a constructive discussion. Instead, what you did is take it personal, become defensive, keep saying you don't care. What is the reason to become upset at a review or consider it a "squabble"? That's how things work here, the code NEEDS to be reviewed by an approver to make sure it's high quality code.

If you were interested in actually learning something you could have been way less defensive. Instead of saying that you don't care about any coding standard you could have asked "why it's important to indent my code or write readable code" and I would gladly explain.

And that's the reason I'm not going to bother with this: you DO NOT want a review, you DO NOT want to have a discussion, you DO NOT want to listen to someone else and accept that you may be wrong. What's the point in my explaining anything or giving feedback when you are clearly not going to listen and discuss about it and instead you will take it as a personal insult? It's a waste of time.

@edon:
What I was pointing at was that you agreed to review his code just because he asked for a review meanwhile there's tons of older or quicker-to-review codes out there, not my problem but just saying.

And from that ton of older/quick to review codes I picked this one. When I started to actively review that section had 21 pages. I managed to bring it down to 14 pages, then I stopped for a period because I was busy and now it's at 27 pages of plugins. That's an insane amount of work for only one person(as I'm the only active approver).
If you are aware of such quick to review plugin feel free to make a list and pm me.

About HN, the style is up to the coder, as long as it's readable and consistent. You shouldn't enforce Hungarian notation, as it's pointless most of the time and make variable names too verbose. Ideally, people should be able to read your code as their read an english text. The variable names should be descriptive and in most cases HN doesn't contribute to that.
You can use it in your plugins(later you'll understand why I say it's pointless). For a project like AMXX where multiple people contribute to it, it makes sense to have some general guidelines on coding style.

edon1337
09-18-2018, 12:25
@edon:

And from that ton of older/quick to review codes I picked this one. When I started to actively review that section had 21 pages. I managed to bring it down to 14 pages, then I stopped for a period because I was busy and now it's at 27 pages of plugins. That's an insane amount of work for only one person(as I'm the only active approver).
If you are aware of such quick to review plugin feel free to make a list and pm me.

I'm not trying to be mean over here but, the approver staff needs to be updated, I know approvers aren't obligated to be active but being inactive means you were inactive, there is approvers who haven't even logged for months, and there's others who haven't a reviewed a single plugin for years.

Plugins like these don't take more than 15 minutes to review, if every approver reviewed at least 1 plugin per 1 month, this huge load of plugins wouldn't have accumulated.

But still, every staff member just dips into reasoning to try and back them up.

If you're not able to invest 15 minutes of your time once in a month, are you really worthy of the title?

I'd gladly help with reviewing, but there's still I'm unknowingly of, so I'll just take my time and focus on filling these blank spots.

DJEarthQuake
09-19-2018, 00:36
#chuttenjr. Footsteps restored. Version 4. Tested. Let me know. Thanks for showing me how to use humans as debuggers for free. You rock dude!

DJEarthQuake
09-19-2018, 02:04
netstat -toad
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State Timer
tcp 315 0 yourIP:yourPORT 192.241.169.168:http CLOSE_WAIT off (0.00/0/0)

whois 192.241.169.168 | grep abuse
OrgAbuseEmail: [email protected]

The simplest cloud platform for developers & teams.

There is no need to be alarmed this is where we get the tiny weather feed from.
There are several formats one can use. Pick whatever naturally works best for you and your project.
Data is available in JSON, XML, or HTML format

tarsisd2
09-19-2018, 12:56
your plugin could detect from what city is the player from and get the weather right for him!

DJEarthQuake
09-19-2018, 12:58
@tarsisd2. Great point. The plug-in already does by saying /mytemp.

chuttenjr
09-19-2018, 22:43
Wow,you fixed it !! thanks a lot man!! dark rainy maps incoming hahahaha

DJEarthQuake
09-19-2018, 23:37
You are welcome!

HamletEagle
09-20-2018, 08:58
It was obviously a typo, no need to make a fuss out of it or try to act smart.

What I am interested in doing something about:
There is a lot of approved code. Plugins that have either crashed or ddos system. Those few need quarantined. Possibly by click to flag with drop-down severity indicators. We can Drupalize. People trust APPROVED. I can show slow hacks and everything else examples of approved code in this state. Issues duplicable. I have had to find new versions of some of my favorite plugins and warn the finding. I'm sure it's not deliberate. Just bugs.
I agree there is a lot of trash in the approved section. A lot of plugins are broken or have terrible code. Unfortunately we don't have the man power to clean it. We can't even deal with the New Plugins Submissions section.
It seems that I'm the only active approver(active as in actually reviewing plugins) and it was like that for few years.

With a lot of help from edon(he did most of the work and gave me a list), in the last few days I managed to remove all the trash from the new plugins section(trash as in source mod plugins/broken or terribly coded plugins/requests/topics without source files). We cleaned 3 pages of pure trash and this were only the most obvious cases, screaming "I'm garbage". There's still plenty.

You are welcome to make a similar list from the approved section(plugins with bugs that stop them from working or such). Post it here or send it to me by PM. I need clear evidence that the plugin is broken(for example multiple people complaining in the thread and providing error logs).

DJEarthQuake
09-21-2018, 02:49
@HamletEagle. Check PM.

tarsisd2
09-24-2018, 15:30
#chuttenjr. Edu. Have you tried my all women skin and weapon pack that rivals cs:go from 18 years ago for 1.6? ;)

https://forums.alliedmods.net/attachment.php?attachmentid=171533&stc=1&d=1537734676
Said server has the details.



i use diferent skins for women on my community too, can i have a loot at your pack?

DJEarthQuake
09-24-2018, 17:39
#tarsisd2. PM me or join the server ~B~Team~ because it advertises URL there.

DJEarthQuake
10-06-2018, 10:54
I see some are clinging on to the Yahoo version. Since they revamped their system after being hacked Amxx plugins based off of it fail to connect.

DJEarthQuake
11-19-2018, 17:14
Some cities are do not show on openweathermap. Best bet is to pick one nearby.

DJEarthQuake
02-28-2019, 06:06
I tested Half-Life Fog successfully on both HL and CS.

DJEarthQuake
03-07-2019, 01:04
Copy left protection added and code is more optimized especially shrinking socket data size.

DJEarthQuake
03-10-2019, 19:54
your plugin could detect from what city is the player from and get the weather right for him!

Bug found in GeoIP (https://github.com/alliedmodders/amxmodx/issues/691)

@tarsisd2. I got it done just how you say with GeoIP on connect. Users no longer have to say /mytemp and wait for MOTD into Google. That means it works on mods before Counter-Strike too. That's an upgrade. Thanks for the suggestion.



/**
* Elements-Lite. Player GeoIp connection reading and temp. Half-Life server of any mod.
* Get a free 32-bit API key from openweathermap.org. Pick metric or imperial. Only cvar.
* Copyleft (C) 2019 .sρiηX҉.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <amxmodx>
#include <amxmisc>
#include <geoip>
#include <sockets>


#define PLUGIN "ClientTemp"
#define VERSION "A"
#define AUTHOR ".sρiηX҉."
#define DEBUG
#define MY public
#define KEY "................................"
#define UPLINK "GET /data/2.5/weather?lat="
#define U2 "&u=c HTTP/1.0^nHost: api.openweathermap.org"
new name[33], ip[32], authid[64], city[64], country[33], region[64];
new Float:g_lat[32], Float:g_lon[32];
new Soc_O_ErroR2, g_scknamede;

new buf[256], constring[256];
new g_cvar_unit;
new id, unit[16];

MY plugin_init()
{
{
{
register_plugin(PLUGIN, VERSION, AUTHOR);
g_cvar_unit = register_cvar("unit", "imperial");
}
}
}

MY client_putinserver(id)

{
{
{
if (is_user_bot(id) || is_user_hltv(id)) return;
get_user_name(id,name,32), get_user_ip(id,ip,31,1), get_user_authid(id,authid,63), geoip_city(ip,city,64,1), geoip_country_ex(ip,country,32,2), geoip_region_name(ip,region, 64,2);
set_task_ex(1.5, "get_namede", 139, .flags = SetTask_Once);

g_lat[id] = geoip_latitude(ip);
g_lon[id] = geoip_longitude(ip);

log_amx("Name: %s, ID: %s, Country: %s, City: %s, Region: %s joined. |lat:%f lon:%f|", name, authid, country, city, region, g_lat[id], g_lon[id]);
client_print(0,print_chat,"%s %s from %s appeared on %s, %s radar.", name, authid, country, city, region);
}
}
}

MY client_disconnected(id)

{
{
{
if (is_user_bot(id) || is_user_hltv(id)) return;

get_user_name(id,name,32), get_user_ip(id,ip,31,0), get_user_authid(id,authid,63), geoip_city(ip,city,64,1), geoip_country_ex(ip,country,32,2), geoip_region_name(ip,region, 64,2);

client_print_color(0,id, "^x03%s^x01 ^x04%s^x01 from ^x04%s^x01 disappeared on ^x04%s^x01, ^x04%s^x01 radar.", name, authid, country, city, region);

if ( cstrike_running() ) return;
client_print(0,print_chat,"%s %s from %s disappeared on %s, %s radar.", name, authid, country, city, region);
}
}
}

MY get_namede()

{
{
{
#if defined DEBUG
log_amx("Named:Starting the sockets routine...");
#endif
get_pcvar_string(g_cvar_unit, unit, 15);

g_scknamede = socket_open("api.openweathermap.org", 80, SOCKET_TCP, Soc_O_ErroR2, SOCK_NON_BLOCKING|SOCK_LIBC_ERRORS);

g_lat[id] = geoip_latitude(ip);
g_lon[id] = geoip_longitude(ip);
formatex(constring, 256, "%s%f&lon=%f&units=%s&APPID=%s%s^n^n", UPLINK, g_lat[id], g_lon[id], unit, KEY, U2);
write_web(constring);

#if defined DEBUG
log_amx("This is where we are trying to get weather from");
log_amx(constring);
log_amx("Debugging enabled::telnet api.openweathermap.org 80 copy and paste link from above into session.");
#endif
read_web();
}
}
}

MY write_web(text[256])

{
{ server_print("Named:soc writable");
{
if (socket_is_writable(g_scknamede, 100000))
socket_send(g_scknamede, text,255);
}
} server_print("Named:writing the web");
}

MY read_web()

{
{
{
server_print("Named:reading the web")
if (socket_is_readable(g_scknamede, 100000))
socket_recv(g_scknamede, buf, 255);
if (!equal(buf, ""))
{
if (containi(buf, "temp") >= 0 )
{
server_print("Named:Ck temp");
new out[8];
copyc(out, 6, buf[containi(buf, "temp") + 6], '"');
replace(out, 6, ":", "");
replace(out, 6, ",", "");
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
#if defined DEBUG
log_amx("Temperature: %s", out);
#endif
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
client_print(0,print_chat,"Temp there is %s degrees in %s.", out, region);
}
set_task_ex(2.0, "read_web");
}
else
{
socket_close(g_scknamede);
server_print("Named finished reading")
}
}
}
}

DJEarthQuake
03-18-2019, 02:31
Sharing tested lite spin-off version called CLIENTEMP. It displays the temp of each player to everybody.

xakintosh
03-19-2019, 12:58
This plugin deserve proper video tutorial for all effects :)
Great Job!

DJEarthQuake
03-30-2019, 16:28
This plugin deserve proper video tutorial for all effects :)
Great Job!

That's one hell of a suggestion. Thank you. More to come! Users are welcome to submit them to my PM!!

DJEarthQuake
06-09-2019, 09:00
How to the automatically post city temp in MOTD with SH.
OP4 example when using cron from root otherwise ~ would be easier instead of /home/username/

cat temps.sh
#~/bin/sh
MYAD=`date +L%Y%m%d*`
cd /home/YOURUSERNAME/Steam/steamapps/common/Half-Life/gearbox/addons/amxmodx/logs

grep degree $MYAD |cut -c 48-120 > /tmp/temps.txt
sleep 7
grep degree $MYAD |cut -c 48-120 >> /home/YOURUSERNAME/Steam/steamapps/common/Half-Life/valve/motd.txt

DJEarthQuake
10-02-2019, 15:22
So, epic. :up:

I will wait for this update. Just let we all know, when it is ready.

I tested the windage was 220 degrees and HUD was pointing around 7 or 8 O' clock as it should.

DJEarthQuake
05-19-2020, 15:26
#DJEarthQuake ,have you found a fix for the silent footsteps while outside bug??

I got the code here (https://forums.alliedmods.net/showpost.php?p=2701081&postcount=5) and will integrate.

Ark_Procession
08-04-2022, 11:56
alright so i decided to try your plugin and i'm lost.
lots of elements to download with random names apparently, which one should i use?
i am in buenos aires, it's not clear to me with all the text from the post/post responses a direct and short way of telling users how to actually use the plugin.

DJEarthQuake
08-05-2022, 09:51
Thank you for the feedback @Ark_Procession. I've edited the post. Cvar sv_region is 3435910 (https://openweathermap.org/find?q=) for Buenos Aires, AR.