Dialog Response Problem
#1

Hey again

I am facing a problem with dialog response, I am making an Credits system and when I select an option on /cshop command it does nothing, here is the codes

Код:
CMD:cshop(playerid, params[])
{
	ShowPlayerDialog(playerid, DIALOG_CSHOP, DIALOG_STYLE_LIST,"Credits Shop","Refill Health "orange"[2 Credits]\n"white"Refill Armour "orange"[5 Credits]","Choose","Cancel");
	return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case DIALOG_CSHOP:
		{
			if(response)
			{
	  			switch(listitem)
	    		{
	    			case 0:
	     			{
	     			    if(Data[playerid][pCredits] < 2) return SendClientMessage(playerid, -1, "["blue"SERVER"white"] You don't have enought credits");
				    	SetPlayerHealth(playerid, 100);
				    	Data[playerid][pCredits] -= 2;
				    	SendClientMessage(playerid, -1, "["blue"SERVER"white"] You have successfully refilled your Health");
	     			}
	    			case 1:
	     			{
	     			    if(Data[playerid][pCredits] < 5) return SendClientMessage(playerid, -1, "["blue"SERVER"white"] You don't have enought credits");
				    	SetPlayerArmour(playerid, 100);
				    	Data[playerid][pCredits] -= 5;
				    	SendClientMessage(playerid, -1, "["blue"SERVER"white"] You have successfully refilled your Armour");
	     			}
				}
			}
		}
	}
	return 1;
}
Any idea on what is wrong?
Reply
#2

Hello!

What is printing in the console (server.log) if you choose a listitem of the dialog?
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        
printf("dialogid: %i",dialogid);
        case 
DIALOG_CSHOP:
        {
            
printf("DIALOG_CSHOP: %i | response: %i",DIALOG_CSHOP,response);
            if(
response)
            {
                
printf("listitem: %i",listitem);
                  switch(
listitem)
                {
                    case 
0:
                     {
                         print(
"listitem 0");
                         if(
Data[playerid][pCredits] < 2) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerHealth(playerid100);
                        
Data[playerid][pCredits] -= 2;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Health");
                     }
                    case 
1:
                     {
                         print(
"listitem 1");
                         if(
Data[playerid][pCredits] < 5) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerArmour(playerid100);
                        
Data[playerid][pCredits] -= 5;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Armour");
                     }
                }
            }
        }
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

What is printing in the console (server.log) if you choose a listitem of the dialog?
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        
printf("dialogid: %i",dialogid);
        case 
DIALOG_CSHOP:
        {
            
printf("DIALOG_CSHOP: %i | response: %i",DIALOG_CSHOP,response);
            if(
response)
            {
                
printf("listitem: %i",listitem);
                  switch(
listitem)
                {
                    case 
0:
                     {
                         print(
"listitem 0");
                         if(
Data[playerid][pCredits] < 2) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerHealth(playerid100);
                        
Data[playerid][pCredits] -= 2;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Health");
                     }
                    case 
1:
                     {
                         print(
"listitem 1");
                         if(
Data[playerid][pCredits] < 5) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerArmour(playerid100);
                        
Data[playerid][pCredits] -= 5;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Armour");
                     }
                }
            }
        }
    }
    return 
1;

I am getting some errors, I checked the script too much, and I have also made a lot of commands and scripts with this way and they all worked perfectly, strange
Reply
#4

Can you share the errors with us?
Reply
#5

Код:
error 002: only a single statement (or expression) can follow each "case"
warning 215: expression has no effect
error 014: invalid statement; not in switch
warning 215: expression has no effect
error 001: expected token: ";", but found ":"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Reply
#6

Oh, sorry.
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_CSHOP:
        {
            
printf("dialogid: %i",dialogid);
            
printf("DIALOG_CSHOP: %i | response: %i",DIALOG_CSHOP,response);
            if(
response)
            {
                
printf("listitem: %i",listitem);
                switch(
listitem)
                {
                    case 
0:
                    {
                         print(
"listitem 0");
                         if(
Data[playerid][pCredits] < 2) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerHealth(playerid100);
                        
Data[playerid][pCredits] -= 2;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Health");
                    }
                       case 
1:
                       {
                        print(
"listitem 1");
                         if(
Data[playerid][pCredits] < 5) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerArmour(playerid100);
                        
Data[playerid][pCredits] -= 5;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Armour");
                    }
                }
            }
        }
    }
    return 
1;

Well. What is printing in the console (server.log)?
Reply
#7

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Oh, sorry.
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_CSHOP:
        {
            
printf("dialogid: %i",dialogid);
            
printf("DIALOG_CSHOP: %i | response: %i",DIALOG_CSHOP,response);
            if(
response)
            {
                
printf("listitem: %i",listitem);
                switch(
listitem)
                {
                    case 
0:
                    {
                         print(
"listitem 0");
                         if(
Data[playerid][pCredits] < 2) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerHealth(playerid100);
                        
Data[playerid][pCredits] -= 2;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Health");
                    }
                       case 
1:
                       {
                        print(
"listitem 1");
                         if(
Data[playerid][pCredits] < 5) return SendClientMessage(playerid, -1"["blue"SERVER"white"] You don't have enought credits");
                        
SetPlayerArmour(playerid100);
                        
Data[playerid][pCredits] -= 5;
                        
SendClientMessage(playerid, -1"["blue"SERVER"white"] You have successfully refilled your Armour");
                    }
                }
            }
        }
    }
    return 
1;

Well. What is printing in the console (server.log)?
Nothing,

Код:
[11:20:55] Number of vehicle models: 0
[11:21:23] [connection] --- requests connection cookie.
[11:21:24] Incoming connection: --- id: 0
[11:21:24] [join] blackNred has joined the server (---)
Reply
#8

Do you use any filterscripts or includes?
Reply
#9

Your Code is right, how did you define DIALOG_CSHOP ?
Reply
#10

Код:
#define         		DIALOG_CSHOP            			14587                   // Random Number
And yea this system is a filterscript
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)