Loading cars - 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)
+--- Thread: Loading cars (
/showthread.php?tid=624882)
Loading cars -
GoldenLion - 24.12.2016
Hi, is it possible to get data from a certain rows in MySQL? I know I can do
Код:
cache_get_value_name...(rowid...
etc but I'm trying to add dynamic vehicles system to my gamemode and only load a player's cars once he logs in. I'm planning to allow player to have like 5 slots so I can't just select one row and load data. I want to load all the 5 cars so I could do it like this: let's say I have my cars in row 1, 6, 8, 10 and 12 then I could do it like this:
Код:
cache_get_value_name(1,...
cache_get_value_name(6,...
cache_get_value_name(8,...
cache_get_value_name(10,...
cache_get_value_name(12,...
but how do I know the row ids? Do I need to create some variables called Car1, Car2, Car3, etc for each player and then load his cars one by one?
Re: Loading cars -
BiosMarcel - 24.12.2016
the cache rows are determined by the results that you get from your SELECT queries
they go from 0 to n
Some pseudo code, to show you what you could do:
PHP код:
mysql_tquery(sqlHandle, "SELECT * FROM cars WHERE Owner='Username'", "callback");
forward callback();
public callback()
{
new rowcount;
cache_get_row_count(rowcount);
for(new i = 0; i < rowcount; i++)
{
cache_get_value_name(i , "VARIABLE NAME", putInHere);
loadCar(putInHere);
}
}
Re: Loading cars -
GoldenLion - 24.12.2016
Thank you.