Help about listitem
#1

Code:
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.
Reply
#2

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?
Reply
#3

how can i get ID from listitem
Reply
#4

Getting the playerid from inputtext is what you want, I believe.
Reply
#5

But I want get ID from listitem.
Reply
#6

Show ShowPlayerDialog for this, how you are using
Reply
#7

Here is the code:
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_STYLE_LIST,"Taxi GPS",string,"Select","Cancel");
Reply
#8

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:
for(new i=0GetPlayerPoolSize(); <= ji++)
{
    if(!
IsPlayerConnected(i))continue;
    if(
CalledForTaxi[i] > 0)
    {
        if(
count != 0)strcat(string"\n");//not insert the \n at first listitem
        
strcat(stringPlayerName(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); 
Reply
#9

Quote:
Originally Posted by BroZeus
View Post
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:
for(new i=0GetPlayerPoolSize(); <= ji++)
{
    if(!
IsPlayerConnected(i))continue;
    if(
CalledForTaxi[i] > 0)
    {
        if(
count != 0)strcat(string"\n");//not insert the \n at first listitem
        
strcat(stringPlayerName(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); 
Sorry but it's not working. This is all of command and DIALOG_TAXI
PHP Code:
CMD:taxigps(playerid,params[])
{
new 
string[128];
new 
count 0;
for(new 
i=0GetPlayerPoolSize(); <= ji++)
{
    if(!
IsPlayerConnected(i))continue;
    if(
CalledForTaxi[i] > 0)
    {
        if(
count != 0)strcat(string"\n");
        
strcat(stringPlayerName(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);
        }
     } 
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)