SA-MP Forums Archive
Send a Message only once - 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: Send a Message only once (/showthread.php?tid=578176)



Send a Message only once - SecretBoss - 17.06.2015

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?


Re: Send a Message only once - Darrenr - 17.06.2015

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?


Re: Send a Message only once - SecretBoss - 17.06.2015

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


Re: Send a Message only once - Threshold - 17.06.2015

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.


Re: Send a Message only once - SecretBoss - 17.06.2015

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