[HELP] Problems with a log
#1

Something is wrong with the GetPlayerIP...
pawn Код:
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\PlayerConnectLog.pwn(49) : error 017: undefined symbol "playerid"
pawn Код:
public ConnectLog(string[])
{
    new Year, Month, Day;
    getdate(Year, Month, Day);
   
    new PlayerIP[16];
    GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

    new entry[256];
    format(entry, sizeof(entry), "[%02d.%02d.%d] {%d} %s\r\n",Day, Month, Year, PlayerIP, string);
    new File:hFile;
    hFile = fopen(CONNECT_LOG, io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
Reply
#2

Your callback "ConnectLog" doesn't have a playerid parameter.

pawn Код:
forward ConnectLog(playerid,string[]);
public ConnectLog(playerid,string[])
{
    //Your code
}
//To use
ConnectLog(playerid,"This is going to be logged");
Reply
#3

And if i want to make a ban log?

pawn Код:
#define BAN_LOG     "BanLog/Banned.log"
forward BanLog(string[]);
pawn Код:
public BanLog(string[])
{
    new Year, Month, Day;
    getdate(Year, Month, Day);
   
    new PlayerIP[16];
    GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

    new entry[256];
    format(entry, sizeof(entry), "[%02d.%02d.%d] {%d} %s\r\n",Day, Month, Year, PlayerIP, string);
    new File:hFile;
    hFile = fopen(BAN_LOG, io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
EXAMPLE BAN:
pawn Код:
public OnPlayerSpawn(playerid)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));

    format(string, sizeof(string), "Ban Log: %s(%d) spanwned to fast", name, playerid);
    BanLog(string);
    return 1;
}
Reply
#4

Then its simply:
pawn Код:
public BanLog(playerid, string[])
{
    new Year, Month, Day;
    getdate(Year, Month, Day);
   
    new PlayerIP[16];
    GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

    new entry[256];
    format(entry, sizeof(entry), "[%02d.%02d.%d] {%d} %s\r\n",Day, Month, Year, PlayerIP, string);
    new File:hFile;
    hFile = fopen(BAN_LOG, io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));

    format(string, sizeof(string), "Ban Log: %s(%d) spanwned to fast", name, playerid);
    BanLog(playerid, string); // playerid equals to the playerid of the banned person, make sure to log this before you ban the user!
    return 1;
}
Reply
#5

pawn Код:
How to change the:

playerid

to

i

because im making  a anticheat code atm... and it wont work with playerid...

---argument type mismatch (argument 1)--- If i change to i
Reply
#6

Use a Loop.
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerInRangeOfPoint(i, 15.0, x, y, z)) return SendClientMessage(playerid, COLOR, "Yay! You are in range!");
}
just an example usage.
Reply
#7

Quote:
Originally Posted by Mean
Посмотреть сообщение
Use a Loop.
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerInRangeOfPoint(i, 15.0, x, y, z)) return SendClientMessage(playerid, COLOR, "Yay! You are in range!");
}
just an example usage.
How? :P
Reply
#8

pawn Код:
// Use stocks for functions, not callbacks (unless you're going to use a timer to call the callback)
stock BanLog(playerid, string[])
{
    new Year, Month, Day;
    getdate(Year, Month, Day);
   
    new PlayerIP[16];
    GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));

    new entry[256];
    format(entry, sizeof(entry), "[%02d.%02d.%d] {%s} %s\r\n",Day, Month, Year, PlayerIP, string);
    new File:hFile;
    hFile = fopen(BAN_LOG, io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
What you do is that you simply replace the "playerid" parameter in the code by "i" when calling the function
Reply
#9

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)