SA-MP Forums Archive
Little problem on ShowPlayerDialog - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little problem on ShowPlayerDialog (/showthread.php?tid=475266)



Little problem on ShowPlayerDialog - Kethrios - 12.11.2013

Hello everybody !

I'm attempting on doing a basic elevator on my GM.
There are 3 levels.

I'm actually testing on the 2nd level, when a cop is pressing F, then a dialog will show up asking where he would like to go, there are 2 options "Up(+1)" and "Down(-1)".

The dialog shows up without any problem, the thing is that, when the player press Up or Down, nothing happens, why ? I can't figure it out, it's driving me crazy.

Here is the full code.

pawn Код:
new gps_currentDest[MAX_PLAYERS]; // ascenseur
forward CheckForWalkingTeleport(playerid);
forward PlayerToPointStripped(Float:radi, playerid, Float:x, Float:y, Float:z, Float:curx, Float:cury, Float:curz);
forward GetCityPlayer(playerid,activated);






public CheckForWalkingTeleport(playerid)
{
    new Float:cx, Float:cy, Float:cz;
    GetPlayerPos(playerid, cx, cy, cz);
   
    if(PlayerToPointStripped(1.0, playerid, 1524.4854,-1677.8744,6.2188, cx,cy,cz))
    { //Garage
        gps_currentDest[playerid] = 10;
        ShowPlayerDialog(playerid,911,DIALOG_STYLE_MSGBOX,"[Police] Elevator- Garage","Select your level","Up (+1)","Up (+2)");
        return 1;
    }
    if(IsACop(playerid) && PlayerToPointStripped(1.0, playerid, 1558.71, -1712.25, -7.79, cx,cy,cz))
    { //1st Floor
        gps_currentDest[playerid] = 11;
        ShowPlayerDialog(playerid,911,DIALOG_STYLE_MSGBOX,"[Police] Elevator - 1st floor","Select your level","","'(Down -1");
        return 1;
    }
    if(IsACop(playerid) &&  PlayerToPointStripped(1.0, playerid, 1558.0886,-1675.5081,28.3955, cx,cy,cz))
    { //Roof
        gps_currentDest[playerid] = 12;
        ShowPlayerDialog(playerid,911,DIALOG_STYLE_MSGBOX,"[Police] Elevator - Roof","Select your level","Down(-1)","Down(-2)");
        return 1;
    }
    return 1;
}



public PlayerToPointStripped(Float:radi, playerid, Float:x, Float:y, Float:z, Float:curx, Float:cury, Float:curz)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:tempposx, Float:tempposy, Float:tempposz;
        tempposx = (curx -x);
        tempposy = (cury -y);
        tempposz = (curz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) return 1;
    }
    return 0;
}

public GetCityPlayer(playerid,activated)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);

    if(activated)
    {
        if(x >= -2694.2791 && x < -2016.9351 && y >= 2163.9771 && y < 2570.9529)
            {return 5;} // BS
        else if(x >= -374.3679 && x < 178.0175 && y >= 981.3533 && y < 1257.3018)
            {return 4;} // FC
        else if(x >= -2977.2312 && x < -994.2332 && y >= -2964.7822 && y < 2973.1956)
            {return 1;} // SF
        else if(x >= -994.2332 && x < 2932.5674 && y >= -2964.7822 && y < 499.1327)
            {return 2;} // LS
        else if(x >= -994.2332 && x < 2932.5674 && y >= 499.1327 && y < 2973.1956)
            {return 3;} // LV
        else return 2;
    }
    else
    {
        if(x >= -2977.2312 && x < -994.2332 && y >= -2964.7822 && y < 2973.1956)
            {return 1;} // SF
        else if(x >= -994.2332 && x < 2932.5674 && y >= -2964.7822 && y < 499.1327)
            {return 2;} // LS
        else if(x >= -994.2332 && x < 2932.5674 && y >= 499.1327 && y < 2973.1956)
            {return 3;} // LV
        else return 2;
    }
}



    if(dialogid == 911) // Elevator Cops
    {
        if(GetCityPlayer(playerid,false) == 2)   // Elevator is in LS
        {
            if(gps_currentDest[playerid]==10) // Garage level
            {
                if(response==0) // Roof
                    {SetPlayerPosEx(playerid,1558.0886,-1675.5081,28.3955); SetPlayerVirtualWorld(playerid, 0);}
                if(response==1) // 1st floor
                    {SetPlayerPosEx(playerid,1558.71, -1712.25, -7.79); SetPlayerInterior(playerid, 6); SetPlayerVirtualWorld(playerid, 1); }
                return 1;
            }
            if(gps_currentDest[playerid]==11) // 1st floor
            {
                if(response==1) // Roof
                    {SetPlayerPosEx(playerid,1558.0886,-1675.5081,28.3955); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0);}
                if(response==0) // Garage
                    {SetPlayerPosEx(playerid,1524.4854,-1677.8744,6.2188); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); }
                return 1;
            }
            if(gps_currentDest[playerid]==12) // Roof
            {
                if(response==1) // 1st floor
                    {SetPlayerPosEx(playerid,1558.71, -1712.25, -7.79); SetPlayerInterior(playerid, 6); SetPlayerVirtualWorld(playerid, 1);}
                if(response==0) // garage
                    {SetPlayerPosEx(playerid,1524.4854,-1677.8744,6.2188); SetPlayerVirtualWorld(playerid, 0);}
                return 1;
            }
        }
    }


And in :
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)

In : if(newkeys == KEY_SECONDARY_ATTACK)

            else if(IsPlayerInRangeOfPoint(playerid, 1, 1558.71, -1712.25, -7.79))
            {
                ShowPlayerDialog(playerid,911,DIALOG_STYLE_MSGBOX,"[Police] Elevator - Garage","Select your level","(Up +1)","(Up+2");
            }


Thanks in advance for your help or advices.


Re: Little problem on ShowPlayerDialog - Loot - 12.11.2013

KEY_SECONDARY_ATTACK is basically the ENTER key.
If you want to use the arrow keys, KEY_UP and KEY_DOWN. https://sampwiki.blast.hk/wiki/Keys.


Re : Little problem on ShowPlayerDialog - Kethrios - 12.11.2013

Oh it must be a little misunderstanding.
When I mean that they press Up or Down, it's not the keys on the keyboard but the text in the dialog.

When they do it, nothing happens, they stay where they are instead of going on the roof etc...


Re: Little problem on ShowPlayerDialog - Konstantinos - 12.11.2013

In OnDialogResponse return 0 at the end.

pawn Код:
... "(Up +1)","(Up+2" ...
I don't see +1 and -1 but +1 and +2. Are you sure you posted the correct dialog?


Re : Re: Little problem on ShowPlayerDialog - Kethrios - 13.11.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
In OnDialogResponse return 0 at the end.

pawn Код:
... "(Up +1)","(Up+2" ...
I don't see +1 and -1 but +1 and +2. Are you sure you posted the correct dialog?
Hi and thanks for taking the time to answer !

Firsly, I already got return 0 at the end of the OnDialogResponse.
Then, by +1 and +2 it means that if the player is at the garage, he can go to the 1st floor (+1) or the roof (+2).

I'm really lost with this problem.


Re: Little problem on ShowPlayerDialog - Konstantinos - 13.11.2013

The problem you mentioned at the first post is:

Quote:
Originally Posted by Kethrios
Посмотреть сообщение
[..]

I'm actually testing on the 2nd level, when a cop is pressing F, then a dialog will show up asking where he would like to go, there are 2 options "Up(+1)" and "Down(-1)".

The dialog shows up without any problem, the thing is that, when the player press Up or Down, nothing happens, why ? I can't figure it out, it's driving me crazy.

[..]
But the code you posted is not for the up and down options, it's if the player is on garage and in the above quote you said the 2nd level.


Re : Little problem on ShowPlayerDialog - Kethrios - 13.11.2013

I said Up+1 and Down-1 (and Down-1 Down -2 ; Up+1 Up+2) but it means this :

Up+1 Down-1 : Player can Go up (Roof) and Down (Garage) -> He is at the 1st floor.
Down-1 Down-2 : The player can go to the 1st floor, or the garage --> He is on the roof.
Up+1 Up+2 : The player can go to the 1st floor or the the roof --> He is at the garage.

I said up or down in order to avoid sayin 1st floor, and garage everytime, but if it's not clear, I can edit to make it more understandable.


Re : Little problem on ShowPlayerDialog - Kethrios - 15.11.2013

Anyone please for some help ?


Re : Little problem on ShowPlayerDialog - Kethrios - 27.11.2013

A little up after more than 10 days, i'm stuck...