PDA

View Full Version : [Help] Dialog


Johnny_DeVito
07/08/2012, 04:38 PM
Hi guys, i have one problem.

When i try to put these codes under OnDialogResponse, Pawno always get crashed. I don't know what is the problem.

I'll Be appreciate if u do this for me.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_HOUSE:
{
if(!response) return 1;
new
string[200];
switch(listitem)
{
case 0: {
new id = Player[playerid][Houseid];
if(id == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have house");
if(!IsPlayerInRangeOfPoint(playerid,3.0,House[id][EnterX],House[id][EnterY],House[id][EnterZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near your house");
format(House[id][Owner], 32, "Department");
if(House[id][hCar] > 0) format(HouseOwner[House[id][hCar]],64,"Department");
House[id][On_Sell] = 1;
Player[playerid][Houseid] = 999;
GivePlayerMoney(playerid,House[id][Price]/2);
DestroyDynamicPickup(House[id][PickupU]);
House[id][PickupU] = CreateDynamicPickup(1273, 23, House[id][EnterX],House[id][EnterY],House[id][EnterZ],-1,-1,-1,100.0);
DestroyDynamicMapIcon(House[id][Icon]);
House[id][Icon] = CreateDynamicMapIcon(House[id][EnterX],House[id][EnterY],House[id][EnterZ], 31, 0, -1, -1, -1, 100.0);
CheckHouse(id);
UpdatePlayerInformation(playerid);
format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"Department\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"%d\n{29CC3F}Level: "COL_WHITE"%d\n{29CC3F}Address: "COL_WHITE"%s\n (/buyhouse)",House[id][HouseName],House[id][Price],House[id][Level],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
}
case 1: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+1,DIALOG_ST YLE_INPUT,""COL_YELLOW"Rent house",""COL_BLUE"Type rent price","Put","Close"); }
case 2:
{
new id = Player[playerid][Houseid];
foreach (Player, i)
{
if(i != playerid)
{
if(strcmp(House[id][Player_Rent],GetName(playerid), false ) == 0) {SCM(i,COLOR_RED,"You have been evicted from house");}
format(House[id][Player_Rent],48,"Nobody");
}
}
}
case 3: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+2,DIALOG_ST YLE_INPUT,""COL_YELLOW"House name",""COL_WHITE"Type new name of house","Name","Close");
}
case 4: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_ST YLE_INPUT,""COL_YELLOW"Lock Password (numbers only)",""COL_WHITE"Type new password","Insert","Close");
}
}
}
case DIALOG_HOUSE+1:
{
if(!response) return 1;
new string[210];
new id = Player[playerid][Houseid];
if(strval(inputtext) <= 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Price can't be less 1");
House[id][RentPrice] = strval(inputtext);
format(string,sizeof(string),"New rent price is $%d",strval(inputtext)); SCM(playerid,-1,string);
format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
CheckHouse(id);
}
case DIALOG_HOUSE+2:
{
if(!response) return 1;
new string[210];
new id = Player[playerid][Houseid];
format(House[id][HouseName], 32, "%s", inputtext);
format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
CheckHouse(id);
}
case DIALOG_HOUSE+3:
{
if(!response) return 1;
new string[128];
new id = Player[playerid][Houseid];
if(strlen(inputtext) >= 5 || strlen(inputtext) < 4) return ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_ST YLE_INPUT,""COL_WHITE"Lock Password",""COL_BLUE"Type new password","Insert","Close"),SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Just four numbers");
format(House[id][LockPass],5,"%d",strval(inputtext));
format(string,sizeof(string),"New password is %d",strval(inputtext)); SCM(playerid,-1,string);
CheckHouse(id);
}
}
return 1;
}

In This Dialog:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}

Thanks.

Johnny_DeVito
07/08/2012, 05:39 PM
Anybody *?

Johnny_DeVito
08/08/2012, 01:28 PM
****BUMP*****


Help me please

Dawnz
08/08/2012, 01:48 PM
Just do it with
if(dialogid == [DIALOGNAME])

Johnny_DeVito
08/08/2012, 05:01 PM
U see this code:

case DIALOG_HOUSE:
{
if(!response) return 1;
new
string[200];
switch(listitem)
{
case 0: {
new id = Player[playerid][Houseid];
if(id == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have house");
if(!IsPlayerInRangeOfPoint(playerid,3.0,House[id][EnterX],House[id][EnterY],House[id][EnterZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near your house");
format(House[id][Owner], 32, "Department");
if(House[id][hCar] > 0) format(HouseOwner[House[id][hCar]],64,"Department");
House[id][On_Sell] = 1;
Player[playerid][Houseid] = 999;
GivePlayerMoney(playerid,House[id][Price]/2);
DestroyDynamicPickup(House[id][PickupU]);
House[id][PickupU] = CreateDynamicPickup(1273, 23, House[id][EnterX],House[id][EnterY],House[id][EnterZ],-1,-1,-1,100.0);
DestroyDynamicMapIcon(House[id][Icon]);
House[id][Icon] = CreateDynamicMapIcon(House[id][EnterX],House[id][EnterY],House[id][EnterZ], 31, 0, -1, -1, -1, 100.0);
CheckHouse(id);
UpdatePlayerInformation(playerid);
format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"Department\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"%d\n{29CC3F}Level: "COL_WHITE"%d\n{29CC3F}Address: "COL_WHITE"%s\n (/buyhouse)",House[id][HouseName],House[id][Price],House[id][Level],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
}
case 1: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+1,DIALOG_ST YLE_INPUT,""COL_YELLOW"Rent house",""COL_BLUE"Type rent price","Put","Close"); }
case 2:
{
new id = Player[playerid][Houseid];
foreach (Player, i)
{
if(i != playerid)
{
if(strcmp(House[id][Player_Rent],GetName(playerid), false ) == 0) {SCM(i,COLOR_RED,"You have been evicted from house");}
format(House[id][Player_Rent],48,"Nobody");
}
}
}
case 3: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+2,DIALOG_ST YLE_INPUT,""COL_YELLOW"House name",""COL_WHITE"Type new name of house","Name","Close");
}
case 4: {
ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_ST YLE_INPUT,""COL_YELLOW"Lock Password (numbers only)",""COL_WHITE"Type new password","Insert","Close");
}
}
}
case DIALOG_HOUSE+1:
{
if(!response) return 1;
new string[210];
new id = Player[playerid][Houseid];
if(strval(inputtext) <= 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Price can't be less 1");
House[id][RentPrice] = strval(inputtext);
format(string,sizeof(string),"New rent price is $%d",strval(inputtext)); SCM(playerid,-1,string);
format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
CheckHouse(id);
}
case DIALOG_HOUSE+2:
{
if(!response) return 1;
new string[210];
new id = Player[playerid][Houseid];
format(House[id][HouseName], 32, "%s", inputtext);
format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
CheckHouse(id);
}
case DIALOG_HOUSE+3:
{
if(!response) return 1;
new string[128];
new id = Player[playerid][Houseid];
if(strlen(inputtext) >= 5 || strlen(inputtext) < 4) return ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_ST YLE_INPUT,""COL_WHITE"Lock Password",""COL_BLUE"Type new password","Insert","Close"),SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Just four numbers");
format(House[id][LockPass],5,"%d",strval(inputtext));
format(string,sizeof(string),"New password is %d",strval(inputtext)); SCM(playerid,-1,string);
CheckHouse(id);
}
}
return 1;
}


This code is untidy, and when i try to put him, pawno get crashed.

I use Gagi's Dynamic House System, and theese codes are...agfffff

damn !