SA-MP Forums Archive
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: ShowPlayerDialog (/showthread.php?tid=600382)



ShowPlayerDialog - Ugaustin - 07.02.2016

hi how can I make, a dialog with distance example:

Los Santos(LSPD) - 10km
in Dialog List..

??


Re: ShowPlayerDialog - Sascha - 07.02.2016

You should create an array that includes the positions of the locations you want to be shown in the dialog.
Then you need a function to get the distance between to points (https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint).

You can set a loop that is running through your array and is getting the distance to each point.
e.g.
Код:
enum locData
{
	posName[20],
	Float:posX,
	Float:posY,
	Float:posZ
}
new YourList[][locData] =
{
	{"SomeName", 0.0, 0.0, 0.0},
	{"Someother", 123.512, 1252.123, 12.00}
};


//The following code inside your function, command or whatever
new Float:dist, string[500];
for(new n=0; n<sizeof(YourList); n++)
{
	dist = GetPlayerDistanceFromPoint(playerid, YourList[n][posX], YourList[n][posY], YourList[n][posZ]);
	if(n == 0)
		format(string, sizeof(string), "%s - %02f", YourList[n][posName], dist);
	else
		format(string, sizeof(string), "%s\n%s - %02f", string, YourList[n][posName], dist);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Distances", string, "Ok", "");



Re: ShowPlayerDialog - Ugaustin - 07.02.2016

why am I getting this??

error 032: array index out of bounds


Re: ShowPlayerDialog - Ugaustin - 07.02.2016

I made this and In game I get Server: Unknown Command..


pawn Код:
new string1[MAX_STRING],string2[MAX_STRING],string3[MAX_STRING],string4[MAX_STRING],allstrings[MAX_STRING];
                                    new Float: Position[3],
                                    Float: Distance[13];
                                    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
                                    Distance[1] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[1][0], gTeleSpawns[1][1], gTeleSpawns[1][2]);
                                    Distance[2] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[2][0], gTeleSpawns[2][1], gTeleSpawns[2][2]);
                                    Distance[3] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[3][0], gTeleSpawns[3][1], gTeleSpawns[3][2]);
                                    Distance[4] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[4][0], gTeleSpawns[4][1], gTeleSpawns[4][2]);
                                    Distance[5] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[5][0], gTeleSpawns[5][1], gTeleSpawns[5][2]);
                                    Distance[6] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[6][0], gTeleSpawns[6][1], gTeleSpawns[6][2]);
                                    Distance[7] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[7][0], gTeleSpawns[7][1], gTeleSpawns[7][2]);
                                    Distance[8] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[8][0], gTeleSpawns[8][1], gTeleSpawns[8][2]);
                                    Distance[9] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[9][0], gTeleSpawns[9][1], gTeleSpawns[9][2]);
                                    Distance[10] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[10][0], gTeleSpawns[10][1], gTeleSpawns[10][2]);
                                    Distance[11] = GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gTeleSpawns[11][0], gTeleSpawns[11][1], gTeleSpawns[11][2]);
                                    format(string1,sizeof(string1),"{FFFFFF}1. Random\n2. LS - (%.0fm)\n3. LS - (%.0fm)\n",Distance[1],Distance[2]);
                                    format(string2,sizeof(string2),"{FFFFFF}4. LS - (%.0fm)\n5. LS - (%.0fm)\n6. LS - (%.0fm)\n",Distance[3],Distance[4],Distance[5]);
                                    format(string3,sizeof(string3),"{FFFFFF}7. LS - (%.0fm)\n8. LS - (%.0fm)\n9. LS - (%.0fm)\n",Distance[6],Distance[7],Distance[8]);
                                    format(string4,sizeof(string4),"{FFFFFF}10. LS - (%.0fm)\n11. LS - (%.0fm)\n12. LS - (%.0fm)\n",Distance[9],Distance[10],Distance[11]);
                                    //format(string5,sizeof(string5),"{FFFFFF}13. LS - (%.0fm)",Distance[12]);
                                    format(allstrings,sizeof(allstrings), "%s\n%s\n%s\n%s", string1, string2, string3, string4);
                                    ShowPlayerDialog(playerid, Dialog_Tele, DIALOG_STYLE_LIST, "Teleport", allstrings, "Ok", "Cancel");