Getting information from a lisitem -
Luis- - 06.05.2015
Alright, so I am currently updating my taxi driver job. I've started coding it so that when you call a taxi, you'll be added to a waiting list, which can be viewed by any on duty taxi driver, it's all loaded into a dialog for easy viewing.
What I need to know is, how can I get the players name & id from that list?
Here's the dialog;
Re: Getting information from a lisitem -
SickAttack - 06.05.2015
Store the players on the list in a variable and then use that variable to get the player the user clicked on by using "listitem" as the index number of the variable. You only need to store the IDs of the players, you can use it to get their name, etc.
Re: Getting information from a lisitem -
Sellize - 07.05.2015
Well obviously you are making that list using some variables. Use those same variables to retrieve customer info
Re: Getting information from a lisitem -
Vince - 07.05.2015
If you select a listitem, the text that it contains will be stored in inputtext, so you can extract it from there using a splitting technique like sscanf. However, you cannot extract information that wasn't there in the first place, like the player's id.
Re: Getting information from a lisitem -
ToiletDuck - 07.05.2015
From my point of view you need something like this
pawn Код:
#define MAX_CUSTOMER (50) // 50 is Max for calling taxies per player
#define DIALOG_CUSTOMERMAIN (1) // List for Players call for Taxi
#define DIALOG_CUSTOMERCONFIRM (2) // confirmation for acxeptong player taxi call
Enum rsCustomer
{
rsUsed,
rsName[MAX_PLAYER_NAME], // Store the Player Name
rsID,
rsLocation[64],
rsTime
};
New RSInfo[MAX_CUSTOMER][rsCustomer];
//When player call for a taxi store his info
Cmd:taxi(playerid) {
For(new x = 0; x< MAX_CUSTOMER; x++) {
{
New name[MAX_PLAYER_NAME], string[128];
If(!RSInfo[x][rsUsed]) { //check if the id isnt used
GetPlayerName(playerid, name, sizeof(name));
// use strlen for storing a name of playerid, :3 not fammilar the syntax
RSInfo[x][rsID] = playerid;
RSInfo[x][rsUsed] = 1;
RSInfo[x][rsTime] = 60; //60 seconds if u use 1000 ms timer golbal or any
//store thelocation of a playerid store it under rsinfo[x][rsLocation]
Break; // wee only justneed one forthis
}
}
}
Return 1;
}
Just a sample code giving you an idea icant give.youwhat im thinking right now im on mobile:/
Then if Taxi take on tha list
Loop the Customernlist that i made a while ago
Then use the VAriables that has been stored whwn player call a taxi
Re: Getting information from a lisitem -
Konstantinos - 07.05.2015
Quote:
Originally Posted by Vince
If you select a listitem, the text that it contains will be stored in inputtext, so you can extract it from there using a splitting technique like sscanf. However, you cannot extract information that wasn't there in the first place, like the player's id.
|
Actually sscanf is not needed as "inputtext" will hold the text of the first column (only) for that listitem.
Re: Getting information from a lisitem -
MP2 - 07.05.2015
Something to note is that players might leave while you are on that dialog. I made a simple script to detect this, I'll post it later if I remember.
AW: Getting information from a lisitem -
Mencent - 07.05.2015
Hello!
Look at this example, which I just wrote.
PHP код:
if(dialogid == /* HERE THE DIALOG_ID */)
{
if(response)
{
new count;
for(new i;i<MAX_PLAYERS;i++)
{
if(HasCalledATaxi[playerid] > 0)//Change this array
{
if(count == listitem)
{
//i ist now the Player-ID
break;
}
count ++;
}
}
}
return 1;
}