ShowPlayerDialog help
#1

Whats wrong with this Dialog why dont it work i get allot of errors.

Код:
	    for(new i = 0; i < sizeof(CarInfo); i++)
	    {
	    	new newcar = GetPlayerVehicleID(playerid);
	    	new string[256];
        	if(newcar == CarInfo[i][ownedvehicle])
			{
			    if(CarInfo[i][cOwned]==0)
			    {
			        TogglePlayerControllable(playerid, 0);
			        CarOffered[playerid]=1;
                    ShowPlayerDialog( playerid, 4512, DIALOG_STYLE_LIST, "Car Menu", "Car: %s Price: %d if you want this car press buy.", "Buy", "Cancel" CarInfo[i][cDescription],CarInfo[i][cValue]);
			    }
			}
		}
	}
	return 1;
Reply
#2

Please post ur code and errors
Reply
#3

Please look at API docs, https://sampwiki.blast.hk/wiki/ShowPlayerDialog

You should format the string BEFORE using it with the function.

Also using 128 strings are better it's the hard-limit for most displayed content.
Reply
#4

Quote:
Originally Posted by mr.sunny
Посмотреть сообщение
Please post ur code and errors
ShowPlayerDialog :

Код:
if(CarInfo[i][cOwned]==0)
			    {
			        TogglePlayerControllable(playerid, 0);
			        CarOffered[playerid]=1;
                    ShowPlayerDialog( playerid, 4512, DIALOG_STYLE_MSGBOX, "Car Menu", "Car: %s Price: %d if you want this car press buy.", "Buy", "Cancel" CarInfo[i][cDescription],CarInfo[i][cValue]);
			    }
			}
		}
	}
	return 1;
Dialog respond :

Код:
if(dialogid == 4512 && response == 1)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        for(new i = 0; i < sizeof(CarInfo); i++)
	        {
				if(CarInfo[i][ownedvehicle] == vehid)
				{
					if(PlayerInfo[playerid][pCarKey]!=0)
					{
						SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /car sell if you want to buy this one!");
						return 1;
					}
					if(CarInfo[i][cOwned]==1)
					{
					    SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
					    return 1;
					}
					if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
					{
						PlayerInfo[playerid][pCarKey] = i;
						CarInfo[i][cOwned] = 1;
						CarOffered[playerid]=0;
						GetPlayerName(playerid, sendername, sizeof(sendername));
						strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
						GivePlayerMoney(playerid,-CarInfo[i][cValue]);
						GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
						SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
						SendClientMessage(playerid, COLOR_GRAD2, "Type /car manual to view the car manual!");
						TogglePlayerControllable(playerid, 1);
						SaveCars();
						return 1;
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "   You don't have the cash for that!");
						return 1;
					}
				}
			}
		}
		return 1;
Errors :

Код:
 error 017: undefined symbol "dialogid"
 error 025: function heading differs from prototype
 error 001: expected token: "-string end-", but found "-identifier-"
 warning 215: expression has no effect
 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
#5

pawn Код:
new string_dialog[128];
format(string_dialog,sizeof(string_dialog),"Car: %s Price: %d if you want that car press buy",CarInfo[i][cDescription],CarInfo[i][cValue]);
ShowPlayerDialog( playerid, 4512, DIALOG_STYLE_LIST, "Car Menu",string_dialog, "Buy", "Cancel");
You can't format inside the ShowPlayerDialog itself, use a pre-formatted string.
Reply
#6

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
new string_dialog[128];
format(string_dialog,sizeof(string_dialog),"Car: %s Price: %d if you want that car press buy",CarInfo[i][cDescription],CarInfo[i][cValue]);
ShowPlayerDialog( playerid, 4512, DIALOG_STYLE_LIST, "Car Menu",string_dialog, "Buy", "Cancel" CarInfo[i][cDescription],CarInfo[i][cValue]);
You can't format inside the ShowPlayerDialog itself, use a pre-formatted string.
Oh okay i understand now, thanks i try work it out
Reply
#7

2 errors now

Код:
 error 017: undefined symbol "dialogid"
 error 025: function heading differs from prototype
 warning 204: symbol is assigned a value that is never used: "string"
i made this
Код:
if(CarInfo[i][cOwned]==0)
			    {
			        TogglePlayerControllable(playerid, 0);
			        CarOffered[playerid]=1;
                    new string_dialog[128];
					format(string_dialog,sizeof(string_dialog),"Car: %s Price: %d if you want that car press buy",CarInfo[i][cDescription],CarInfo[i][cValue]);
					ShowPlayerDialog( playerid, 4512, DIALOG_STYLE_MSGBOX, "Car Menu",string_dialog, "Buy", "Cancel");
			    }
			}
		}
	}
	return 1;
Reply
#8

These errors are from your dialog response public.

First- The symbol 'dialogid' is not recognized.
Second- Some function is declared differently from the way it's implemented; example:
pawn Код:
forward Test(playerid,wtf);
public Test(playerid)
{
    //...
}
Will return an error because the function 'wtf' is not declared.

Third error- Remove the 'new string[256];' line. You have a string variable that you haven't used.

Show me your OnDialogResponse line.
Reply
#9

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
These errors are from your dialog response public.

First- The symbol 'dialogid' is not recognized.
Second- Some function is declared differently from the way it's implemented; example:
pawn Код:
forward Test(playerid,wtf);
public Test(playerid)
{
    //...
}
Will return an error because the function 'wtf' is not declared.

Third error- Remove the 'new string[256];' line. You have a string variable that you haven't used.

Show me your OnDialogResponse line.
Just wanna say thanks for helping me out your really good at helping.

Well here is my dialogresponse :
Код:
if(dialogid == 4512 && response == 1)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        for(new i = 0; i < sizeof(CarInfo); i++)
	        {
				if(CarInfo[i][ownedvehicle] == vehid)
				{
					if(PlayerInfo[playerid][pCarKey]!=0)
					{
						SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /car sell if you want to buy this one!");
						return 1;
					}
					if(CarInfo[i][cOwned]==1)
					{
					    SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
					    return 1;
					}
					if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
					{
						PlayerInfo[playerid][pCarKey] = i;
						CarInfo[i][cOwned] = 1;
						CarOffered[playerid]=0;
						GetPlayerName(playerid, sendername, sizeof(sendername));
						strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
						GivePlayerMoney(playerid,-CarInfo[i][cValue]);
						GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
						SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
						SendClientMessage(playerid, COLOR_GRAD2, "Type /car manual to view the car manual!");
						TogglePlayerControllable(playerid, 1);
						SaveCars();
						return 1;
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "   You don't have the cash for that!");
						return 1;
					}
				}
			}
		}
		return 1;
Im trying to make so when you enter a buy able car the dialog shows and you can cancel ore buy it.
it was a text on the screen before trying to make it into a dialog
Reply
#10

Nono!, I meant the 'public OnDialogResponse' line itself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)