Send a Message only once
#1

Hello I just made a PM system and I added a ClientMessage when a player PMs the another the other player will receive a message like "You can use /r to quiucly respond" but it sending every time the other player receiving all the time this message and the chat is getting spammed

Is there any way to make the message sending only the first time?
Reply
#2

At the top of your script create a new variable

Код:
new ReplyNotification[MAX_PLAYERS]; //Every player now has a "ReplyNotification" variable available
Then you will need to give this variable a default value. Under OnPlayerConnect, set ReplyNotificatio equal to 1 (this will be the default)

Код:
Public OnPlayerConnect(playerid){
     ReplyNotification[playerid] = 1; // Defaults set to 1
     return 1;
}
Now you can use this variable inside your PM code. So, this would proabbly be at a PM command?

The code which says "use /r for quick response" needs to be wrapped in an If Statment, checking against the ReplyNotification.... see the code below

Код:
CMD:pm(playerid, params[]){
     
    //CODE GOES HERE WHICH DOES PM STUFF

     if(ReplyNotification[targetid] == 1){
          ReplyNotification[targetid] = 0; // Sets to 0, this will prevent this message being sent in the future
          SendClientMessage(targetid, COLOR, "Did you know? That you can use /r to reply quickly to PMs");
     }
     return 1;
}
And thats it.

Ive used targetid instead of playerid as it would probably be the player that your sending the PM to, which is told to use /r rather than the player who sends the first message.


Hope that makes sense?
Reply
#3

Quote:
Originally Posted by Darrenr
Посмотреть сообщение
At the top of your script create a new variable

Код:
new ReplyNotification[MAX_PLAYERS]; //Every player now has a "ReplyNotification" variable available
Then you will need to give this variable a default value. Under OnPlayerConnect, set ReplyNotificatio equal to 1 (this will be the default)

Код:
Public OnPlayerConnect(playerid){
     ReplyNotification[playerid] = 1; // Defaults set to 1
     return 1;
}
Now you can use this variable inside your PM code. So, this would proabbly be at a PM command?

The code which says "use /r for quick response" needs to be wrapped in an If Statment, checking against the ReplyNotification.... see the code below

Код:
CMD:pm(playerid, params[]){
     
    //CODE GOES HERE WHICH DOES PM STUFF

     if(ReplyNotification[targetid] == 1){
          ReplyNotification[targetid] = 0; // Sets to 0, this will prevent this message being sent in the future
          SendClientMessage(targetid, COLOR, "Did you know? That you can use /r to reply quickly to PMs");
     }
     return 1;
}
And thats it.

Ive used targetid instead of playerid as it would probably be the player that your sending the PM to, which is told to use /r rather than the player who sends the first message.


Hope that makes sense?
Its working thanks for helping
Reply
#4

Or you can use just the one variable that you use to store the person who was the last to send a PM.

Example:
pawn Код:
// When a player receives a PM
if(LastPM[targetid] == INVALID_PLAYER_ID) SendClientMessage(targetid, -1, "You can use /r to quickly respond to PMs");
LastPM[targetid] = playerid; // playerid was the last to message targetid.
Reset LastPM[playerid] to INVALID_PLAYER_ID on OnPlayerConnect/Disconnect. Simple.
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Or you can use just the one variable that you use to store the person who was the last to send a PM.

Example:
pawn Код:
// When a player receives a PM
if(LastPM[targetid] == INVALID_PLAYER_ID) SendClientMessage(targetid, -1, "You can use /r to quickly respond to PMs");
LastPM[targetid] = playerid; // playerid was the last to message targetid.
Reset LastPM[playerid] to INVALID_PLAYER_ID on OnPlayerConnect/Disconnect. Simple.
Anyway I made it, can I ask and something other? How can I add a second case on Dialogs?

I mean for ex I have a /cmds command that which shows you some themes like "House Commands,General Commands" etc and I want to add a second page on General Commands how can I do this

I want to do this with "next" button
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)