PM Dialog pronlem -
RatHack - 27.07.2011
Hello
In this dialog by Mo3 theres a problem. if u insert a bad ID or the player isnt connected it sends the message too
Do u know how to restrict to send the PM is the ID is invalid or the player isnt connected?
pawn Код:
/*
This dialog PM system has been developed by Mo3.
Please keep these credits.
*/
#include <a_samp>
new ReceiverID[MAX_PLAYERS];
new PMfrom[MAX_PLAYERS];
new reply[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
reply[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/pm", true))
{
ShowPlayerDialog(playerid,755,DIALOG_STYLE_INPUT,"Private Message System","Enter the receiverґs ID","Done","Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new s1[264],s2[264],name[24];
if(dialogid == 755)
{
ReceiverID[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,756,DIALOG_STYLE_INPUT,"Private Message System","Enter the text you want to send:","Send","Cancel");
return 1;
}
if(dialogid == 756)
{
if(response == 1)
{
if(reply[playerid] == 0)
{
PMfrom[ReceiverID[playerid]] = playerid;
GetPlayerName(playerid, name, sizeof(name));
format(s1, sizeof(s1), "You have received a new PM from %s\n\n%s",name,inputtext);
format(s2, sizeof(s2), "New PM from %s (%d)",name,playerid);
ShowPlayerDialog(ReceiverID[playerid],757,DIALOG_STYLE_MSGBOX,s2,s1,"Reply","Close");
PlayerPlaySound(ReceiverID[playerid], 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else if(reply[playerid] == 1)
{
PMfrom[ReceiverID[playerid]] = playerid;
GetPlayerName(playerid, name, sizeof(name));
format(s1, sizeof(s1), "You have received a new PM from %s\n\n%s",name,inputtext);
format(s2, sizeof(s2), "New PM from %s (%d)",name,playerid);
ShowPlayerDialog(PMfrom[playerid],757,DIALOG_STYLE_MSGBOX,s2,s1,"Reply","Close");
reply[playerid] = 0;
PlayerPlaySound(PMfrom[playerid], 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
}
return 1;
}
if(dialogid == 757)
{
if(response == 1)
{
ShowPlayerDialog(playerid,756,DIALOG_STYLE_INPUT,"Private Message System","Enter the text you want to send:","Done","Cancel");
reply[playerid] = 1;
return 1;
}
}
return 0;
}
stock GetPlayerID(const Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true)==0)
{
return i;
}
}
}
return -1;
}
Re: PM Dialog pronlem -
FireCat - 27.07.2011
pawn Код:
/*
This dialog PM system has been developed by Mo3.
Please keep these credits.
*/
#include <a_samp>
new ReceiverID[MAX_PLAYERS];
new PMfrom[MAX_PLAYERS];
new reply[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
reply[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/pm", true))
{
ShowPlayerDialog(playerid,755,DIALOG_STYLE_INPUT,"Private Message System","Enter the receiverґs ID","Done","Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new s1[264],s2[264],name[24];
if(dialogid == 755)
{
if(IsPlayerConnected(strval(inputtext)) return SendClientMessage(playerid,color,"That player is not connected");
ReceiverID[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,756,DIALOG_STYLE_INPUT,"Private Message System","Enter the text you want to send:","Send","Cancel");
return 1;
}
if(dialogid == 756)
{
if(response == 1)
{
if(reply[playerid] == 0)
{
PMfrom[ReceiverID[playerid]] = playerid;
GetPlayerName(playerid, name, sizeof(name));
format(s1, sizeof(s1), "You have received a new PM from %s\n\n%s",name,inputtext);
format(s2, sizeof(s2), "New PM from %s (%d)",name,playerid);
ShowPlayerDialog(ReceiverID[playerid],757,DIALOG_STYLE_MSGBOX,s2,s1,"Reply","Close");
PlayerPlaySound(ReceiverID[playerid], 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else if(reply[playerid] == 1)
{
PMfrom[ReceiverID[playerid]] = playerid;
GetPlayerName(playerid, name, sizeof(name));
format(s1, sizeof(s1), "You have received a new PM from %s\n\n%s",name,inputtext);
format(s2, sizeof(s2), "New PM from %s (%d)",name,playerid);
ShowPlayerDialog(PMfrom[playerid],757,DIALOG_STYLE_MSGBOX,s2,s1,"Reply","Close");
reply[playerid] = 0;
PlayerPlaySound(PMfrom[playerid], 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
}
return 1;
}
if(dialogid == 757)
{
if(response == 1)
{
ShowPlayerDialog(playerid,756,DIALOG_STYLE_INPUT,"Private Message System","Enter the text you want to send:","Done","Cancel");
reply[playerid] = 1;
return 1;
}
}
return 0;
}
stock GetPlayerID(const Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true)==0)
{
return i;
}
}
}
return -1;
}
If it works give me rep
Respuesta: PM Dialog pronlem -
RatHack - 27.07.2011
pawn Код:
C:\Users\Valentino\Desktop\Rat's propiety\0.3b Server Samp1\gamemodes\DS.pwn(3627) : error 001: expected token: ")", but found "return"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
And i need too, if the player doesn't write anything in the box, the message could not be send.
Re: PM Dialog pronlem -
=WoR=Varth - 28.07.2011
pawn Код:
if(strlen(inputtext) == 0) return blahblahblah
Re: PM Dialog pronlem -
dowster - 28.07.2011
Use sscanf, you can input the players name or id.
Respuesta: PM Dialog pronlem -
RatHack - 28.07.2011
Okey
And if the player doesn't write anything in the box, it says You didnt enter any message
How to make that?
Re: PM Dialog pronlem -
Kingunit - 28.07.2011
pawn Код:
if(strlen(inputtext) == 0) return SendClientMessage(playerid, COLOR_WHITE, "You didn't typed anything.")
Respuesta: PM Dialog pronlem -
RatHack - 28.07.2011
Where to put that?