Help with pm command. -
ZToPMaN - 25.02.2016
I don't have errors, but it's not working.
Help!
CMD
m(playerid, params[])
{
new id;
new message[600], str[1000];
new name[MAX_PLAYER_NAME];
new tname[MAX_PLAYER_NAME];
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "ERROR:This player isn't in game.");
if(sscanf(params, "us", id, message)) return SendClientMessage(playerid, -1 , "Server: Usage, /pm [id] [message]");
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, tname, sizeof(tname));
format(Jstring, sizeof(Jstring), "Server: You had sent a private message to %s(%d): %s ", tname , id , message);
format(str, sizeof(str), "%s(%d) had sent you a private message: %s ", name , playerid, message);
SendClientMessage(id, -1, Jstring);
SendClientMessage(playerid, -1 , str);
return 1;
}
Re: Help with pm command. -
EiresJason - 25.02.2016
Quote:
Originally Posted by ZToPMaN
post
|
Make sure you always put code snippets into [.pawn] [/pawn] tags (remove the full stop in the first tag).
Also, reduce the size of your strings as they're unnecessarily large.
You need to check if the player is connected after calling the sscanf function (otherwise the value of 'id' is always 0 and will not correctly represent the player you want to message).
pawn Код:
CMD:pm(playerid, params[])
{
new id;
new message[128], string[200]; // reduce the size of the string if needed
new name[MAX_PLAYER_NAME];
new tname[MAX_PLAYER_NAME];
if(sscanf(params, "us", id, message)) return SendClientMessage(playerid, -1 , "Server: Usage, /pm [id]
[message]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "ERROR:This player isn't in game.");
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, tname, sizeof(tname));
format(string, sizeof(string), "To %s (%d): %s ", tname , id , message);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "From %s (%d): %s", name , playerid, message);
SendClientMessage(playerid, -1 , string);
return 1;
}
Re: Help with pm command. -
ZToPMaN - 25.02.2016
Hey, it still not working.
When ever i say /pm [any id except my id any online player , it says /pm id message.
also, when i told my friend to come ig and i was tring to use it, it was not working also.
Re: Help with pm command. -
lulo356 - 25.02.2016
PHP код:
CMD:pm(playerid, params[])
{
new str2[128], id;
if(sscanf(params, "us[128]", id, str2)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm [ID] [MESSAGE]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_WHITE, "Player Isnt Connected");
new Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, Name1, sizeof(Name1));
GetPlayerName(id, Name2, sizeof(Name2));
format(str, sizeof(str), "((PM To %s: %s))", Name2, str2);
SendClientMessage(playerid, COLOR_YELLOW, str);
format(str, sizeof(str), "((PM From %s: %s))", Name1, str2);
SendClientMessage(id, COLOR_YELLOW, str);
return 1;
}
Replace this with your command
Re: Help with pm command. -
ZToPMaN - 25.02.2016
I know now what's the problem.
I checked the logs, and i found this error with sscanf, can any one tell me how can i fix this?
pawn Код:
[01:41:34] sscanf error: System not initialised.
Re: Help with pm command. -
Crystallize - 25.02.2016
If you get this error, you need to make sure that you have recompiled ALL your scripts using the LATEST version of "sscanf2.inc". Older versions didn't really require this as they only had two natives - "sscanf" and "unformat", the new version has some other functions - you don't need to worry about them, but you must use "sscanf2.inc" so that they are correctly called. If you think you have done this and STILL get the error then try again - make sure you are using the correct version of PAWNO for example.
Re: Help with pm command. -
ZToPMaN - 26.02.2016
It's working now, thanks alot all!.