![]() |
NEW STEAM: Failure on detecting round, how do YOU do it?
Here is my sollution, probably many use it as i believe i got this from the forums when i just started RB :D
Code:
edict_t* pfnFindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue) Perhaps an engine message gets sent ALL THE TIME (also on dedicated server) so we can use that as a sollution? |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Ah. Here's the pitfall.
I believe it's eLiTe who figured out this code. Anyhow... I always suspected this was not a clean way to detect round start. I will run some tests using my o-so-handy PMtools plugin. Perhaps I can find a network message that is sent at round start and only then. Back in 2 minutes... |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
I admit this is method is probably not the most clean one, but it worked all the time, and as long as it works, don't fix things that are not broken (yet? :D)
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
HOLY SHIT!
Here's what is sent as soon as I toggle sv_restartround to 1: Code:
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
I don't know about teamscore, i thought i have seen it changed directly after the bomb exploded or hostages have been rescued. So i am not sure about that.
I did see a roundtimer got set too? |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
yes... the RoundTime message. What if we tested this one ?
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
WORKS!!!!!! :D :D :D
this message is sent ONLY when the round restarts ! it is NOT sent when you change the mp_roundtime CVAR ! Here's the fix, guys ! in pfnMessageBegin(): Code:
else if (msg_type == GetUserMsgId ("RoundTime")) |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
PMB I looked at your plugin solution. It seems that you won't detect the very first round start because "round_end" is set to true only after the round ends. To start off, round_end should be initialized to true, that way on the first start frame the first round start will be detected.
Your code may be fine if the intention is to detect only the end of a round, but I did not dig into it that far. *edit* I see another problem. What about a map change before a round ends? For example, if you issue a changelevel command in the middle of a round, will the roundend message be sent? Even if the roundend message is sent, several frames may go by before the map starts to load up, and your plugin will not be aware of exactly when the first round of the new map started. It will instead think the round started before the map even started to load up. Tosolve this, you will have to also add the round_end detection in pfnChangeLevel, in PMB's case, set the bool Code:
round_end = true I have not yet tested any of this with the new CS 1.6 update (I am coding the changes now as I type), so don't assume I know what I'm talking about. I'll post updates once I have my updates coded and tested. *edit* I am assuming that the roundtime message is sent directly after a round ends, not when a round begins. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
FINALLY BU works again.
And i got the fix too, this one is with help from Alfred. Using messages with destination MSG_SPEC... engine.cpp Code:
// STEFAN Code:
// STEFAN |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Nice... but I prefer my method. Less code involved :P
and my method always works since any map change / map start / server start calls ServerActivate(), which resets all the round and mission parameters and sets mission.finished to TRUE automatically. :) *edit* in CS 1.5 at least, RoundTime is sent for the first round too, so it DOES indeed catch every round START. I don't know for CS 1.6. Can one of you confirm ? |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Well, i got word from Alfred that this is unique to the round-start function code in CS. So i'll take that code, as its only needed for round-start ;)
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
BTW, this thread rather belongs to the SDK coding forum since it's HL specific, no ?
I'm moving it there. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
@stefanhendriks:
I'm not sure if I understood correctly. You are using Alfreds or PMBs code? |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Below is the code that I'm using to detect a new round in CS 1.6 (adapted from statsme):
Code:
extern float g_fTimeNewRound; Code:
void BotClient_CS_TextMsg (void *p, int bot_index) Code:
void BotClient_CS_SendAudio (void *p, int bot_index) Code:
if (g_fTimeNewRound && (g_fTimeNewRound < gpGlobals->time)) |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
wow... does StatMe really do that ?? it's ugly :(
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
i got code from Alfred (of Valve) , he replied to my 'angry' mail at the hlcoders list...
he said that code is always called at round start (as i show above), so i rely on that. And yes, that statsme code is very ugly. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
I don't like any of the methods, they are all ugly and inaccurate options to choose from. This is not my opinion, I before reading this, I did extensive tests to see if I could find a good solution, I explored each of the options mentioned and they all have problems.
At this point, the statsme code is the only code that will work most of the time, and possibly all the time. All the other methods do not work 100% and some probably don't even work at all, like the HLTV message detection because the HLTV message is sent at regular intervals during a round and not just during a round start. I gave up on that method quickly. The RoundTimer message is sent ONLY when there are players in a game. This may work fine for some plugins, but is of no use to plugins that require knowing when a round started no matter if there are players in game or not. Also, because the round start is detected only when the round ends, you should also check for "worldspawn" to detect a fresh mapload or first round after the server started. The problem with "worlspawn" is that there is a delay from that activity to when the round actually starts, so your timing may be off by a few seconds. In each case, multiple messages will be detected, meaning your code will detect multiple round starts for every round start! This can lead to problems. For example, knowing when the round actually started is not accurate. If you stop your bots from moving until after the roundstart delay, your bots will be stuck for a few seconds after the delay passed depending on when the last round start message was detected. It's just damn UGLY! I'll keep searching for a good solution. Does anyone know how to monitor the roundtimer? That's the time telling you how much time is left in the round. I don't think this will help by itself, but it may be part of a foolproof solution. This is what you get for hacking into someone else's code. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
@botmeister : don't forget that we are hooking the date when the messages are being SENT, not the date at which clients receive them. And such messages are all sent in a row in the same frame, for each client in the game. Thus you won't be triggering the round start several times but only ONCE provided all you do is raising a boolean flag that you will check later on in StartFrame.
Also, as I explained, ServerActivate() DOES raise this flag too and since ServerActivate is the LAST function to be called before the first StartFrame(), I can hook map changes and server restarts like this as well. I don't find this "ugly", I find this very neat instead... ...RoundTime is not sent when no players/bots are in game ? Sure, but nevermind for me, my code does strictly nothing when there are no bots or players in game. Anyway, as soon as a player will join, the round will immediately restart. So... |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Quote:
Quote:
I have to correct myself. The HLTV message check actually DOES appear to be the very best solution. I missed the obvious, and it's what Stephan's function points out, you have to look for a message that looks like this: Message_Begin MessageType: 125 MessageDest: 9 WriteByte : 0 WriteByte : 0 Message_End This form of message appears to be sent only once after a round ends. The in round messages have nonzero values for each byte, although more tests are needed to confirm this. So using it, along with the ServerActivate() function hook (as PMB points out) should give us a fool proof and universal method of detecting a round start. Quote:
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Regarding ServerActivate(), yes, it is called everytime a new map boots in. Actually a new map means a new server ; each time you change level (even in single player with level transitions), or force a level restart, in whatever manner you want, you will force a call to ServerDeactivate() immediately after the last StartFrame() in which the command was triggered, and a call to ServerActivate() immediately before the first StartFrame() of the new map.
<facultative> Why I'm reluctant to using HLTV messages is that HLTV is an "external" application using a not-so-well defined protocol, that changes very often. And the purpose of HLTV messages is not for notifying players of a round change, actually if this code is specific to a round change in CS it's pure coincidence ; and on the contrary, notifying clients of a change in the round timer is exactly the point of RoundTime messages... </facultative> |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Quote:
I do think that HLTV would need to know about round starts even if there are no players in the game - no? |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
If you're looking for round events try looking in pfnAlertMessage.
The at_logged event should have something like... "world" triggered "Round_Start", ect. Unfortunately, the site that hosted information about logs and the standard format is gone so I'm going by memory on this. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Quote:
L 01/01/2004 - 01:25:55: World triggered "Round_Start" You can also look for this one: L 01/01/2004 - 01:25:55: World triggered "Game_Commencing" and this L 01/01/2004 - 01:26:21: World triggered "Round_End" Thanks Lazy for this idea :) |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
It works ! I side with this method too.
If you're interested I have updated my PMTools plugin to make it hook pfnAlertMessage()s and send them directly on the listenserver's HUD. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Quote:
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
That's funny, I always thought that you're aware of this message and simply don't reply upon it because of some timing issues :-)
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Bah! I'm back with the HLTV method. Take a look at this test log.
Code:
00:42:00 2004 :: World triggered "Round_End" This may work fine for other people, but it is no good to me as I need to know exactly when a round really starts. *edit* Quote:
*edit* FYI: the Round_End message gets sent only when a round times out. It will not get sent if the round is cut short by other means. |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
The Round_Start message is send when the "freezetime" is over? In that case you could use for other purposes :-)
|
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
OK, I've finally settled on a solution that works great for me. For those who are interested, I've done the following:
1. Hook onto pfnServerActivate. This tells me when a new round has starting after a map load. I set a bool flag indicating that a round is just about to start: RoundStart = true; 2. Hook onto message "HLTV". If the two bytes in the message are both zero, then this tells me a round has just started. RoundStart = true; Note: This message is sent ONLY after a round is ended and at the same time the new round has started - there's no delay between the message and the start of the new round. It will get sent no matter how the round has been ended, and not just when the round times out. 3. Optional: Hook onto pfnStartFrame Code:
If (RoundStart) |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Quote:
Cool! Botmesiter, you said: "Hook onto message "HLTV". If the two bytes in the message are both zero, " Could you please post some sample code on how to do this? Thanks... |
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
code aesthetes aren't we...
weirdos united ! :D |
All times are GMT +2. The time now is 02:30. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.