SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 15/05/2019, 07:18 PM   #1
wilking
Big Clucker
 
Join Date: May 2017
Posts: 53
Reputation: 0
Default how to get data from query

my id in sqlid = 70 .

i have

Code:
stock LoadVeh(playerid) {
	new string[128];
	format(string, sizeof(string), "SELECT * FROM `veh` where vID= %d ", GetPlayerSQLId(playerid));
	mysql_function_query(MainPipeline, string , true, "OnLoadVeh", "");
}
and

Code:
forward OnLoadVeh();
public OnLoadVeh() {

	new
		iFields,
		iRows,
		szResult[128];

	cache_get_data(iRows, iFields, MainPipeline);
	cache_get_field_content(0, "vID", szResult, MainPipeline); idveh= strval(szResult);
	cache_get_field_content(0, "vPrice", szResult, MainPipeline); priceveh= strval(szResult);

	return 1;
}
then i want get vID from table `veh` , i used

Code:
CMD:checkvehid(playerid, params[]){

	LoadVeh(playerid);

	new str[128];
	format(str, sizeof(str), "your veh id : %d",  idveh);
	SendClientMessage(playerid, -1, str);

	return 1;
}
but result is " your veh id : 0 "
If it's right , it's " your veh id : 70 "

help me , pleaseee !
wilking is offline   Reply With Quote
Old 16/05/2019, 02:29 AM   #2
wilking
Big Clucker
 
Join Date: May 2017
Posts: 53
Reputation: 0
Default Re: how to get data from query

help me , pleaseee
wilking is offline   Reply With Quote
Old 16/05/2019, 02:52 AM   #3
xNinJaa
Little Clucker
 
xNinJaa's Avatar
 
Join Date: Mar 2019
Location: Morocco
Posts: 4
Reputation: 0
Default Re: how to get data from query

Quote:
select 'accounts', count(*) from accounts
union
select 'admins', count(*) from accounts where admin > 0
union
select 'vips', count(*) from accounts where vip > 0
union
select 'bans', count(*) from bans
xNinJa
__________________
[ENG] .s2.gta-multiplayer.cz:7777 WTLS 2 (Singleplayer Features)
[ENG] .s3.gta-multiplayer.cz:7777 WTLS 3 (Singleplayer Features)

- Many features from singleplayer
- Pool, basketball and Poker Texas Holdem minigames, singleplayer race and other challenges
- Video game QUB3D from GTA 4
- Roulettes, blackjack, slot machines, video poker and horse-betting
- Stock market BAWSAQ from GTA 5
- Phone with a lot of features from GTA Online
- Missions from Big Smoke, Sweet, Zero, Cesar or Woozie!
- Gang wars over 100 gang hoods
- More than 30 jobs (police, paramedic, firefighter, burglar, pimp, valet pizza-boy and more)
- Gyms, strip clubs, clothes shops, hidden packages, oysters, spray tags, horseshoes and more
xNinJaa is offline   Reply With Quote
Old 16/05/2019, 06:28 AM   #4
wilking
Big Clucker
 
Join Date: May 2017
Posts: 53
Reputation: 0
Default Re: how to get data from query

i can't get data . select * from `veh` where vID = %d , getplayersqlid .

then if it right . i'll receive data is id = 70.

but i receive id = 0 .

I didn't know where I was wrong
wilking is offline   Reply With Quote
Old 16/05/2019, 10:34 AM   #5
KeyOfKey
Big Clucker
 
KeyOfKey's Avatar
 
Join Date: Apr 2019
Posts: 88
Reputation: 3
Default Re: how to get data from query

Are you sure you're assigning the vID ownership to the player? Your code OnLoadVeh is a bit strange.
__________________
An alternative to PasteBin: CodeTainer
Encrypted pastes - Passworded pastes - Private pastes. All your pastes, in one place.
KeyOfKey is offline   Reply With Quote
Old 16/05/2019, 10:43 AM   #6
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 553
Reputation: 90
Default Re: how to get data from query

You cannot get the result directly with threaded queries.

Move format and SendClientMessage in `OnLoadVeh` callback. Pass `playerid` in the callback and don't use global variables like that. If you execute query each time, use locals. Otherwise store it once in a global array.
Calisthenics 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
loading data from 2 tables in 1 query ax1 Scripting Help 2 24/01/2017 06:18 PM
Is it good to save a lot of data with one query? ax1 Scripting Help 3 12/12/2016 07:34 AM
Data from array to mysql query thimo Scripting Help 5 04/12/2014 09:04 PM
Lost data in a query Hornet600 Help Archive 1 15/03/2011 04:00 PM
Query doesn't insert data into DB! WTF? Vince Help Archive 0 17/07/2009 11:03 AM


All times are GMT. The time now is 12:38 AM.


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