View Single Post
Rescue9
Junior Member
Join Date: Apr 2009
Old 10-19-2009 , 22:01   Re: Basic Player Tracker
Reply With Quote #6

After dealing with this issue for days now, I've determined that REGEXP doesn't play well with unicode characters. Because of this the IF statement keeps writing the same name to playername, even though it's already listed, if it has unicode characters in it.

So... as it stands now, I've changed the code a bit more like the original code. It will only log the last playername the SteamID was seen under, but I'm working on using separate tables to take care of the Name issue. Just have to decide how I'm going to design the other tables, and what other information I'm going to put in there as well. Probably going to implement a Last Seen date at least, but who knows.

Also, if you'll notice above, I changed the SteamID string a bit. I'm not sure why, but on my server it was only inserting every 3rd or 4th person that joined into the DB. Since changing it to GetClientAuthString I'm now catching everyone. Don't know if this was a bug, or just something unnoticed previously.

Here is the new code that is actually working if plugged into the tracker.sp. Not much change from the original, but I thought it needed to be documented. Again... much thanks goes to msleeper. His plugin jumpstarted my thought process.

Code:
    new String:SteamID[32];
    GetClientAuthString(client, SteamID, sizeof(SteamID));

    new String:PlayerName[32];
    GetClientName(client, PlayerName, sizeof(PlayerName));
    
    new String:PlayerIP[32];
    GetClientIP(client, PlayerIP, sizeof(PlayerIP));

    new String:GameType[32];
    GetGameFolderName(GameType, sizeof(GameType));

    new String:ServerIP[32];
    cvar_ServerIP = FindConVar("ip");
    GetConVarString(cvar_ServerIP, ServerIP, sizeof(ServerIP));

    new String:query[512];
    Format(query, sizeof(query), "INSERT INTO player_tracker (steamid, playername, playerip, servertype, serverip, status) VALUES ('%s', '%s', '%s', '%s', '%s', 'new') ON DUPLICATE KEY UPDATE playerip='%s', status='seen', playername='%s';", SteamID, PlayerName, PlayerIP, GameType, ServerIP, PlayerIP, PlayerName);
    SendQuery(query);
}
Rescue9 is offline