SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/09/2015, 12:39 PM   #1
Sensation
Big Clucker
 
Join Date: Jul 2014
Posts: 81
Reputation: 3
Default Help about listitem

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.
Sensation is offline   Reply With Quote
Old 18/09/2015, 12:42 PM   #2
rappy93
Huge Clucker
 
rappy93's Avatar
 
Join Date: Mar 2012
Location: Romania
Posts: 449
Reputation: 18
Default Re: Help about listitem

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?
__________________
Nothing.
rappy93 is offline   Reply With Quote
Old 18/09/2015, 12:47 PM   #3
Sensation
Big Clucker
 
Join Date: Jul 2014
Posts: 81
Reputation: 3
Default Re: Help about listitem

how can i get ID from listitem
Sensation is offline   Reply With Quote
Old 18/09/2015, 12:50 PM   #4
Sellize
Gangsta
 
Sellize's Avatar
 
Join Date: Jan 2013
Location: (ง ͠ ͟ل͜ ͡)ง fight me irl
Posts: 708
Reputation: 293
Default Re: Help about listitem

Getting the playerid from inputtext is what you want, I believe.
__________________
dead
Sellize is offline   Reply With Quote
Old 18/09/2015, 12:59 PM   #5
Sensation
Big Clucker
 
Join Date: Jul 2014
Posts: 81
Reputation: 3
Default Re: Help about listitem

But I want get ID from listitem.
Sensation is offline   Reply With Quote
Old 18/09/2015, 03:08 PM   #6
Jefff
Banned
 
Join Date: Dec 2007
Posts: 2,593
Reputation: 326
Default Re: Help about listitem

Show ShowPlayerDialog for this, how you are using
Jefff is offline   Reply With Quote
Old 19/09/2015, 03:24 AM   #7
Sensation
Big Clucker
 
Join Date: Jul 2014
Posts: 81
Reputation: 3
Default Re: Help about listitem

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");
Sensation is offline   Reply With Quote
Old 19/09/2015, 05:08 AM   #8
BroZeus
High-roller
 
BroZeus's Avatar
 
Join Date: Jan 2014
Location: India
Posts: 1,398
Reputation: 173
Default Re: Help about listitem

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


"Be the change that you wish to see in the world."

Check out my Github profile!
BroZeus is offline   Reply With Quote
Old 19/09/2015, 07:51 AM   #9
Sensation
Big Clucker
 
Join Date: Jul 2014
Posts: 81
Reputation: 3
Default Re: Help about listitem

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);
        }
     } 
Sensation is offline   Reply With Quote
Old 19/09/2015, 09:36 AM   #10
BroZeus
High-roller
 
BroZeus's Avatar
 
Join Date: Jan 2014
Location: India
Posts: 1,398
Reputation: 173
Default Re: Help about listitem

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


"Be the change that you wish to see in the world."

Check out my Github profile!
BroZeus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
listitem name yellow Scripting Help 3 30/03/2015 03:33 PM
Listitem +rep iBots Scripting Help 5 12/07/2014 06:22 AM
Getting the name of listitem Nimrodcame General 5 16/05/2013 07:28 PM
Get Listitem Name Muhamed.pwn Scripting Help 8 01/09/2012 11:10 PM
Listitem [HELP] Salsa Scripting Help 1 11/10/2011 07:11 AM


All times are GMT. The time now is 06:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.