PM command crashing server - 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)
+--- Thread: PM command crashing server (
/showthread.php?tid=556086)
PM command crashing server -
CalvinC - 09.01.2015
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;
}
Re: PM command crashing server -
bgedition - 09.01.2015
This
Quote:
Originally Posted by CalvinC
pawn Код:
if(sscanf(params, "s[128]", targetid, text))
|
must be
pawn Код:
if(sscanf(params, "us[128]", targetid, text))
Re: PM command crashing server -
CalvinC - 09.01.2015
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.
Re: PM command crashing server -
JeaSon - 09.01.2015
read more about ssacnf
https://github.com/Y-Less/sscanf/wiki
u = PlayerID and PlayerName
s = string
i = integer
Re: PM command crashing server -
bgedition - 09.01.2015
In your case u == targetid, s == text.