View Single Post
Rescue9
Junior Member
Join Date: Apr 2009
Old 10-17-2009 , 00:03   Re: Basic Player Tracker
Reply With Quote #4

I've been rewriting a bit of this. It is broken, but a work in progress.

The changed code is as such (from line 86 of above tracker.sp):
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=IF( playername like '%%s%', playername, CONCAT_WS(', ', playername, '%s'));", SteamID, PlayerName, PlayerIP, GameType, ServerIP, PlayerIP, PlayerName, PlayerName);
    SendQuery(query);
}
This basically updates playername with PlayerName only if PlayerName isn't already in playername. My problem is this section:
Code:
playername like '%%s%',
Basically, mysql needs the two % to match the name. So, when it hits the sql server, if the players name were Bob, I'd need it to say:
Code:
playername like '%Bob%',
Any suggestions.
Rescue9 is offline