CMD:aka(playerid,params[])
{
new pID;
if(!sscanf(params,"u",pID)) return SendClientMessage(playerid,-1,"/aka (playerid)");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,-1,"Invalid playerid");
new accounts[*][MAX_PLAYER_NAME],string[256]; //change * to the maximum number of names you want to retrieve.
AKA(playerid,accounts);
if(accounts[0][0] == '\0') return SendClientMessage(playerid,-1,"This Player has no mutli accounts!");
for(new i; i<sizeof(accounts); i++)
{
if(accounts[i][0] == '\0') break;
format(string,sizeof(string),"%sPlayerName: %s\n",string,accounts[i]);
}
return ShowPlayerDialog(playerid,999,DIALOG_STYLE_MSGBOX,"All Player Accounts",string,!"Okay",!"");
}
#if !defined _samp_included
#error samp is not included
#endif
#if defined _AKA
#endinput
#endif
#define _AKA
static DB:database;
LoadAKADatabase()
{
database = db_open("aka.db");
db_query(database,"CREATE TABLE IF NOT EXISTS `akas` (`Username`,`Ip`)");
}
InitAKAOnConnect(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
new ip[16],name[MAX_PLAYER_NAME],DBResult:result,string[128];
GetPlayerIp(playerid,ip,16);
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof(string),"SELECT `Ip` FROM `akas` WHERE `Username`='%s'",name);
result = db_query(database,string);
switch(db_num_rows(result))
{
case 0: format(string,sizeof(string),"INSERT INTO `akas` (`Username`,`Ip`) VALUES ('%s','%s')",name,ip);
default: format(string,sizeof(string),"UPDATE `akas` SET `Ip`='%s' WHERE `Username`='%s'",ip,name);
}
db_free_result(result);
db_query(database,string);
return 1;
}
stock AKA(playerid,accs[][],const size=sizeof(accs))
{
new ip[16],name[MAX_PLAYER_NAME],DBResult:result,string[128],rows;
GetPlayerIp(playerid,ip,16);
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof(string),"SELECT `Username` FROM `akas` WHERE `Ip`='%s'",ip);
result = db_query(database,string);
rows = db_num_rows(result);
if(rows>1)
{
for(new i,j; i<rows; i++)
{
if(j==size) break;
db_get_field(result,0,accs[j++],MAX_PLAYER_NAME);
db_next_row(result);
}
}
return db_free_result(result);
}
|
You should escape the player names (%q), or else an SQL Injection might occur.
Also, read this: https://sampforum.blast.hk/showthread.php?tid=570910 If you convert to that (Which would eliminate the need to add stuff to the script like InitAKA and LoadAKA), make sure to check if FILTERSCRIPT is defined, so you'd do it under OnFilterScriptInit, if not, under OnGameModeInit |
|
http://forum.sa-mp.com/showpost.php?...postcount=4569
Use ipmatch to detect similar IPs, because this is the main purpose of AKA. Your code just checks accounts registered on same IPs not similar. So in case of IP match, you have to: go through all rows > get their IP > use ipmatch > store matched ones. |