PDA

View Full Version : /viewaliases - Help Please.


Eric
18/01/2012, 09:34 PM
Heya' guys.

I'm attempting to make a command that will get the players IP from the SQL, and compare it to all of the other accounts IP addresses.

If there is more then one account with the same IP address, it will relay the account names to the administrator that typed the command.

Here is what I have so far;


CMD:viewaliases(playerid,params[]) {
if(playerVariables[playerid][pAdminLevel] >= 3) {
new targetid,
string[128];

if(sscanf(params, "u", targetid))
return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/viewaliases [playerid]");

format(string, sizeof(string), "Players IP: %s", playerVariables[targetid][pConnectionIP]);
SendClientMessage(playerid, COLOR_GREY, string);

mysql_query("SELECT playerIP FROM `playerAccounts` WHERE playerID='%d'", playerVariables[playerid][pInternalID]);
}
else {
return SendClientMessage(playerid, COLOR_GREY, "You are not a senior administrator.");
}
return 1;
}


I can't figure out how to make it check if the other accounts have the same IP address.
Could somebody please help? Thanks!

milanosie
18/01/2012, 10:03 PM
Uhmm Im making the same thing. So let me think for a while and I will give you my script for this when its done:)
U using mysql as saving right?

Eric
18/01/2012, 10:09 PM
Uhmm Im making the same thing. So let me think for a while and I will give you my script for this when its done:)
U using mysql as saving right?


Yes, I am.
Thanks!

milanosie
18/01/2012, 10:24 PM
Well I guess we could kinda work together on this one. I do know that we probably need to create a separate file where it calls the file to the IP adress. then maybe add all players wich use that ip adress to that file when they login.. and on the cmd /viewalias [playerid] it would have to search trough all files wich would be slow. but this could be faster if u save the IP adress in the player file, then it searches for the file with the same name as the IP adress saved for the player.. U might need to read this 3 times to understand what I mean hehe:P

GamingTurf
18/01/2012, 10:30 PM
SELECT `name` FROM `users` WHERE `ip` LIKE '%s'

or

SELECT `name` FROM `users` WHERE `ip` = '%s'

Eric
18/01/2012, 10:31 PM
SELECT `name` FROM `users` WHERE `ip` LIKE '%s'

or

SELECT `name` FROM `users` WHERE `ip` = '%s'

How would we put that into a string, then?

milanosie
18/01/2012, 10:33 PM
hmm. I dont really use mysql myself but I know how to use it.
It is a good idea, just show a list of people with the same ip using the foreach function?

GamingTurf
18/01/2012, 10:34 PM
while(mysql_fetch_row(query))
{
format(msg,sizeof(msg),"%s\n",namefound);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, title, msg, "Select", "Back");

Edit that to your needs. It will display all users with 'LIKE' or 'EQUAL' to the IP, and list in the dialog.

Obviously you need to define all the other stuff.

Eric
18/01/2012, 10:35 PM
while(mysql_fetch_row(query))
{
format(msg,sizeof(msg),"%s\n",namefound);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, title, msg, "Select", "Back");

Edit that to your needs. It will display all users with 'LIKE' or 'EQUAL' to the IP, and list in the dialog.

Obviously you need to define all the other stuff.

That's all I needed. Thanks!

Not sure if I can give rep, but if I can I'm giving both of you guys rep for helping out. <3

Eric
18/01/2012, 10:46 PM
while(mysql_fetch_row(query))
{
format(msg,sizeof(msg),"%s\n",namefound);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, title, msg, "Select", "Back");

Edit that to your needs. It will display all users with 'LIKE' or 'EQUAL' to the IP, and list in the dialog.

Obviously you need to define all the other stuff.

Alright, I actually have one more question.

I'm trying to figure out how I would apply your given code to my script;
I'm not exactly sure what to do with while(mysql_fetch_row(query)).

Would I put the query into the brackets, or would I apply the query to a string, and put the string in there? Or does it even matter?

In any case, in trying to do this, I came up with this. Please provide some insight as to whether this is correct or not. Thanks!


format(queryString, sizeof(queryString), "SELECT `playerName` FROM `playerAccounts` WHERE `playerIP` = '%s'", playerVariables[targetid][pConnectionIP]);
while(mysql_fetch_row(queryString)) {
format(string, sizeof(string), "%s", namefound);
}


And if that is correct- what would I enter for the variable, where namefound is? I don't see the name, if it is found, being applied to a variable, and I'm unsure where to do that.