PM to specific username.
#1

Hello,
I am a rookie Or not even scripter. I would like to know what i should do to make a CMD to send a PM to a specific username.
like /se7evolution [text]. will be send to se7evolution and he will see a message like this
Player %:_______________________

What i mean is not /PM [id/name] [text] but /playername [text].

I am really sorry if my english isn't good at all at explaining.

Hope you understand me.
Se7evolution
Reply
#2

You could make such a command I think, although I really, really wouldn't recommend it.
Keep in mind you'll be creating commands to the amount of your player base (Which could be well over 800, but that is doubtful).

As result, it's way better to make a /pm command, that's only one thing to check for on user input. It just generally is way faster and less prone to duplicate commands (E.g., you have a command /test, a player with the name test joins, then you'll have two test commands, to avoid this, you should add return 1;, but generally, this is really not recommended).

Additionally, to achieve what you want to achieve. I think you would need something like this:
Note, I have not myself tested this code.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new name[MAX_PLAYER_NAME]; //Create a new name variable that temporarily holds every players' name.
  for (new i=0; i < MAX_PLAYERS; i++)  //initiate a loop to check all players
  {
    if (IsPlayerConnected(i)) //Is the player connected?
    {
       GetPlayerName(i, name, MAX_PLAYER_NAME); //Fetch the player name for comparison
       if (!strcmp(cmdtext, name, true)) SendClientMessage(i, -1, "Hello!"); //If the command matches the name, we send him a message "Hello!"
    }
  }
  return 1;
}
Reply
#3

Quote:
Originally Posted by BuuGhost
Посмотреть сообщение
You could make such a command I think, although I really, really wouldn't recommend it.
Keep in mind you'll be creating commands to the amount of your player base (Which could be well over 800, but that is doubtful).
Dafuq is that supposed to mean? If there are 800 dynamic commands then there aren't 800 actual commands.
Reply
#4

would sscanf2 used in the OnPlayerText() work? i dont like the idea either btw, but attepting to
pawn Код:
sscanf(inputtext,"'/'uS(Hello World!)[120]",playerid,message)
instead using it in a command could work.
if you want to fuck it up compledetly, use my fingerprint include, then you never know who you send a PM when you do some typos, trolol
Reply
#5

We understand you very well but, why not just the /mp command. Its even easier because you won't have to type the player's name. (Some of the time people choose very weird names like [The]Killer52, ToHooo!, [P]ardo[C]ity$, 2426kevin2426. I got this names on my server. :/)
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Dafuq is that supposed to mean? If there are 800 dynamic commands then there aren't 800 actual commands.
It all depends on how many players are connected, in the end, if your server ends up having 800 players, you'll have 800 dynamic commands, never the less, the script still loops through every "id" of a possible player on every command, because it uses MAX_PLAYERS as maximum value, if you set MAX_PLAYERS to be 800 anyways.

The point is, it won't work well and I do not recommend it.

Quote:

If there are 800 dynamic commands then there aren't 800 actual commands

Theoritically, yes, there will be? You're still making the check. They may not exist but they definitely do get checked for. If they don't exist, it will run past it faster, but you're still making the check if it exists. In the end, 1 command is faster than 800 possibilities of dynamic commands.

Quote:
Originally Posted by Babul
Посмотреть сообщение
would sscanf2 used in the OnPlayerText() work? i dont like the idea either btw, but attepting to
pawn Код:
sscanf(inputtext,"'/'uS(Hello World!)[120]",playerid,message)
instead using it in a command could work.
if you want to fuck it up compledetly, use my fingerprint include, then you never know who you send a PM when you do some typos, trolol
I'm pretty sure only OnPlayerCommandText gets called when you prepend something with an /, so, no. You could do this with a # symbol for example, though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)