new File:ip = fopen("ip.log", io_readwrite); new string[100], pName[24], pIp[20]; if(ip) { GetPlayerName(playerid, pName, sizeof(pName)); GetPlayerIp(playerid, pIp, sizeof(pIp)); format(string, sizeof(string), "%s - %s \n", pIp, pName); fwrite(ip, string); fclose(ip); }
new File:ip = fopen("ip.log", io_readwrite);
new string[100], pName[24], pIp[20];
if(ip)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerName(i, pName, sizeof(pName));
GetPlayerIp(i, pIp, sizeof(pIp));
format(string, sizeof(string), "%s - %s \n", pIp, pName);
fwrite(ip, string);
fclose(ip);
}
}
Originally Posted by Ash0153
Hello.
I've found this script to save a player's IP to a file: Код:
new File:ip = fopen("ip.log", io_readwrite); new string[100], pName[24], pIp[20]; if(ip) { GetPlayerName(playerid, pName, sizeof(pName)); GetPlayerIp(playerid, pIp, sizeof(pIp)); format(string, sizeof(string), "%s - %s \n", pIp, pName); fwrite(ip, string); fclose(ip); } Credits go to ZeroBurn who permits to code to be used by anyone. Thank you in advance! |
new File:ip = fopen("ip.log", io_readwrite); new string[100], pName[24], pIp[20]; if(ip) { for(new i = 0; i < MAX_PLAYERS; i++) { GetPlayerName(i, pName, sizeof(pName)); GetPlayerIp(i, pIp, sizeof(pIp)); format(string, sizeof(string), "%s - %s \n", pIp, pName); fwrite(ip, string); } fclose(ip); }
Originally Posted by Ash0153
Kaisersouse, yours' repeats the saved data about 100 times inside the file.
Testing yours now Karlip. Thanks for the replies =] |
if(ip { if(IsPlayerConnected(i)) { everything else
Originally Posted by Karlip
Quote:
Do you want it to save on connect? |
Originally Posted by kaisersouse
ugh im used to using foreach which has built-in IsPlayerConnected. Sorry
Код:
if(ip { if(IsPlayerConnected(i)) { everything else |
if(ip)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
// Blah
}
}
}
forward KickLog(string[]);
public IpLog(string[])
{
new entry[256];
format(entry, sizeof(entry), "%s\r\n",string);
new File:hFile;
hFile = fopen("ip.log", io_append);
if (hFile){
fwrite(hFile, entry);
fclose(hFile);
}
}
public OnPlayerConnect(playerid)
{
new string[100], pName[24], pIp[20];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerIp(playerid, pIp, sizeof(pIp));
format(string, sizeof(string), "%s - %s \n", pIp, pName);
IpLog(string);
return 1;
}