Dialog doesn't work. -
Creax - 15.11.2013
When I click on player in list is no reaction.
Код HTML:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
new friend[24];
SetPVarInt(playerid, "Clicked", clickedplayerid);
if(IsAcceptedFriend(playerid, friend))
{
ShowPlayerDialog(playerid, DIALOG_ISFRIEND, DIALOG_STYLE_LIST, "", "Teleport\nSend Money\nDelete Friend", "Select", "Close");
}
else
{
ShowPlayerDialog(playerid, DIALOG_INVITEFR, DIALOG_STYLE_LIST, "", "Invite to add friend", "Invite", "Close");
}
return 1;
}
IsAcceptedFriend
Код HTML:
stock IsAcceptedFriend(playerid, friend[]) {
new query[256];
new bool:isfriend = false;
format(query, sizeof(query), "SELECT * FROM `Znajomi` WHERE (`Nick` = '%s' AND `Znajomy` = '%s' AND `Akceptowane` = '1') OR (`Nick` = '%s' AND `Znajomy` = '%s' AND `Akceptowane` = '1') ",
GetPlayerNick(playerid), friend, friend, GetPlayerNick(playerid));
mysql_query(query);
mysql_store_result();
isfriend = mysql_num_rows()>0;
mysql_free_result();
return isfriend;
}
Re: Dialog doesn't work. -
Konstantinos - 15.11.2013
Do you have any code in OnDialogResponse about dialogid DIALOG_ISFRIEND or DIALOG_INVITEFR? Also make sure that it returns 0 at the end (the callback).
Re: Dialog doesn't work. -
Creax - 16.11.2013
This is my OnDialogResponse.
Код HTML:
if(dialogid == DIALOG_INVITEFR)
{
if(response)
{
new str[128];
new friend[24];
new pid;
if(!IsInvitedFriend(playerid, friend)) {
AddFriend(playerid, friend);
format(str, sizeof(str), "You invite %s to friends.", friend);
SendClientMessage(playerid, Colour_Green, str);
for(new i=0; i<MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(strcmp(GetPlayerNick(i), friend, true) == 0) {
format(str, sizeof(str), "%s invited you to friends! '/accept %d' to accept friend.", GetPlayerNick(playerid), playerid);
SendClientMessage(pid, Colour_Yellow, str);
}
}
}
}
}
return 1;
}
if(dialogid == DIALOG_ISFRIEND)
{
if(response)
{
switch(listitem)
{
case 0:
{
new Clickedplayerid = GetPVarInt(playerid, "Clicked");
new Float:x,Float:y,Float:z;
GetPlayerPos(Clickedplayerid, x,y,z);
SetPlayerPos(playerid, x,y,z+3);
}
}
}
return 1;
}
return 0;
}
Re: Dialog doesn't work. -
Konstantinos - 16.11.2013
Dialogs sometimes conflict with other which have the same dialogid. So make sure that the dialogid of DIALOG_INVITEFR and DIALOG_ISFRIEND are not used anywhere else.
You can also debug it and see if it's called when a player responses to those dialogids
pawn Код:
// ...
if(dialogid == DIALOG_INVITEFR)
{
if(response)
{
print("DIALOG_INVITEFR is being called..");
new str[128];
new friend[24];
new pid;
if(!IsInvitedFriend(playerid, friend)) {
AddFriend(playerid, friend);
format(str, sizeof(str), "You invite %s to friends.", friend);
SendClientMessage(playerid, Colour_Green, str);
for(new i=0; i<MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(strcmp(GetPlayerNick(i), friend, true) == 0) {
format(str, sizeof(str), "%s invited you to friends! '/accept %d' to accept friend.", GetPlayerNick(playerid), playerid);
SendClientMessage(pid, Colour_Yellow, str);
}
}
}
}
}
return 1;
}
if(dialogid == DIALOG_ISFRIEND)
{
if(response)
{
print("DIALOG_ISFRIEND is being called..");
switch(listitem)
{
case 0:
{
new Clickedplayerid = GetPVarInt(playerid, "Clicked");
new Float:x,Float:y,Float:z;
GetPlayerPos(Clickedplayerid, x,y,z);
SetPlayerPos(playerid, x,y,z+3);
}
}
}
return 1;
}
return 0;
}
Test it and let us know whether it printed the messages or not.
PS: switch is faster than using if statement about dialogid.
Re: Dialog doesn't work. -
Creax - 16.11.2013
I paste it and message isn't printed in logs.
Function AddFriend.
Код HTML:
stock AddFriend(playerid, friend[]) {
new query[256];
format(query, sizeof(query), "INSERT INTO `Znajomi` (`Nick`, `Znajomy`, `Akceptowane`) VALUES('%s', '%s', '0')", GetPlayerNick(playerid), friend);
mysql_query(query);
}
Re: Dialog doesn't work. -
Konstantinos - 16.11.2013
Well, the problem might be:
- Same dialogids and conflict.
- OnDialogResponse returns 1 so it doesn't allow the rest of the modes to search for the dialogids.
I'd suggest you to use
easyDialog.inc for the dialogs, it's really useful for cases like yours and problems with dialogs in general.
Re: Dialog doesn't work. -
Creax - 16.11.2013
I used easyDialog and nothing.
And I change dialogs ID...
I think mistake is in function IsAcceptedFriend.
Re: Dialog doesn't work. -
Konstantinos - 16.11.2013
IsAcceptedFriend is fine because it returns 1 if there are rows and 0 if not.
You also said that the dialog is shown but when you response on it - it does nothing.
Re: Dialog doesn't work. -
Creax - 16.11.2013
This if(IsAcceptedFriend(playerid, friend)) in onplayerclickplayer is correct?
Re: Dialog doesn't work. -
Konstantinos - 16.11.2013
friend is actually NULL.
It should be:
pawn Код:
if(IsAcceptedFriend(playerid, GetPlayerNick(clickedplayerid)))
But again, it'd return 0 in the first place since there weren't any rows and it'd show DIALOG_INVITEFR dialog.