06/07/2021 20:09
(Esta mensagem foi modificada pela última vez a: 06/07/2021 20:11 por LeleziiN.)
E como eu poderia passa isso aqui para dof2?
Na callback ongamemodeinit
No topo do gm
No comando
Na callback ongamemodeinit
Código:
// open database & create tables
ScriptDBHandle = db_open("lumberjack.db");
db_query(ScriptDBHandle, "CREATE TABLE IF NOT EXISTS trees (ID INTEGER, PosX FLOAT, PosY FLOAT, PosZ FLOAT, RotX FLOAT, RotY FLOAT, RotZ FLOAT)");
db_query(ScriptDBHandle, "CREATE TABLE IF NOT EXISTS buyers (ID INTEGER, Skin INTEGER, PosX FLOAT, PosY FLOAT, PosZ FLOAT, PosA FLOAT)");
// prepare tree queries
LoadTrees = db_prepare(ScriptDBHandle, "Carregamento * das árvores");
AddTree = db_prepare(ScriptDBHandle, "Criar árvores (ID, PosX, PosY, PosZ, RotX, RotY, RotZ) VALUES (?, ?, ?, ?, ?, ?, ?)");
UpdateTree = db_prepare(ScriptDBHandle, "Atualizar árvores SET PosX=?, PosY=?, PosZ=?, RotX=?, RotY=?, RotZ=? WHERE ID=?");
RemoveTree = db_prepare(ScriptDBHandle, "Apagar as árvores pelo ID=?");
// prepare buyer queries
LoadBuyers = db_prepare(ScriptDBHandle, "SELECT * FROM buyers");
AddBuyer = db_prepare(ScriptDBHandle, "INSERT INTO buyers (ID, Skin, PosX, PosY, PosZ, PosA) VALUES (?, ?, ?, ?, ?, ?)");
UpdateBuyer = db_prepare(ScriptDBHandle, "UPDATE buyers SET Skin=?, PosX=?, PosY=?, PosZ=?, PosA=? WHERE ID=?");
RemoveBuyer = db_prepare(ScriptDBHandle, "DELETE FROM buyers WHERE ID=?");
// load trees
new id, Float: pos[3], Float: rot[3];
udb_Exists(LoadTrees, 0, DB::TYPE_INTEGER, id);
udb_Exists(LoadTrees, 1, DB::TYPE_FLOAT, pos[0]);
udb_Exists(LoadTrees, 2, DB::TYPE_FLOAT, pos[1]);
udb_Exists(LoadTrees, 3, DB::TYPE_FLOAT, pos[2]);
udb_Exists(LoadTrees, 4, DB::TYPE_FLOAT, rot[0]);
udb_Exists(LoadTrees, 5, DB::TYPE_FLOAT, rot[1]);
udb_Exists(LoadTrees, 6, DB::TYPE_FLOAT, rot[2]);
if(stmt_execute(LoadTrees))
{
print(" [Lenhador] Carregando árvores...");
new label[96];
while(stmt_fetch_row(LoadTrees))
{
No topo do gm
Código:
new
DB: ScriptDBHandle;
new
DBStatement: LoadTrees,
DBStatement: AddTree,
DBStatement: UpdateTree,
DBStatement: RemoveTree;
new
DBStatement: LoadBuyers,
DBStatement: AddBuyer,
DBStatement: UpdateBuyer,
DBStatement: RemoveBuyer;
No comando
Código:
stmt_bind_value(AddTree, 0, DB::TYPE_INTEGER, id);
stmt_bind_value(AddTree, 1, DB::TYPE_FLOAT, TreeData[id][treeX]);
stmt_bind_value(AddTree, 2, DB::TYPE_FLOAT, TreeData[id][treeY]);
stmt_bind_value(AddTree, 3, DB::TYPE_FLOAT, TreeData[id][treeZ]);
stmt_bind_value(AddTree, 4, DB::TYPE_FLOAT, TreeData[id][treeRX]);
stmt_bind_value(AddTree, 5, DB::TYPE_FLOAT, TreeData[id][treeRY]);
stmt_bind_value(AddTree, 6, DB::TYPE_FLOAT, TreeData[id][treeRZ]);
if(stmt_execute(AddTree))
{
EditingTreeID[playerid] = id;
EditDynamicObject(playerid, TreeData[id][treeObjID]);