User ip adress - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: User ip adress (
/showthread.php?tid=87417)
User ip adress -
lilstuh - 20.07.2009
hey guys.
can someone give me a code for --- onplayerdisconnect ip adress for admins to see
like so when a players leaves, admins will be able to see a persons ip adress.
example: Michael left [123.245.2.32]
Re: User ip adress -
saiberfun - 20.07.2009
pawn Код:
//ontop of script
forward SendClientMessageToAdmins(color,string[]);
public SendClientMessageToAdmins(color,string[])//sumwhere in script
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
{
SendClientMessage(i, color, string);
printf("%s", string);
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid,reason);
{
new ip[128];
new str[256];
new name[256];
GetPlayerName(playerid,name,sizeof(name);
GetPlayerIP(playerid,ip,sizeof (ip);
format(str,256,"%s[%s] left the server.",name,ip);
SendClientMessageToAdmins(yourcolor,str);
return 1;
}
didn't test it yet tho
tell me if it works^^
Re: User ip adress -
Grim_ - 20.07.2009
Код:
new ip[128];
new str[256];
new name[256];
O.o talk about useless cells.
It should look like this instead:
pawn Код:
new ip[16];
new str[128];
new name[MAX_PLAYER_NAME];
Re: User ip adress -
Correlli - 20.07.2009
If you're going to get player's ip at OnPlayerDisconnect callback then it won't work, because there is a bug if you want to get player's ip at OnPlayerDisconnect, it will always show ip 255.255.255.255.
Re: User ip adress -
Grim_ - 20.07.2009
I'm guessing that doesn't happen all the time? Oh well, I may be wrong, but here's a possible solution:
pawn Код:
//top of script
new PlayerIP[MAX_PLAYERS];
//OnPlayerConnect
ip[16];
PlayerIP[playerid] = GetPlayerIp(playerid, ip, sizeof ip);
//OnPlayerDisconnect
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
format(str, sizeof str, "%s has left the server! (IP: %d)", name, PlayerIP[playerid]);
SendClientMessage(i, color, str);
}
}
-- untested
Re: User ip adress -
Correlli - 20.07.2009
Quote:
Originally Posted by Swift_
I'm guessing that doesn't happen all the time? Oh well, I may be wrong, but here's a possible solution:
|
All the time. So the solution is other callback like you did.
Re: User ip adress -
lilstuh - 20.07.2009
it says that:
symbol already defined: "GetPlayerName"
Line: ip[16]; error 010: invalid function or declaration
line: for(new i = 0; i<MAX_PLAYERS; i++) error 010: invalid function or declaration
Line: if(IsPlayerAdmin(i)) error 010: invalid function or declaration
Re: User ip adress -
XPlatform - 20.07.2009
Just get the ip when the player connects, store it somewhere, and when they disconnect, show it again.
Re: User ip adress -
Grim_ - 20.07.2009
I could have sworn I just did that but showed him in code, next time read before posting.
Re: User ip adress -
lilstuh - 20.07.2009
so what about all these errors?