Quote:
Originally Posted by pride95
PHP Code:
int IntMaxUserId;
public void OnPluginStart() { HookEvent("player_connect_full", Event_PlayerConnect); }
public void OnMapStart() { int Bot = CreateFakeClient("Bot"); IntMaxUserid = GetClientUserId(Bot); KickClient(Bot); }
public Action Event_PlayerConnect(Event event, const char[] name, bool dontBroadcast) { int Id = event.GetInt("userid"); int Client = GetClientOfUserId(Id); if(Id < IntMaxUserid) { ... connection from previous map } }
i don't know if the bot has some userid, but this is an idea. You should find a signature and use in gamedata (if exists) for connections from previous maps. If the players keep their userid on map change i think there should be a signature for this.
|
I am doing something that requires this same thing, where I want to keep tract of new people joining - specifically, joining for the first time in a campaign (I want to do something if somebody is joining for the first time in a campaign - or if they disconnect and rejoin at some point - so NOT when a new chapter of a campaign is loaded into).
I've tested with the mentioned user ID method, and it looks like it doesn't change while loading the 2nd or 3rd level of a campaign - You only get a new user ID if you connect again after leaving. So from my tests, if I store a user ID, and check people who join against the stored ID's, it has always worked for checking if someone is joining for the first time.
The problem is that the
OnMapStart() event happens both during new map loads as well as during map changes to the next chapter in a campaign; so this can't be used to clear the stored user ID's since that would be saying everyone who loads into the next part of a campaign is joining for the first time.
Does anyone know if there is some other event for something like starting a new campaign/the first level?
Edit: "Round_Start" won't work, this happens even more often than OnMapStart