How to Extract values from a string ? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to Extract values from a string ? (
/showthread.php?tid=106803)
How to Extract values from a string ? -
Alice[WS] - 05.11.2009
Hi ! I'm actually scripting a shop system, where people can buy or sell some stuffs from their inventories. I'm having some problems for the buying part, as the prices and the quantities aren't always the same (setted by the seller).
So i have to extract the values from the " Menu row" they selected, to take the money, and give them the stuffs they bought.
It's hard to explain so i took a screen shot :
How can i do ?
I also add the script of the menu, dunno if it can help.
Код:
public CreateAKBulletsMenus()
{
AK47Bullets = CreateMenu("AK47 Bullets", 2, 200.0, 100.0, 150.0, 150.0);
new quantity[240];
for(new i = 0; i < sizeof(SHOP); i++)
{
if(SHOP[i][Item] == 24)
{
if(SHOP[i][Quantity] > 0)
{
format(quantity,240,"%d x AK47 Bullets",SHOP[i][Quantity]);
AddMenuItem(AK47Bullets, 0, quantity);
format(quantity,240," %d $",SHOP[i][Price]);
AddMenuItem(AK47Bullets, 1, quantity);
}
}
}
AddMenuItem(AK47Bullets, 0, "[Exit]");
}
Re: How to Extract values from a string ? -
MadeMan - 05.11.2009
The same way you put these prices when making the menu.
And to get value from string use strval(string[]).
Re: How to Extract values from a string ? -
Alice[WS] - 05.11.2009
Quote:
Originally Posted by MadeMan
The same way you put these prices when making the menu.
And to get value from string use strval(string[]).
|
I don't understand :S.
How can i do using OnPlayerSelectedMenuRow(playerid, row) ?
Re: How to Extract values from a string ? -
-xy! - 05.11.2009
string is a character set, which may represent a text, phrase, word and so on.
Examples
By declaring this array, it is initially looks like this:
new StringTest [10], (can hold a string with up to 10 chars)
[][][][][][][][][][]
But when I hold her say hello, looks like this:
[H][e][l][l][o][\0][][][][]
this is the basics.
(sorry my bad english)