SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/09/2016, 07:07 AM   #1
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default MySQL Selection

Hello, I want to make a command to display a dialog (DIALOG_STYLE_LIST), it lists all the created houses in the server, the houses system is based on MySQL database, anyway, I know how to list the houses, but my question is that if someone chooses a house, I want to display him a dialog: Remove House, Edit House Price. So how to know which house did he choose?
Ahmed21 is offline   Reply With Quote
Old 09/09/2016, 07:12 AM   #2
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,759
Reputation: 754
Default Re: MySQL Selection

https://wiki.sa-mp.com/wiki/OnDialogResponse

inputtext[] - The text entered into the input box by the player or the selected list item text.

You can compare the inputtext, which would be the text of the selected list item as described on the wiki. Or you could use listitem, and add it up to the number of the page multiplied by the results per page.

If you want the easy way in, then go for the first option.
SickAttack is offline   Reply With Quote
Old 09/09/2016, 07:15 AM   #3
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default Re: MySQL Selection

Quote:
Originally Posted by SickAttack View Post
https://wiki.sa-mp.com/wiki/OnDialogResponse

inputtext[] - The text entered into the input box by the player or the selected list item text.

You can compare the inputtext, which would be the text of the selected list item as described on the wiki. Or you could use listitem, and add it up to the number of the page multiplied by the results per page.

If you want the easy way in, then go for the first option.
If I make a list dialog, first option is Hai and 2nd is Bai.

If he chooses the 2nd option, the inputtext will be "Bai"?
Ahmed21 is offline   Reply With Quote
Old 09/09/2016, 07:19 AM   #4
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,759
Reputation: 754
Default Re: MySQL Selection

Quote:
Originally Posted by Ahmed21 View Post
If I make a list dialog, first option is Hai and 2nd is Bai.

If he chooses the 2nd option, the inputtext will be "Bai"?
Exactly.
SickAttack is offline   Reply With Quote
Old 09/09/2016, 07:28 AM   #5
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,266
Reputation: 366
Default Re: MySQL Selection

Quote:
Originally Posted by SickAttack View Post
Exactly.
Actually it will be "listitem Bai"

I've just tested this, didn't know about it lol, Thanks for info SickAttack. : o
jlalt is offline   Reply With Quote
Old 09/09/2016, 07:32 AM   #6
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,759
Reputation: 754
Default Re: MySQL Selection

Quote:
Originally Posted by jlalt View Post
Actually it will be "listitem Bai"

I've just tested this, didn't know about it lol, Thanks for info SickAttack. : o
No, it's just "Bai".

pawn Code:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "1", "a\nb\nc", "1", "2");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    printf("%s", inputtext);
    return 1;
}

SickAttack is offline   Reply With Quote
Old 09/09/2016, 07:34 AM   #7
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,266
Reputation: 366
Default Re: MySQL Selection

Quote:
Originally Posted by SickAttack View Post
No, it's just "Bai".

pawn Code:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Server Rules", "a\nb\nc", "Yes", "No");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    printf("%s", inputtext);
    return 1;
}

oh, yea you're correct lol I forgot I put listitem word in the print function lol.
jlalt is offline   Reply With Quote
Old 09/09/2016, 08:02 AM   #8
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default Re: MySQL Selection

So the dialog is like this:
House ID : House Title
0: The cute house
1: Great houzzy
2: lolBb
3: AmmuHouse

Should I do this at the response?

PHP Code:
for(new 0MAX_HOUSESi++)
{
     new 
ChosenHouse = -1;
     if(
hInfo[i][hID] == hInfo[strval(inputtext[0..3])][hID])
     {
          
ChosenHouse i;
     }

Ahmed21 is offline   Reply With Quote
Old 09/09/2016, 08:11 AM   #9
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,759
Reputation: 754
Default Re: MySQL Selection

You could do that, or you could put the house ID first and get it directly. Or you could do the second option I described above. It's up to you, really.
SickAttack is offline   Reply With Quote
Old 09/09/2016, 08:38 AM   #10
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default Re: MySQL Selection

Okay thank you.
Ahmed21 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
Ordered mysql selection Ahmed21 Scripting Help 5 23/08/2016 04:54 PM
Avoid Class Selection[+rep][MYSQL] vassilis Scripting Help 2 27/01/2015 04:16 AM
MySQL Selection fails Sk1lleD Scripting Help 8 26/12/2013 02:42 PM
Use a Filterscripts Class Selection Instead of Gamemode Class Selection Eminem 2ka9 Scripting Help 12 04/08/2012 05:00 AM


All times are GMT. The time now is 01:57 PM.


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