PDA

View Full Version : Help about listitem


Sensation
18/09/2015, 12:39 PM
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);

Hey guys i am making gps system for my taxi system but this code is not marking the ID's pos. How can i fix this. Please help me.

rappy93
18/09/2015, 12:42 PM
Not sure what you're trying to accomplish with this code. GetPlayerPos(listitem,tx,ty,tx); is not going to work because listitem doesn't return any IDs you can use for GetPlayerPos.

Can you explain to me what this script is supposed to do?

Sensation
18/09/2015, 12:47 PM
how can i get ID from listitem

Sellize
18/09/2015, 12:50 PM
Getting the playerid from inputtext is what you want, I believe.

Sensation
18/09/2015, 12:59 PM
But I want get ID from listitem.

Jefff
18/09/2015, 03:08 PM
Show ShowPlayerDialog for this, how you are using

Sensation
19/09/2015, 03:24 AM
Here is the code:
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_ST YLE_LIST,"Taxi GPS",string,"Select","Cancel");

BroZeus
19/09/2015, 05:08 AM
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 :

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_ST YLE_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);

Sensation
19/09/2015, 07:51 AM
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 :

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_ST YLE_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);
Sorry but it's not working. This is all of command and DIALOG_TAXI

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_ST YLE_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);
}
}

BroZeus
19/09/2015, 09:36 AM
Hm what is not working in that like when you type taxigps does it show dialog? If yes then when you click on player name what message does it sends you?

Sensation
19/09/2015, 09:52 AM
Hm what is not working in that like when you type taxigps does it show dialog? If yes then when you click on player name what message does it sends you?When i type /taxigps, showing dialog but when i click player name on dialog, it doesn't send message to me.

BroZeus
19/09/2015, 10:01 AM
The problem is of a spelling mistake in ShowPlayerDialog you have used DIALOG_TAXIGPS and in dialog response you have used DIALOG_TAKSIGPS

Sensation
19/09/2015, 10:10 AM
The problem is of a spelling mistake in ShowPlayerDialog you have used DIALOG_TAXIGPS and in dialog response you have used DIALOG_TAKSIGPSI fixed it but it sends me to blank message.

BroZeus
19/09/2015, 10:16 AM
Blank message means no message at all? Even not the "Seems like the target player disconnected!" message?
And also make sure that sscanf plugin is loaded correctly.

Sensation
19/09/2015, 10:28 AM
Blank message means no message at all? Even not the "Seems like the target player disconnected!" message?
And also make sure that sscanf plugin is loaded correctly.It sends message but it is only a blank message. Also sscanf plugin working correctly.

BroZeus
19/09/2015, 11:03 AM
O just noticed we are formatting into str but sending string
Use:

SCM(playerid,COLOR_LIGHTBLUE,str);

Sensation
19/09/2015, 11:41 AM
O just noticed we are formatting into str but sending string
Use:I fixed problems. Thank you very very much for your helps. By the way sorry for my bad english :)

M0HAMMAD
19/09/2015, 12:19 PM
;)
if(strcmp(cmd, "/cmd", true) == 0)
{
//if(gTeam[playerid] != TEAM_TAXI) return SendClientMessage(playerid, COLOR, "You are not a Taxi Driver !");
new string3[1024],string2[1024],count=0;
for(new i; i < MAX_PLAYERS; i++)
{
if(CalledTaxi[i] == 1)
{
count ++;
format(string3,sizeof(string3),"{FFFFFF}(%d) %s\n",i,PlayerName(i));
strcat(string2,string3, sizeof(string2));
}
}
if(count != 0)
{
ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT, "{FF0000}Need Taxi:",string2, "","{FFFFFF}Close");
SendClientMessage(playerid,COLOR,"Enter Player ID You Want");
}
if(count == 0) ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX, "{FF0000}Need Taxi:","{FF0000}No One Called Taxi.", "","{FFFFFF}Close");
}
and use GetPlayerPos(strval(inputtext),tx,ty,tx);