dialog response
#1

I am trying to make a command, /ccolor for VIPs, where they can change their chat color.
I have done this so far:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new colormsg[128], color;
	if(dialogid == 1)
	{
		if(response)
		{
			switch(listitem)
			{
				case 1: {color = 0xF30DFF00;}
				case 2: {color = 0xB10AFF00;}
				case 3: {color = 0x7B7DED00;}
				case 4: {color = 0x0FFAA00;}
				case 5:	{color = 0xFF7A2100;}			
				case 6: {color = 0x75757500;}
				case 7: {color = 0xFF858500;}
			}
			SetPlayerColor(playerid, color);
			return 1;
			}
		
		}	
	}
	return 0;
}
combined with:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/ccolor", true) == 0)
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{FFFFFF}Chat Colors", " {F30DFF}Pink\n{B10AFF}Purple\n{7B7DED}Navy Blue\n{00FFAA}Turqoise\n{FF7A21}Vibrant Orange\n{757575}Dark Grey\n{FF8585}Light Red\n{F6FF00}Bright Yellow\n{A34D4D}Brown", "Choose", "Cancel");
		return 1;
	}
	return 0;
}
It does not compile and I do not what is wrong.
Here are the errors:
Код:
GM.pwn(179) : warning 204: symbol is assigned a value that is never used: "colormsg"
GM.pwn(179 -- 199) : warning 209: function "OnDialogResponse" should return a value
GM.pwn(179 -- 200) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
================ READY ================
Also, would the switch(listitem) on each case work with a formatted message, along with the { color = .... ; } ? I have tried it and I got the error saying "Only one message can be assigned on each case".
Reply
#2

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new colormsg[128], color;
	if(dialogid == 1)
	{
		if(response)
		{
			switch(listitem)
			{
				case 1: {color = 0xF30DFF00;}
				case 2: {color = 0xB10AFF00;}
				case 3: {color = 0x7B7DED00;}
				case 4: {color = 0x0FFAA00;}
				case 5:	{color = 0xFF7A2100;}			
				case 6: {color = 0x75757500;}
				case 7: {color = 0xFF858500;}
			}
			SetPlayerColor(playerid, color);
			return 1;
			}
		
		}// this Was the problem Remove it because your opening 4 and closing 5.	 
	}
	return 0;
}
Reply
#3

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/ccolor", true) == 0)
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{FFFFFF}Chat Colors", " {F30DFF}Pink\n{B10AFF}Purple\n{7B7DED}Navy Blue\n{00FFAA}Turqoise\n{FF7A21}Vibrant Orange\n{757575}Dark Grey\n{FF8585}Light Red\n{F6FF00}Bright Yellow\n{A34D4D}Brown", "Choose", "Cancel");
		return 1;
	}
	return 0;
}
this strcmp part does not return 1, why not?
Reply
#4

Quote:
Originally Posted by JXF
Посмотреть сообщение
Код:
..
this strcmp part does not return 1, why not?
Returning 0 informs the server that the command hasn't been processed by this script.
OnPlayerCommandText will be called in other scripts until one returns 1.
If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
Reply
#5

Quote:
Originally Posted by JXF
Посмотреть сообщение
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/ccolor", true) == 0)
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{FFFFFF}Chat Colors", " {F30DFF}Pink\n{B10AFF}Purple\n{7B7DED}Navy Blue\n{00FFAA}Turqoise\n{FF7A21}Vibrant Orange\n{757575}Dark Grey\n{FF8585}Light Red\n{F6FF00}Bright Yellow\n{A34D4D}Brown", "Choose", "Cancel");
		return 1;
	}
	return 0;
}
this strcmp part does not return 1, why not?
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/ccolor", true) == 0)
	{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{FFFFFF}Chat Colors", " {F30DFF}Pink\n{B10AFF}Purple\n{7B7DED}Navy Blue\n{00FFAA}Turqoise\n{FF7A21}Vibrant Orange\n{757575}Dark Grey\n{FF8585}Light Red\n{F6FF00}Bright Yellow\n{A34D4D}Brown", "Choose", "Cancel");
		return 1;
	}
	return 1;
}
Just try that.
Reply
#6

First of all, you should use a command processor, like ZCMD:


https://sampforum.blast.hk/showthread.php?tid=91354


Then you can do it like this.

PHP код:
#define DIALOG_ID_VIP_COLORS 1
CMD:ccolor(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_ID_VIP_COLORSDIALOG_STYLE_LIST"{FFFFFF}Chat Colors""{F30DFF}Pink\n{B10AFF}Purple\n{7B7DED}Navy Blue\n{00FFAA}Turqoise\n{FF7A21}Vibrant Orange\n{757575}Dark Grey\n{FF8585}Light Red\n{F6FF00}Bright Yellow\n{A34D4D}Brown""Choose""Cancel");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ID_VIP_COLORS:
        {
            if(
response)
            {
                new 
_:color;
                switch(
listitem)
                {
                    
// Listitem ID starts from 0. There are 9 items.
                    
case 0color 0xF30DFF00;
                    case 
1color 0xB10AFF00;
                    case 
2color 0x7B7DED00;
                    case 
3color 0x00FFAA00;
                    case 
4color 0xFF7A2100;
                    case 
5color 0x75757500;
                    case 
6color 0xFF858500;
                    case 
7color 0xF6FF0000;
                    case 
8color 0xA34D4D00;
                }
                
SendClientMessage(playerid_:color"* This is your new color.");
                
SetPlayerColor(playerid_:color);
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)