new Float:tx,Float:ty,Float:tz; GetPlayerPos(listitem,tx,ty,tx); SetPlayerMapIcon(playerid,40,tx,ty,tz,42,0,MAPICON_LOCAL); new str[128]; format(str,sizeof(str),"%s is marked on your map.",PlayerName(listitem)); SCM(playerid,COLOR_LIGHTBLUE,string);
for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i)) { if(CalledForTaxi[i] > 0) { format(string,sizeof(string),"%s%s\n",string,PlayerName(i)); count++; } } } ShowPlayerDialog(playerid,DIALOG_TAXIGPS,DIALOG_STYLE_LIST,"Taxi GPS",string,"Select","Cancel");
for(new i=0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i))continue;
if(CalledForTaxi[i] > 0)
{
if(count != 0)strcat(string, "\n");//not insert the \n at first listitem
strcat(string, PlayerName(i));
count++;
}
}
ShowPlayerDialog(playerid,DIALOG_TAXIGPS,DIALOG_STYLE_LIST,"Taxi GPS",string,"Select","Cancel");
//OnDialog response :
//if dialog style is list type then inputtext = listitem text which was selected by user so:
new targetid;
sscanf(inputtext, "u", targetid);
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, -1, "{ff0000}Seems like the target player disconnected!");
new Float:tx,Float:ty,Float:tz;
GetPlayerPos(targetid,tx,ty,tx);
SetPlayerMapIcon(playerid,40,tx,ty,tz,42,0,MAPICON_LOCAL);
new str[50];//128 is too big, use the size which is needed don't use too big
format(str,sizeof(str),"%s is marked on your map.",PlayerName(targetid));
SCM(playerid,COLOR_LIGHTBLUE,string);
Use strcat instead of format its a lot faster and insert the \n before the name instead of after the name the way you are doing it now will result in an extra listitem at last. Use this :
PHP Code:
|
CMD:taxigps(playerid,params[])
{
new string[128];
new count = 0;
for(new i=0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i))continue;
if(CalledForTaxi[i] > 0)
{
if(count != 0)strcat(string, "\n");
strcat(string, PlayerName(i));
count++;
}
}
ShowPlayerDialog(playerid,DIALOG_TAXIGPS,DIALOG_STYLE_LIST,"Taxi GPS",string,"Select","Cancel");
if(count == 0) return SCM(playerid,COLOR_ERROR,"Nobody called the taxi.");
return 1;
}
//OnDialogResponse
if (dialogid == DIALOG_TAKSIGPS)
{
if (response)
{
new targetid;
sscanf(inputtext, "u", targetid);
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, -1, "{ff0000}Seems like the target player disconnected!");
new Float:tx,Float:ty,Float:tz;
GetPlayerPos(targetid,tx,ty,tx);
SetPlayerMapIcon(playerid,40,tx,ty,tz,42,0,MAPICON_LOCAL);
new str[50];
format(str,sizeof(str),"%s is marked on your map.",PlayerName(targetid));
SCM(playerid,COLOR_LIGHTBLUE,string);
}
}