#1

Hello I wanted to ask that i dont get logs in my server of every thing I just get logs fot the local chat how can I get all logs like /b /do /g etc
Reply
#2

Use printf
https://sampwiki.blast.hk/wiki/Printf
Reply
#3

pawn Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Usage]: /pm [playerid] [message]");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: You cannot pm yourself!");
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
    SendClientMessage(id, COLOR_YELLOW, str);
    return 1;
}
Can some 1 do 1 for me please my pm cmd
Reply
#4

Note the last 2 lines

pawn Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Usage]: /pm [playerid] [message]");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: You cannot pm yourself!");
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
    SendClientMessage(id, COLOR_YELLOW, str);
   
    format(str, sizeof(str), "PM From %s(ID %d) to %s(ID %d) %s", Name1, playerid,Name2,id, str2);
    printf(str);

    return 1;
}
Reply
#5

use a simple cords;

pawn Код:
if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Usage]: /pm [playerid] [message]");
        return 1;
    }
//to
if(sscanf(params, "us[128]", id, str2)) return SendClientMessage(playerid, COLOR_GREY, "[Usage]: /pm [playerid] [message]");
Reply
#6

Do you want logs to be written in specific .txt file?
If so, use:
pawn Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, COLOR_GREY, "[Usage]: /pm [playerid] [message]");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFFFF00AA, "ERROR: You cannot pm yourself!");
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
    SendClientMessage(id, COLOR_YELLOW, str);
    new File:log = fopen("/ServerLog.txt", io_append); // Open the file and prepares for writing inside
    format(str, sizeof(str), "PM From %s to %s: %s\r\n", Name1, Name2, str2);//makes string that will be printed
    fwrite(log, str); // Write to the file (\r\n is for a new line)printing the string
    fclose(log); // Close the file
    return 1;
}
and the file will be in your scriptfiles folder
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)