Dialog list bug
#1

The Dialog only opens for the first person that goes to the checkpoint...any help?




Код:
// By Shabi RoxX

#include <a_samp>
#include <CheckpointManager>
#include <streamer>
//forwad your function
forward IsPlayerInArea();

main()
{
    print("\n----------------------------------");
    print("            Elevator                ");
    print("----------------------------------\n");
}




public OnGameModeInit()
{
    // you must create menu in OnGameModeInit


    SetTimer("IsPlayerInArea", 2000, true);//will repeat every 1 second to check if any player on pos :)

    SetGameModeText("Cops Robbers RPG");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public IsPlayerInArea()
{

    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    CreateDynamicCP( -1916.9716,1112.4375,48.7100, 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (1 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (2 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (3 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (4 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (5 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (6 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (7 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (8 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (9 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (10 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (11 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (12 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (13 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (14 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (15 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (16 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (17 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (18 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (19 * 5.45155), 3.0);
    CreateDynamicCP(  -1916.9716,1112.4375,57.4496 + (20 * 5.45155), 3.0);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/lift", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if	(IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,48.7100)||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (1 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (2 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (3 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (4 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (5 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (6 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (7 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (8 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (9 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (10 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (11 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (12 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (13 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (14 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (15 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (16 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (17 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (18 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (19 * 5.45155))||
	IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (20 * 5.45155)))


{

	    new Float:X, Float:Y, Float:Z;
	    for(new i=0; i < MAX_PLAYERS; i++)
	    {
	        GetPlayerPos(i, X, Y, Z);
	        if(IsPlayerConnected(i))//checking if player is connected else nothing
	        {

	           ShowPlayerDialog(i, 1, DIALOG_STYLE_LIST, "what floor do you want?", "Ground floor \nFirst Floor \nSecond Floor \nThirdFloor \nFourth Floor \nFifth Floor \nSixthFloor \nSeventh Floor \nEighth Floor \nNineth Floor \nTenthfloor \nEleventh Floor \nTwelefth Floor \nThirteenth Floor \nFourteenth Floor \nFifteenth Floor \nSixteenth Floor \nSeventeenth Floor \nEighteenth Floor \nNineteenth Floor \nRoof", "Select", "Cancel");
	           return 1;

	        }
}
}
return 1;

}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
    {
        case 1:// Our dialog!
        {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100);}
                case 1: //Ground
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (1 * 5.45155));}
                case 2: //First
                {SetPlayerPos(playerid, -1916.9716,1112.4375,48.7100+ 8.7396 + (2 * 5.45155));}
                case 3: //Second
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (3 * 5.45155));}
                case 4: //Third
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (4 * 5.45155) );}
                case 5: //Fourth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (5 * 5.45155));}
                case 6: //Fifth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (6 * 5.45155));}
                case 7: //Sixth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (7 * 5.45155));}
                case 8: //Seventh
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (8 * 5.45155));}
                case 9: //Eighth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (9 * 5.45155));}
                case 10: //Ninth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (10 * 5.45155));}
                case 11: //Tenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (11 * 5.45155));}
                case 12: //Eleventh
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (12 * 5.45155));}
                case 13: //Twelth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (13 * 5.45155));}
                case 14: //Thirteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (14 * 5.45155));}
                case 15: //Fourteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (15 * 5.45155));}
                case 16: //Fifteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (16 * 5.45155));}
                case 17: //Sixteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (17 * 5.45155));}
                case 18: //Seventeenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (18 * 5.45155));}
                case 19: //Eighteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (19 * 5.45155));}
                case 20: //Nineteenth
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (20 * 5.45155));}
                case 21: //Penthouse
                {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (21 * 5.45155));}
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply
#2

Anyone know why its doing this?
Reply
#3

pawn Код:
...
            if(IsPlayerConnected(i))//checking if player is connected else nothing
            {

               ShowPlayerDialog(i, 1, DIALOG_STYLE_LIST, "what floor do you want?", "Ground floor \nFirst Floor \nSecond Floor \nThirdFloor \nFourth Floor \nFifth Floor \nSixthFloor \nSeventh Floor \nEighth Floor \nNineth Floor \nTenthfloor \nEleventh Floor \nTwelefth Floor \nThirteenth Floor \nFourteenth Floor \nFifteenth Floor \nSixteenth Floor \nSeventeenth Floor \nEighteenth Floor \nNineteenth Floor \nRoof", "Select", "Cancel");
               return 1;//<---

            }
...
You are returning inside a loop, which will stop the loop. So as soon you have shown the dialog to 1 person, it'll stop showing it to other players. Just remove the "return 1;" and it should work as you want it to.
Reply
#4

Remove the 'return 1'.
But, you don't need this:
pawn Код:
for(new i=0; i < MAX_PLAYERS; i++)
{
    GetPlayerPos(i, X, Y, Z);
    if(IsPlayerConnected(i))//checking if player is connected else nothing
    {
        // Code...
    }
}
Because you are looping all players and checking if someone are connected, and the callback did it.
NOTE: You better use foreach to loop all online players. Click here.

Also, you can save lines using a stock:
pawn Код:
stock IsPlayerOnElevator(playerid) // Whatever you want
{
    if(IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,48.7100)) return 1;
    for (new a=1;a<=20;a++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (a * 5.45155)))
        {
            return 1;
        }
    }
    return 0;
}
pawn Код:
// If Condition
if(IsPlayerOnElevator(playerid))
{
    // Code here
}
Instead of:
pawn Код:
// If Condition
if  (IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,48.7100)||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (1 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (2 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (3 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (4 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (5 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (6 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (7 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (8 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (9 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (10 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (11 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (12 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (13 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (14 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (15 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (16 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (17 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (18 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (19 * 5.45155))||
    IsPlayerInRangeOfPoint(playerid, 9.0, -1916.9716,1112.4375,57.4496 + (20 * 5.45155)))
{
    // Code here
}
Reply
#5

Thank you both! it works! +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)