Doubt with Mysql and Samp
#1

Hello, I would like to know how I can take 2 values ​​from the same field, for example, it looks like this in my database:

V_KEY_1
1,2


V_Key_1 is the name of the column,
1 is the sqlid of the vehicle
2 is the type of the key (1 for owners and 2 for friends)

...

My question is how i can get 1 and 2 per separate in the same code.. їCan you help me? Thanks!
Reply
#2

You can make use of sscanf to achieve this.
PHP Code:

if(sscanf(params"p<,>fff"xyz))
{
    
Usage(playerid"teleport <x, y, z>");

here is an example,
it just tells to separately enter x y and z with commas between them,
if you show the code i can provide you with more details... (Maybe)
Reply
#3

Here is more information on how to use sscanf:
https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#4

Thanks for your time, i want to make some like this

Code
Code:
new newload[10][32];
explode("This,is,a,string",",",newload);
printf("%s-%s-%s-%s",newload[0],newload[1],newload[2],newload[3]);
That code show
Code:
This-is-a-string
їI can do with sscanf too?

I take that code from https://sampforum.blast.hk/showthread.php?tid=223561 but is very old and i don't want add that on my GM.
Reply
#5

Even though your code wouldn't compile, yes:
pawn Code:
new newload[10][32];
newload[0] = "This,is,a,string";
sscanf(newload[0], "p<,>s[32]s[32]s[32]s[32]", newload[0], newload[1], newload[2], newload[3]);
printf("%s-%s-%s-%s", newload[0], newload[1], newload[2], newload[3]);
Once again, I refer to that URL I sent, it explains very well how sscanf works.
Reply
#6

Thanks for your help ♥
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)