OnPlayerDeath && ShowPlayerDialog issue -
OsmanMalagic - 14.05.2018
I have some issue with onplayerdeath and showplayerdialog. When i show dialog for killer, killer can leave dialog empty and press ok.I trying on many ways to find solution for fix, but i don't have more ideas.
When i showing this dialog for player via command YCMD, everything work fine, but when i show dialog for killer under onplayerdeath, conditions in that dialog not work.
Although they are correct
Example of code:
PHP код:
new GetKillerID[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
GetKillerID[playerid] = 0;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
ShowPlayerDialog(killerid, 654, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
return 1;
}
fDialog(654)
{
if(response)
{
if(!strlen(inputtext))
{
SCM(playerid, COLOR_GRAD1, "Dialog is Empty");
return 1;
}
if(strlen(inputtext) < 5)
{
SCM(playerid, COLOR_GRAD1, "Inputtext can't be under 5 letters");
return 1;
}
if(((!(inputtext[0])) || (((inputtext[0]) == '\1') && (!(inputtext[1])))))
{
SCM(playerid, COLOR_GRAD1, "wtf?");
return 1;
}
// other code
}
else
{
ShowPlayerDialog(playerid, 654, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
}
return 1;
}
And also i tryed to store killerid - id in variable, and that variable use in fDialog but again same problem.
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
GetKillerID[killerid] = killerid;
ShowPlayerDialog(killerid, 654, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
return 1;
}
fDialog(654)
{
if(response)
{
//NOT WORK
if(!strlen(inputtext))
{
SCM(GetKillerID[playerid], COLOR_GRAD1, "Dialog is Empty");
return 1;
}
if(strlen(inputtext) < 5)
{
SCM(GetKillerID[playerid], COLOR_GRAD1, "Inputtext can't be under 5 letters");
return 1;
}
if(((!(inputtext[0])) || (((inputtext[0]) == '\1') && (!(inputtext[1])))))
{
SCM(GetKillerID[playerid], COLOR_GRAD1, "wtf?");
return 1;
}
//NOT WORK
// other code WORK
}
else
{
ShowPlayerDialog(GetKillerID[playerid], 654, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
}
return 1;
}
Re: OnPlayerDeath && ShowPlayerDialog issue -
CodeStyle175 - 14.05.2018
PHP код:
#define scm SendClientMessage
enum{
d_deathmsg
};
public OnPlayerDeath(playerid, killerid, reason) {
ShowPlayerDialog(killerid, d_deathmsg, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
new pid=playerid;
switch(dialogid){
case d_deathmsg:{
//must answer, cant be closed with pressing ESC
if(strlen(inputtext) < 5)
return scm(pid,-1,"Text must be longer then 5 letters!"),
ShowPlayerDialog(killerid, d_deathmsg, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
for(new i,i2=strlen(inputtext); i < i2; i++){
if(!('a' <= inputtext[i] <= 'z'))
return scm(pid,-1,"Only letters are allowed!"),
ShowPlayerDialog(killerid, d_deathmsg, DIALOG_STYLE_INPUT, "Simple question for you", "Are you smart?", "Ok", "");
}
//your other code
}
}
return 1;
}