SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/05/2020, 03:44 AM   #1
OdgFox
Little Clucker
 
Join Date: Mar 2017
Posts: 27
Reputation: 0
Cool Doubt with Mysql and Samp

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!
OdgFox is offline   Reply With Quote
Old 14/05/2020, 07:54 AM   #2
Shaheen
Huge Clucker
 
Shaheen's Avatar
 
Join Date: Feb 2016
Location: Qatar
Posts: 221
Reputation: 24
Default Re: Doubt with Mysql and Samp

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


Add Me On Discord: Nightmare#6799
Shaheen is offline   Reply With Quote
Old 14/05/2020, 01:16 PM   #3
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: Doubt with Mysql and Samp

Here is more information on how to use sscanf:
https://forum.sa-mp.com/showthread.php?t=570927
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 14/05/2020, 03:25 PM   #4
OdgFox
Little Clucker
 
Join Date: Mar 2017
Posts: 27
Reputation: 0
Default Re: Doubt with Mysql and Samp

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://forum.sa-mp.com/showthread.php?t=223561 but is very old and i don't want add that on my GM.
OdgFox is offline   Reply With Quote
Old 14/05/2020, 04:51 PM   #5
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: Doubt with Mysql and Samp

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.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009

Last edited by Kwarde; 15/05/2020 at 03:02 AM.
Kwarde is offline   Reply With Quote
Old 14/05/2020, 11:28 PM   #6
OdgFox
Little Clucker
 
Join Date: Mar 2017
Posts: 27
Reputation: 0
Default Re: Doubt with Mysql and Samp

Thanks for your help ♥
OdgFox 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
Doubt with mysql r41-2 Jose_grana Scripting Help 1 24/07/2018 02:12 PM
Doubt with MySQL Sc0pion Scripting Help 5 15/07/2015 10:16 PM
MySQL doubt Fernado Samuel Scripting Help 2 15/04/2013 06:22 PM
MySQL doubt LoveYouBoth Scripting Help 14 06/03/2013 06:08 PM
MySQL doubt Fernado Samuel Scripting Help 1 15/01/2013 10:19 PM


All times are GMT. The time now is 11:05 PM.


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