MYSQL Help !! -
ManIsHere - 12.03.2017
Hello all. i am trying to make a dynamic tree system for decoration in house using mysql. i am just learning mysql.
so can you tell me what to do after i do
select * from tree? how do i use variables to set
TreeInfo[treeid][tPosX] , [PosY] etc... from my database when filterscript starts. and then createobject(id, posx, posy....) please help me.
thank you
Re: MYSQL Help !! -
sizeof - 12.03.2017
Depends on version of your MySQL Plugin, U must load your values in variables
Re: MYSQL Help !! -
Unte99 - 12.03.2017
Yes, you could ask someone to tell you how to do it, or, you could go on ****** and search for information where
millions of threads already exist and have what you are looking for.
Re: MYSQL Help !! -
ManIsHere - 12.03.2017
i am using MySQL R5. i didnot find it on SAMP Wiki thats why i asked here. please help me.
Re: MYSQL Help !! -
ManIsHere - 12.03.2017
help me..........................
Re: MYSQL Help !! -
ManIsHere - 13.03.2017
I Need Help. please do it fast. i know the syntax but how do i use it in loop?
i mean, i know that i can use mysql_fetch_row(or something like this) to store it in variable. now how do i createobject because how do i use it in loop? and for how long should i run the loop..... so that i can create object with each number of rows.
please help me.
Re: MYSQL Help !! -
X337 - 13.03.2017
Here's an example to loop and get data each rows:
Code:
mysql_tquery(g_Sql, "SELECT * FROM tree", "OnLoadingTree");
public OnLoadingTree()
{
new rows;
cache_get_row_count(rows);
for(new i; i < rows; i++) {
// loop each rows
// use cache_get_value_* to get field data
}
}
Re: MYSQL Help !! -
ManIsHere - 13.03.2017
Thank you very much for a example.
ill will reply back ASAP after testing. thanks.
Re: MYSQL Help !! -
ManIsHere - 13.03.2017
Can you give a example on how to store PositionX from database into a variable and use it to create Object?
Re: MYSQL Help !! -
GTLS - 13.03.2017
Instead of another example, you just need to learn it how to do it so that next time you will remember by your self how to load Objects from MySQL.
here is the link to tutorial, if you dont understand anything, just ask us. :
https://sampforum.blast.hk/showthread.php?tid=544230
Re: MYSQL Help !! -
X337 - 13.03.2017
You can use cache_get_value_name_* or cache_get_value_index_* functions.
https://sampwiki.blast.hk/wiki/MySQL/R40...lue_name_float
Re: MYSQL Help !! -
Unte99 - 13.03.2017
Quote:
Originally Posted by X337
|
Quote:
Originally Posted by ManIsHere
i am using MySQL R5. i didnot find it on SAMP Wiki thats why i asked here. please help me.
|
And why are you suggesting to get the value by the name of the row if it's faster to get the value by the index number of the row?
Re: MYSQL Help !! -
ManIsHere - 13.03.2017
i found a tutorial on forus, will that be good for me? please check.
here is Object loading code:
Code:
orward LoadObjects(limit);
public LoadObjects(limit)
{
new count, rows, fields, data[50];
cache_get_data(rows, fields);
for(new i; i < rows; i++)
{
if(count > limit)
{
printf("Number of objects exceeded limit!");
break;
}
for(new h; h < sizeof(object); h++)
{
if(object[h][ScriptID] == 0)
{
cache_get_field_content(i, "ScriptID", data); object[h][ScriptID] = strval(data);
cache_get_field_content(i, "ModelID", data); object[h][ModelID] = strval(data);
cache_get_field_content(i, "X", data); object[h][X] = floatstr(data);
cache_get_field_content(i, "Y", data); object[h][Y] = floatstr(data);
cache_get_field_content(i, "Z", data); object[h][Z] = floatstr(data);
cache_get_field_content(i, "rX", data); object[h][rX] = floatstr(data);
cache_get_field_content(i, "rY", data); object[h][rY] = floatstr(data);
cache_get_field_content(i, "rZ", data); object[h][rZ] = floatstr(data);
CreateDynamicObject(object[h][ModelID], object[h][X], object[h][Y], object[h][Z], object[h][rX], object[h][rY], object[h][rZ]);
count++;
break;
}
}
}
printf("Current objects on the server: %d",CountDynamicObjects());
return 1;
}