SA-MP Forums Archive
Help about listitem - 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: Help about listitem (/showthread.php?tid=589358)



Help about listitem - Sensation - 18.09.2015

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.


Re: Help about listitem - rappy93 - 18.09.2015

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?


Re: Help about listitem - Sensation - 18.09.2015

how can i get ID from listitem


Re: Help about listitem - Sellize - 18.09.2015

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


Re: Help about listitem - Sensation - 18.09.2015

But I want get ID from listitem.


Re: Help about listitem - Jefff - 18.09.2015

Show ShowPlayerDialog for this, how you are using


Re: Help about listitem - Sensation - 19.09.2015

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");



Re: Help about listitem - BroZeus - 19.09.2015

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



Re: Help about listitem - Sensation - 19.09.2015

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



Re: Help about listitem - BroZeus - 19.09.2015

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?