PM command crashing server
#1

This command is supposed to send a message to another player, and to admins so they can see it for safety.
But it crashes the server for some reason, no warnings in the script, and it looks to work for me.
pawn Код:
CMD:pm(playerid, params[])
{
    new targetid, text[128], string[128];
    if(sscanf(params, "s[128]", targetid, text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pm [playerid] [text]");
    if(PmOff[targetid] == 1) return SendClientMessage(playerid, COLOR_GREY, "Player has disabled Private Messages.");
    if(PmOff[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You have disabled Private Messages, /toggle pm to enable them.");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "That player is not connected.");
    format(string, sizeof(string), "** PM to %s (ID: %i): %s", GetName(targetid), targetid, text);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), "** PM from %s (ID: %i): %s", GetName(playerid), playerid, text);
    SendClientMessage(targetid, COLOR_YELLOW, string);
    format(string, sizeof(string), "** PM %s (%i) > %s (%i): %s", GetName(playerid), playerid, GetName(targetid), targetid, text);
    SendAdminMessage(2, COLOR_GREY, string);
    return 1;
}
Reply
#2

This
Quote:
Originally Posted by CalvinC
Посмотреть сообщение
pawn Код:
if(sscanf(params, "s[128]", targetid, text))
must be
pawn Код:
if(sscanf(params, "us[128]", targetid, text))
Reply
#3

What does that s, us, u, ui and such even do? What's the difference?
That part is something i took from an old script because im not sure how to make a function that detects when he doesn't write the needed params.
Reply
#4

read more about ssacnf
https://github.com/Y-Less/sscanf/wiki


u = PlayerID and PlayerName
s = string
i = integer
Reply
#5

In your case u == targetid, s == text.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)