Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock LoadPlayerAka(playerid,id=1,name[]="none")
- {
- new mysqlquery[124];
- mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "SELECT ip,username FROM aka WHERE username = '%e' OR ip = '%e'", PlayerInfo[playerid][pUserName], PlayerInfo[playerid][pIP]);
- print(mysqlquery);
- if(id == 1) return mysql_pquery(g_SQL, mysqlquery,"OnAkaLoad", "d", playerid);
- else if(id == 2) return mysql_pquery(g_SQL, mysqlquery,"GetPlayerIPs", "ds", playerid,name); //using this to load aka for even offline players
- return 1;
- }
- forward OnAkaLoad(playerid); //forward
- public OnAkaLoad(playerid) // public
- {
- new mysqlquery[124], //storing mysql format
- name[MAX_PLAYER_NAME], // storing the name in row
- ip[16], //storing the ip in row
- namerow=-1, // will store where the name was found
- iprow=-1; // will store where the ip was found
- for(new i, j = cache_get_row_count(g_SQL); i < j; i++) // loop through all the rows that were found
- {
- cache_get_field_content(i, "username", name, g_SQL, MAX_PLAYER_NAME); // this will get the username from the current row
- cache_get_field_content(i, "ip", ip, g_SQL, MAX_PLAYER_NAME); //this will get the ip from the current row
- printf("Got row %d with name %s",i,name); // just for my own testing
- if(strcmp(name,PlayerInfo[playerid][pUserName]) == 0) // the will match if the name from that field matches player name
- {
- printf("Name Matched in row %d with name %s",i,name); // just for my own testing
- namerow=i; // will store player name row
- }
- if(strcmp(ip,PlayerInfo[playerid][pIP]) == 0) //this will match if the ip from player matches the one in row
- {
- printf("IP Matched in row %d with name %s",i,name); // just for my own testing
- iprow=i; // will store player ip row
- }
- if(namerow == iprow) // this will check if the player name row and ip row are same
- {
- break; // as they are same no need to do anything further
- }
- }
- if(namerow == -1) // will check if any row with that name was founded or not
- {
- mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "INSERT INTO aka SET ip='%e',username='%e';",PlayerInfo[playerid][pIP],PlayerInfo[playerid][pUserName]);
- print(mysqlquery);
- mysql_pquery(g_SQL,mysqlquery); //no row with that name so inserting the aka
- }
- else if(iprow == -1) //will check if any row with that ip was founded or not
- {
- mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "INSERT INTO aka SET ip='%e',username='%e';",PlayerInfo[playerid][pIP],PlayerInfo[playerid][pUserName]);
- print(mysqlquery);
- mysql_pquery(g_SQL,mysqlquery); // no row with this ip inserting the aka
- }
- else if(namerow != iprow) // will check if this ip was also stored for the name we are checking
- {
- mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "INSERT INTO aka SET ip='%e',username='%e';",PlayerInfo[playerid][pIP],PlayerInfo[playerid][pUserName]);
- print(mysqlquery);
- mysql_pquery(g_SQL,mysqlquery); // updating the aka.
- }
- return 1;
- }
- forward GetPlayerIPs(playerid,TargetName[]);
- public GetPlayerIPs(playerid,TargetName[])
- {
- new string[124],name[MAX_PLAYER_NAME],ip[16];
- format(string,sizeof(string),""ORANGE"%s "ADMIN"IPs : "ORANGE"",TargetName);
- for(new i, j = cache_get_row_count(g_SQL); i < j; i++)
- {
- cache_get_field_content(i, "username", name, g_SQL, MAX_PLAYER_NAME);
- if(strcmp(name,TargetName) == 0)
- {
- cache_get_field_content(i, "ip", ip, g_SQL, MAX_PLAYER_NAME);
- format(string,sizeof(string),"%s%s | ",string,ip);
- }
- }
- SendClientMessage(playerid,COLOR_ADMIN,string);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement