SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Help with dialog (https://forum.sa-mp.com/showthread.php?t=672540)

D1am0nd 17/02/2020 02:17 PM

Help with dialog
 
Hello. So I'm having a problem with dialog response on missions for trucker class.

When I select first delivery, it kicks me from the server, saying "You've been kicked for typing wrong password!", even though that's the login part.

It happens only when I choose the first delivery.

Here's the code:

PHP Code:

public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 2)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 1;
                
SetPlayerCheckpoint(playerid,-69.7976,-1120.2092,1.07813.0);
                
SendClientMessage(playerid, -1"Deliver Sand to Glass Factory");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 2;
                
SetPlayerCheckpoint(playerid2433.3452,-2113.8091,13.5469,3.0);
                
SendClientMessage(playerid, -1"Deliver Rocks to the Smeltery");
            }
        }
    }
    if(
dialogid == 3)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 3;
                
SetPlayerCheckpoint(playerid,1923.8414,-1319.1575,16.43853.0);
                
SendClientMessage(playerid, -1"Deliver Planks to Los Santos Construction Site");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 4;
                
SetPlayerCheckpoint(playerid326.5647,869.9084,20.3990,3.0);
                
SendClientMessage(playerid, -1"Deliver Planks to San Fierro Construction Site");
            }
        }
    }
    if(
dialogid == 4)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 5;
                
SetPlayerCheckpoint(playerid,-1704.9644,14.6946,3.55473.0);
                
SendClientMessage(playerid, -1"Deliver Scrap Metal to San Fierro Import/Export Company");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 6;
                
SetPlayerCheckpoint(playerid, -2081.6560,230.5117,35.5137,3.0);
                
SendClientMessage(playerid, -1"Deliver Garbage to Las Venturas Quarry");
            }

        }
    }
    if(
dialogid == 5)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 7;
                
SetPlayerCheckpoint(playerid,2410.4470,-1425.5830,23.98253.0);
                
SendClientMessage(playerid, -1"Deliver Tools to Los Santos Wood Processing Facility");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 8;
                
SetPlayerCheckpoint(playerid326.5647,869.9084,20.3990,3.0);
                
SendClientMessage(playerid, -1"Deliver Tools to Las Venturas Quarry");
            }
            if(
listitem == 2)
            {
                
Ccp[playerid] = 9;
                
SetPlayerCheckpoint(playerid1923.8414,-1319.1575,16.4385,3.0);
                
SendClientMessage(playerid,-1"Deliver Tools to Los Santos Construction Site");
            }
            if(
listitem == 3)
            {
                
Ccp[playerid] = 10;
                
SetPlayerCheckpoint(playerid,-2081.6560,230.5117,35.5137,3.0);
                
SendClientMessage(playerid,-1"Deliver Tools to San Fierro Construction Site");
            }
        }
    }
    if(
dialogid == 6)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 11;
                
SetPlayerCheckpoint(playerid,2197.9055,-2656.3906,13.54693.0);
                
SendClientMessage(playerid, -1"Deliver Metal to Los Santos Workshop");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 12;
                
SetPlayerCheckpoint(playerid1923.8414,-1319.1575,16.4385,3.0);
                
SendClientMessage(playerid, -1"Deliver Metal to Los Santos Construction Site");
            }
            if(
listitem == 2)
            {
                
Ccp[playerid] = 13;
                
SetPlayerCheckpoint(playerid, -2081.6560,230.5117,35.5137,3.0);
                
SendClientMessage(playerid, -1"Deliver Metal to San Fierro Construction Site");
            }
        }
    }
    if(
dialogid == 7)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 14;
                
SetPlayerCheckpoint(playerid,2182.9985,-2259.2625,13.38853.0);
                
SendClientMessage(playerid, -1"Deliver Tools to Los Santos Storage Unit");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 15;
                
SetPlayerCheckpoint(playerid, -1851.9323,-190.6102,18.3750,3.0);
                
SendClientMessage(playerid, -1"Deliver Tools to San Fierro Storage Unit");
            }
        }
    }
    if(
dialogid == 8)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 16;
                
SetPlayerCheckpoint(playerid,2433.3452,-2113.8091,13.54693.0);
                
SendClientMessage(playerid, -1"Deliver Chemicals to Los Santos Smeltery");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 17;
                
SetPlayerCheckpoint(playerid2410.4470,-1425.5830,23.9825,3.0);
                
SendClientMessage(playerid, -1"Deliver Chemicals to Los Santos Wood Processing Facility");
            }
        }
    }
    if(
dialogid == 9)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 18;
                
SetPlayerCheckpoint(playerid,-2081.6560,230.5117,35.51373.0);
                
SendClientMessage(playerid, -1"Deliver Tools to San Fierro Construction Site");
            }
            if(
listitem == 1)
            {
                
Ccp[playerid] = 19;
                
SetPlayerCheckpoint(playerid1923.8414,-1319.1575,16.4385,3.0);
                
SendClientMessage(playerid, -1"Deliver Tools to Los Santos Construction Site");
            }
        }
    }
    if(
dialogid == 10)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                
Ccp[playerid] = 20;
                
SetPlayerCheckpoint(playerid,2104.2332,-2074.1304,13.55443.0);
                
SendClientMessage(playerid, -1"Deliver Waste Material to Los Santos Recycle Center");
            }
            return 
1;
        }
    }
    if (
dialogid == DIALOG_REGISTER)
    {
        if (!
response) return pkick(playerid);
        if(
response)
        {
            if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_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,"Work",0);
            
INI_WriteInt(File,"Convoy",0);
            
INI_WriteInt(File,"Deaths",0);
            
INI_WriteInt(File,"Class",0);
            
INI_WriteInt(File,"License",0);
            
INI_Close(File);

            
SendClientMessage(playerid0xFF0000FF"Your account has been registered succesfully. Please go to the next step by chosing your class.");
        }
    }

    if (
dialogid == DIALOG_LOGIN)
    {
        if ( !
response ) return pkick(playerid);
        if( 
response )
        {
            if(
udb_hash(inputtext) == PlayerInfo[playerid][pPass])
            {
                
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"You've been kicked for typing wrong password!");
                
pkick(playerid);
            }
            return 
1;
        }
    }
    return 
1;



EDIT: The problem doesn't appear when I remove the lines related to wrong password and kick,but then player can login back with any password

Beckett 17/02/2020 02:20 PM

Re: Help with dialog
 
This means the dialogid is conflicting with that of the login dialog. Redefine DIALOG_LOGIN into another ID. Right now its id 2.

D1am0nd 17/02/2020 02:32 PM

Re: Help with dialog
 
Quote:

Originally Posted by Beckett (Post 4131673)
This means the dialogid is conflicting with that of the login dialog. Redefine DIALOG_LOGIN into another ID. Right now its id 2.

Oh silly me, didn't notice that one. Thanks for the help!

GTLS 18/02/2020 04:09 AM

Re: Help with dialog
 
Use enum to manage dialogids. You dont have to worry about them this way.

Beckett 23/02/2020 05:24 PM

Re: Help with dialog
 
Or you can use easydialog, my favorite include for the most efficient usage of dialogs. Personally I recommend it, and always used it in all of my gamemodes.

jasperschellekens 23/02/2020 06:29 PM

Re: Help with dialog
 
DIALOG_LOGIN is assigned to an integer which is also being used by your truck system resulting in this to happen.


All times are GMT. The time now is 09:10 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.