02.07.2011, 18:14
Hello there,
I've been working on a /pm command using sscanf and zcmd and I bumped into something that I cant figure out quite yet.
The problem is with players that have similar nicknames.
For example, John(1) and John32(2).
The command works if you send a pm with the id instead of name.
Now with this example, when sending a pm with their names or part of their names, it will only send to John, even when typing John32.
I've been scratching my head for a while now and I would appreciate it if someone would help me with coming up with some kind of code
for distinguishing similar nicknames in a similar manner to this:
Here is the code for reference:
I've been working on a /pm command using sscanf and zcmd and I bumped into something that I cant figure out quite yet.
The problem is with players that have similar nicknames.
Код:
if(!sscanf(params, "us["#STR_SIZE"]", id, message))
The command works if you send a pm with the id instead of name.
Now with this example, when sending a pm with their names or part of their names, it will only send to John, even when typing John32.
I've been scratching my head for a while now and I would appreciate it if someone would help me with coming up with some kind of code
for distinguishing similar nicknames in a similar manner to this:
Код:
if(similarnames) { SendClientMessage(playerid, 0xFF0000FF, "Too many similar names, please indicate id."); } else { }
Код:
#include <a_samp> #include <sscanf2> #include <zcmd> #define STR_SIZE 128 CMD:pm(playerid, params[]) { new id, Sender[MAX_PLAYER_NAME], Receiver[MAX_PLAYER_NAME]; new string[90], string2[90],message[STR_SIZE]; if(!sscanf(params, "us["#STR_SIZE"]", id, message)) { if(id != INVALID_PLAYER_ID) { if(playerid == id) { SendClientMessage(playerid, 0xFF0000FF, "You can't message yourself!"); } else { GetPlayerName(playerid, Sender, sizeof(Sender)); GetPlayerName(id, Receiver, sizeof(Receiver)); format(string, sizeof(string), "PM: %s(%i): %s", Receiver, id, message); SendClientMessage(playerid, 0xFFE600AA, string); format(string2, sizeof(string2), "PM: %s(%i): %s", Sender, playerid, message); SendClientMessage(id, 0xFFE600AA, string2); } } else { SendClientMessage(playerid, 0xFF0000FF, "Player not Connected."); } } else { SendClientMessage(playerid, 0xFF0000FF, "Use: /pm [ID] [Message]"); } return 1; }