Jump to content

kyleflow

Advanced members
  • Content Count

    230
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by kyleflow

  1. Work like a charm thanks to you @Jonathan
  2. @Jonathan, thanks for the lengthy explanation. The Check_CG_HechengBS() that I have here is the default script i get from the Lucky Server Files and I did not know that they disregards totally the usage of catalyst or even the fruit. Lets says I able to find the original Check_CG_HechengBS() script, I could then implement the said fruit with manipulation of STATE_HCGLJB right ? Am I able to understand exactly on your explanation or not ? Thanks a lot.
  3. What so difference. You are trying to make a quest that ask player to kill certain mobs. The post have the script for it. You can just edit the quest to give a summon scroll after the quota of the kills is meet. To instantly spawn, im not sure
  4. What so difference. You are trying to make a quest that ask player to kill certain mobs. The post have the script for it.
  5. https://pkodev.net/topic/1098-create-a-quest/?tab=comments#comment-7137 You may refer into this post. There are step on making quest for killing mobs. Still I also fail to made it work properly. But this will give you an idea on how the scripting should look like.
  6. Change the value of 'a' here into 1 making it 100% combine rate. How do I made the 100 combine fruit item to change that 'a' value. function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv ) Item_Lv = Item_Lv - 1 if Item_Type == 49 or Item_Type == 50 then local a local b if Item_Lv < 3 then a = 1 b = Percentage_Random ( a ) elseif Item_Lv == 3 then a = 0.9 b = Percentage_Random ( a ) elseif Item_Lv == 4 then a = 0.8 b = Percentage_Random ( a ) elseif Item_Lv == 5 then a = 0.7 b = Percentage_Random ( a ) elseif Item_Lv == 6 then a = 0.6 b = Percentage_Random ( a ) elseif Item_Lv == 7 then a = 0.5 b = Percentage_Random ( a ) elseif Item_Lv == 8 then a = 0.4 b = Percentage_Random ( a ) elseif Item_Lv == 9 then a = 0.3 b = Percentage_Random ( a ) end return b else LG( "Hecheng_BS","probability check determine item type is not a gem" ) return 0 end end
  7. kyleflow

    Create a Quest

    Why wont the quest appear inside the NPC i chosed. Can anyone clarify what other setting do I need to do for it to appear ?
  8. I have been scripting some quest mission based on the quest guide made by Angelix and I put the MissionID inside the chosen NPC with AddNpcMission but it wont appear on the NPC. How do I made sure the quest to appear ? can anyone share all the necessary setup for quest to be able to work properly other than making the mission itself
  9. Using this script give reputation but its not auto updated. need to relog before can see changes in reputation. Any ways to make it work like normal reputation ?
  10. None of this script is mine. The contribution is already forge in the script itself. Some script is not named but I declared that its not mine and can be found in the forum itself. 1. This file should be followed the script LuaSQL.Directory location. -- *********************************** -- Sample Lua-SQL System -- Requires: SQL Server 2005 -- By Sultan | V3ct0r -- *********************************** local PLUGIN_NAME = '[[LUA-SQL System]]' local PLUGIN_VERSION = '0.2' local PLUGIN_AUTHOR = 'Sultan | V3ct0r' --[[ ****************** ** Version: 0.2 ** ****************** [*] Slightly faster and less lag on execution [*] Edited LuaSQL.LG function to generate new files instead of editing Query.txt [*] Added LuaSQL.LG for every sample function to trace players inside new file Logs.txt [*] Removed/Edited few unneccessary stuffs from V0.1 ****************** ** Version: 0.1 ** ****************** [*] Use SQL Query directly using your scripts! [*] Built in the extension, there are few sample SQL Queries: AddMallPoints, AddCreditsPoints, ChangePlayerName, and more! [*] Requires GetPlayerByName if used by &lua command [*] Built in the extension the GetPlayerByName function, if it isn't exists in your files it will add it [*] You can freely add any SQL Query Execute function you wish for [*] This system will only generate UPDATES to SQL, you cannot "GET" any data from SQL [*] Requires SQL 2005 and above to use [*] For more information & details: http://forum.maindev.ru/threads/npc-dlja-nadoedalok-skajpa.19514/#post-159439 ]]-- -- -------------------------- -- Display loading message on startup -- -------------------------- print(">> Loading extension: "..PLUGIN_NAME) print(" [Version: "..PLUGIN_VERSION.."] from "..PLUGIN_AUTHOR) -- ------------------------ -- LUA-SQL ::DO NOT TOUCH:: -- ------------------------ do LuaSQL = {} LuaSQL.Directory = GetResPath('script\\extension\\Lua-SQL\\'); LuaSQL.Host = "(local)"; LuaSQL.User = "sa"; LuaSQL.Pass = "Y87dc#$98"; LuaSQL.LG = function(file_name,text) local file = LuaSQL.Directory..file_name..'.txt' LogFile = io.open(file,'a') LogFile:write("["..os.date().."]\t"..text.."\n") LogFile:close() end LuaSQL.Execute = function(query) LuaSQL.LG('Query','Executed Query: ['..query..']'); os.execute("sqlcmd -S "..LuaSQL.Host.." -U "..LuaSQL.User.." -P "..LuaSQL.Pass.." -Q \""..query.."\" 1>NUL 2>NUL"); end -- if GetPlayerByName is nil, it will generate if(GetPlayerByName == nil)then Roles = {} Timer = cha_timer cha_timer = function(r,f,t) if(IsPlayer(r) == 1)then local characterName = GetChaDefaultName(r) if(Roles[characterName] == nil)then Roles[characterName] = r end end Timer(r,f,t) end GetPlayerByName = function(name) if(Roles[name] ~= nil)then return Roles[name] end return nil end end end -- ------------------------ -- LUA-SQL Functions -- ------------------------ --[[ ***************************** ** Sample Custom Functions ** ***************************** [*]: AddMallPoints(cha,points) => Requires Userdata to grant Mall Points [*]: AddCreditsPoints(cha,points) => Requires Userdata to grant Credits [*]: ChangePlayerName(cha,newName) => Requires Userdata to change players name [*]: ChangeGuildName(guildID,newName) => Requires Guild ID to change guild name [*]: Ban(cha) => Will ban character by Userdata [*]: UnBan(account Name) => Will unban character by account P/S: You can add yours, just use one of samples below and create your own. @FAQ [How To Use]: Example: &lua AddMallPoints("Player Name",1000) &lua ChangeGuildName(1,"New Guild Name") &lua Ban("Account Name") ]]-- function AddMallPoints(cha,points) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE tradedb.dbo.AccountInfo SET Money = Money + "..points.." WHERE accName = '"..accountName.."'") LuaSQL.LG('Logs','[AddMallPoints] = Account name['..accountName..'] successfully added '..points..' mall points'); end end function AddCreditsPoints(cha,points) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE GameDB.dbo.account SET credits = credits + "..points.." WHERE act_name = '"..accountName.."'") LuaSQL.LG('Logs','[AddCreditsPoints] = Account name['..accountName..'] successfully added '..points..' credits'); end end function ChangePlayerName(cha,newName) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local characterName,characterID = GetChaDefaultName(cha),GetCharID(cha) LuaSQL.Execute("UPDATE GameDB.dbo.character SET cha_name = '"..newName.."' WHERE cha_id = '"..characterID.."'") LuaSQL.LG('Logs','[ChangePlayerName] = Character name['..characterName..'] with ID['..characterID..'] successfully changed name to ['..newName..']'); end end function ChangeGuildName(guildID,newName) LuaSQL.Execute("UPDATE GameDB.dbo.guild SET guild_name = '"..newName.."' WHERE guild_id = '"..guildID.."'") LuaSQL.LG('Logs','[ChangeGuildName] = Guild Name['..GetGuildName(guildID)..'] with ID['..guildID..'] successfully changed name to ['..newName..']'); end function Ban(cha) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'True' WHERE name = '"..accountName.."'") LuaSQL.LG('Logs','[Ban] = Account name['..accountName..'] was successfully banned'); -- kick cha local pkt = GetPacket() WriteCmd(pkt,1505) SendPacket(cha,pkt) end end function UnBan(accountName) LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'False' WHERE name = '"..accountName.."'") LuaSQL.LG('Logs','[UnBan] = Account name['..accountName..'] was successfully banned'); end 2. Need to put this script in any other existing files such as the NPCScript.lua dofile(GetResPath("script/extension/Lua-SQL/init.lua")) 3. Put this in ItemEffect.lua function ImpsPointCard ( role , Item ) local points = AddMallPoints(role,100) if points == 1 then SystemNotice(role ,"You just got 100 points !") end end function ImpsPointCard10 ( role , Item ) local points = AddMallPoints(role,10) if points == 1 then SystemNotice(role ,"You just got 100 points !") end end function ImpsPointCard15 ( role , Item ) local points = AddMallPoints(role,15) if points == 1 then SystemNotice(role ,"You just got 100 points !") end end You may change the item name but it need to be the same as in Iteminfo.txt and compile it in client afterward. 4. Put this in the iteminfo.txt 7295 100IMP in a Bottle q0078 10130005 0 0 0 0 0 0 31 0 0 0 0 0 1 1 1 1 99 0 1000 -1,-2,-2,-2 0 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2 0 0 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0 0,0 0,0 0 0 0 0 0 0 0 0 0 ImpsPointCard 0 0 0 0,0 0 0 IMP in a bottle 0 You can replicate the amount and change also the itemid based on your liking. Hope this help.
  11. did try both luasql and did use the same script.. return the same problem -- *********************************** -- Sample Lua-SQL System -- Requires: SQL Server 2005 -- By Sultan | V3ct0r -- *********************************** local PLUGIN_NAME = '[[LUA-SQL System]]' local PLUGIN_VERSION = '0.2' local PLUGIN_AUTHOR = 'Sultan | V3ct0r' --[[ ****************** ** Version: 0.2 ** ****************** [*] Slightly faster and less lag on execution [*] Edited LuaSQL.LG function to generate new files instead of editing Query.txt [*] Added LuaSQL.LG for every sample function to trace players inside new file Logs.txt [*] Removed/Edited few unneccessary stuffs from V0.1 ****************** ** Version: 0.1 ** ****************** [*] Use SQL Query directly using your scripts! [*] Built in the extension, there are few sample SQL Queries: AddMallPoints, AddCreditsPoints, ChangePlayerName, and more! [*] Requires GetPlayerByName if used by &lua command [*] Built in the extension the GetPlayerByName function, if it isn't exists in your files it will add it [*] You can freely add any SQL Query Execute function you wish for [*] This system will only generate UPDATES to SQL, you cannot "GET" any data from SQL [*] Requires SQL 2005 and above to use [*] For more information & details: http://forum.maindev.ru/threads/npc-dlja-nadoedalok-skajpa.19514/#post-159439 ]]-- -- -------------------------- -- Display loading message on startup -- -------------------------- print(">> Loading extension: "..PLUGIN_NAME) print(" [Version: "..PLUGIN_VERSION.."] from "..PLUGIN_AUTHOR) -- ------------------------ -- LUA-SQL ::DO NOT TOUCH:: -- ------------------------ do LuaSQL = {} LuaSQL.Directory = GetResPath('script\\extension\\Lua-SQL\\'); LuaSQL.Host = "(local)"; LuaSQL.User = "sa"; LuaSQL.Pass = "Y87dc#$98"; LuaSQL.LG = function(file_name,text) local file = LuaSQL.Directory..file_name..'.txt' LogFile = io.open(file,'a') LogFile:write("["..os.date().."]\t"..text.."\n") LogFile:close() end LuaSQL.Execute = function(query) LuaSQL.LG('Query','Executed Query: ['..query..']'); os.execute("sqlcmd -S "..LuaSQL.Host.." -U "..LuaSQL.User.." -P "..LuaSQL.Pass.." -Q \""..query.."\" 1>NUL 2>NUL"); end -- if GetPlayerByName is nil, it will generate if(GetPlayerByName == nil)then Roles = {} Timer = cha_timer cha_timer = function(r,f,t) if(IsPlayer(r) == 1)then local characterName = GetChaDefaultName(r) if(Roles[characterName] == nil)then Roles[characterName] = r end end Timer(r,f,t) end GetPlayerByName = function(name) if(Roles[name] ~= nil)then return Roles[name] end return nil end end end -- ------------------------ -- LUA-SQL Functions -- ------------------------ --[[ ***************************** ** Sample Custom Functions ** ***************************** [*]: AddMallPoints(cha,points) => Requires Userdata to grant Mall Points [*]: AddCreditsPoints(cha,points) => Requires Userdata to grant Credits [*]: ChangePlayerName(cha,newName) => Requires Userdata to change players name [*]: ChangeGuildName(guildID,newName) => Requires Guild ID to change guild name [*]: Ban(cha) => Will ban character by Userdata [*]: UnBan(account Name) => Will unban character by account P/S: You can add yours, just use one of samples below and create your own. @FAQ [How To Use]: Example: &lua AddMallPoints("Player Name",1000) &lua ChangeGuildName(1,"New Guild Name") &lua Ban("Account Name") ]]-- function AddMallPoints(cha,points) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE tradedb.dbo.AccountInfo SET Money = Money + "..points.." WHERE accName = '"..accountName.."'") LuaSQL.LG('Logs','[AddMallPoints] = Account name['..accountName..'] successfully added '..points..' mall points'); end end function AddCreditsPoints(cha,points) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE GameDB.dbo.account SET credits = credits + "..points.." WHERE act_name = '"..accountName.."'") LuaSQL.LG('Logs','[AddCreditsPoints] = Account name['..accountName..'] successfully added '..points..' credits'); end end function ChangePlayerName(cha,newName) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local characterName,characterID = GetChaDefaultName(cha),GetCharID(cha) LuaSQL.Execute("UPDATE GameDB.dbo.character SET cha_name = '"..newName.."' WHERE cha_id = '"..characterID.."'") LuaSQL.LG('Logs','[ChangePlayerName] = Character name['..characterName..'] with ID['..characterID..'] successfully changed name to ['..newName..']'); end end function ChangeGuildName(guildID,newName) LuaSQL.Execute("UPDATE GameDB.dbo.guild SET guild_name = '"..newName.."' WHERE guild_id = '"..guildID.."'") LuaSQL.LG('Logs','[ChangeGuildName] = Guild Name['..GetGuildName(guildID)..'] with ID['..guildID..'] successfully changed name to ['..newName..']'); end function Ban(cha) if(type(cha) ~= 'userdata')then cha = GetPlayerByName(cha) end if(cha ~= nil)then local accountName = GetActName(cha) LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'True' WHERE name = '"..accountName.."'") LuaSQL.LG('Logs','[Ban] = Account name['..accountName..'] was successfully banned'); -- kick cha local pkt = GetPacket() WriteCmd(pkt,1505) SendPacket(cha,pkt) end end function UnBan(accountName) LuaSQL.Execute("UPDATE AccountServer.dbo.account_login SET ban = 'False' WHERE name = '"..accountName.."'") LuaSQL.LG('Logs','[UnBan] = Account name['..accountName..'] was successfully banned'); end This one is from vector and I change the database location and it able to connect with luasql.dll and i'm able to use the function to insert imp with GM account. So the question now, how do i made a function based on above connection setting for IMP card or Killing mobs and get imps ? I tried cross reference it with existing script in forum but after few tries. still fail.
  12. 1. Yes I got a loaded prompt in GS console. 2. I'm using the later version with 1.36 and 1.38 in the zip files. I use 1.36 since my server files is 1.36. 3. Using all the LuaSQL.lua script found especially shared by Angelix, and few other posting and every and each time it return a nil value.
  13. Every time I try to call the injected LuaSQL.dll in GS, it return a nil value. I tried all the guide script in the forum but none able to work. If its not an issue, can anyone gave their working 1.36 GS with loaded dll and their lua function to call for imp
  14. kyleflow

    LuaSQL (DLL)

    does the second statement should be use in the LuaSQL ? from my undestanding, I should connect first and prompt the second command so that i can query my function afterward? is that the correct step or its not ?
  15. Is there a reason this C coding for LuaSQL.dll is not responding with LuaSQL.lua query ? should i call LuaSQL in query or LuaSql ? #include "stdafx.h" #include <future> #include "LuaSQL.h" #include "Lua.h" #include "Sql.h" void ExecuteQuery(char* query, char* host, char* user, char* pass) { // Connect to sql server SQL Sql(host, user, pass); // Allocate statement handle if (Sql.retcode == SQL_SUCCESS || Sql.retcode == SQL_SUCCESS_WITH_INFO) { Sql.retcode = SQLAllocHandle(SQL_HANDLE_STMT, Sql.hdbc, &Sql.hstmtA); // Execute query Sql.retcode = SQLExecDirectA(Sql.hstmtA, (SQLCHAR*)query, SQL_NTS); // Check for errors if (Sql.retcode == SQL_SUCCESS_WITH_INFO || Sql.retcode == SQL_ERROR) { //Sql.DisplayErrors(SQL_HANDLE_STMT, Sql.hstmt); } // Free statement handle SQLFreeHandle(SQL_HANDLE_STMT, Sql.hstmtA); } } std::vector<std::future<void>> pending_queries; int ExecuteQueryAsync(lua_State *L) { if (lua_gettop(L) != 4) { return 0; } if (lua_isstring(L, 1) == 0) { return 0; } if (lua_isstring(L, 2) == 0) { return 0; } if (lua_isstring(L, 3) == 0) { return 0; } if (lua_isstring(L, 4) == 0) { return 0; } char* hostPtr = lua_tostring(L, 1); char* userPtr = lua_tostring(L, 2); char* passPtr = lua_tostring(L, 3); char* queryPtr = lua_tostring(L, 4); char* host = new char[strlen(hostPtr) + 1]; strncpy_s(host, strlen(hostPtr) + 1, hostPtr, strlen(hostPtr) + 1); char* user = new char[strlen(userPtr) + 1]; strncpy_s(user, strlen(userPtr) + 1, userPtr, strlen(userPtr) + 1); char* pass = new char[strlen(passPtr) + 1]; strncpy_s(pass, strlen(passPtr) + 1, passPtr, strlen(passPtr) + 1); char* query = new char[strlen(queryPtr) + 1]; strncpy_s(query, strlen(queryPtr) + 1, queryPtr, strlen(queryPtr) + 1); auto f = std::async(std::launch::async, ExecuteQuery, query, host, user, pass); pending_queries.push_back(std::move(f)); return 1; } unsigned int handleC = 0; std::map<unsigned int, SQL*> handle; int LuaSql(lua_State *L) { // Check for arguments if (lua_gettop(L) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } // Check and read command if (lua_isstring(L, 1) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } char* command = lua_tostring(L, 1); // Create a connection to the database if (strcmp(command, "connect") == 0) { // Check arguments if (lua_gettop(L) != 4) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } if (lua_isstring(L, 2) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } if (lua_isstring(L, 3) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } if (lua_isstring(L, 4) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } // Get connection info char* host = lua_tostring(L, 2); char* user = lua_tostring(L, 3); char* pass = lua_tostring(L, 4); // Connect to SQL Server SQL* Sql = new SQL(host, user, pass); // Check if connection was successful switch (Sql->retcode) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: // Save connection handle.emplace(handleC, Sql); // Return handle id lua_pushnumber(L, 1); lua_pushnumber(L, handleC++); break; default: lua_pushnumber(L, 0); lua_pushnumber(L, Sql->retcode); break; } return 2; } // Execute query else if (strcmp(command, "query") == 0) { // Check arguments if (lua_gettop(L) != 3) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } if (lua_isnumber(L, 2) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } if (lua_isstring(L, 3) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, LUA_ARG_ERROR); return 2; } // Check if connection handle is valid int connHandleId = (int)lua_tonumber(L, 2); if (handle.count(connHandleId) == 0) { lua_pushnumber(L, 0); lua_pushnumber(L, SQL_INVALID_HANDLE); return 2; } // Get connection SQL* Sql = handle.at(connHandleId); // Get query char* query = lua_tostring(L, 3); // Allocate statement handle SQLHSTMT hstmt; Sql->retcode = SQLAllocHandle(SQL_HANDLE_STMT, Sql->hdbc, &hstmt); // Save statement handle Sql->hstmt.emplace(Sql->hstmtC, hstmt); // Execute query Sql->retcode = SQLExecDirectA(hstmt, (SQLCHAR*)query, SQL_NTS); // Return 1 on success, otherwise return 0 switch (Sql->retcode) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: lua_pushnumber(L, 1); lua_pushnumber(L, Sql->hstmtC++); break; default: //Sql->DisplayErrors(SQL_HANDLE_STMT, hstmt); lua_pushnumber(L, 0); lua_pushnumber(L, Sql->retcode); } return 2; } // Fetch data else if (strcmp(command, "fetch") == 0) { // Check arguments if (lua_gettop(L) != 3) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } if (lua_isnumber(L, 2) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } if (lua_isnumber(L, 3) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } // Check if connection handle is valid int connHandleId = (int)lua_tonumber(L, 2); if (handle.count(connHandleId) == 0) { lua_pushnumber(L, SQL_INVALID_HANDLE); return 1; } // Get connection SQL* Sql = handle.at(connHandleId); // Check if statement handle is valid int stmtHandleId = (int)lua_tonumber(L, 3); if (Sql->hstmt.count(stmtHandleId) == 0) { lua_pushnumber(L, SQL_INVALID_HANDLE); return 1; } // Get statement handle SQLHSTMT hstmt = Sql->hstmt.at(stmtHandleId); // Fetch next row Sql->retcode = SQLFetch(hstmt); if (Sql->retcode == SQL_NO_DATA) { lua_pushnumber(L, Sql->retcode); return 1; } // Get number of columns SQLSMALLINT numCols; Sql->retcode = SQLNumResultCols(hstmt, &numCols); // Create lua table for fetched data lua_newtable(L); for (int i = 1; i < numCols + 1; i++) { // Get column info SQLCHAR colName[64]; SQLULEN colSize; Sql->retcode = SQLDescribeColA(hstmt, i, colName, sizeof(colName), NULL, NULL, &colSize, NULL, NULL); // Push column name on stack lua_pushstring(L, (CHAR*)colName); // Fetch column data char* value = new char[colSize]; SQLLEN null; Sql->retcode = SQLGetData(hstmt, i, SQL_C_CHAR, value, colSize, &null); switch (Sql->retcode) { case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: break; default: lua_pushnumber(L, Sql->retcode); return 1; } // Check if data is null and push it on stack if (null == SQL_NULL_DATA) { lua_pushstring(L, "NULL"); } else { lua_pushstring(L, value); } // Add fetched column data to the table lua_settable(L, -3); } } // Free statement handle else if (strcmp(command, "freehandle")) { // Check arguments if (lua_gettop(L) != 3) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } if (lua_isnumber(L, 2) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } if (lua_isnumber(L, 3) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } // Check if connection handle is valid int connHandleId = (int)lua_tonumber(L, 2); if (handle.count(connHandleId) == 0) { lua_pushnumber(L, SQL_INVALID_HANDLE); return 1; } // Get connection SQL* Sql = handle.at(connHandleId); // Check if statement handle is valid int stmtHandleId = (int)lua_tonumber(L, 3); if (Sql->hstmt.count(stmtHandleId) == 0) { lua_pushnumber(L, SQL_INVALID_HANDLE); return 1; } // Free handle resources Sql->retcode = SQLFreeHandle(SQL_HANDLE_STMT, Sql->hstmt.at(stmtHandleId)); if (Sql->retcode == SQL_SUCCESS) { Sql->hstmt.erase(stmtHandleId); } // Return result lua_pushnumber(L, Sql->retcode); } // Close database connection else if (strcmp(command, "close")) { // Check and read arguments if (lua_gettop(L) != 2) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } if (lua_isnumber(L, 2) == 0) { lua_pushnumber(L, LUA_ARG_ERROR); return 1; } int handleId = (int)lua_tonumber(L, 2); if (handle.count(handleId) == 0) { lua_pushnumber(L, SQL_INVALID_HANDLE); return 1; } SQL Sql = *handle.at(handleId); Sql.retcode = SQLDisconnect(Sql.hdbc); handle.erase(handleId); lua_pushnumber(L, Sql.retcode); } return 1; }
  16. Does this shows that the LuaSQL.dll properly loaded if I'm able to check it through OllyDbg? Calling it with lua return a nill value.
  17. for me i figure it out how to set manually in sql management system but i dont know how to do it by using LuaSQL.dll and lua query. I'm not even sure if my LuaSQL.dll is loaded or not. In the GS prompt, it said loading LuaSQL.dll but never mention its succeeded or not. and checking with lua query return a nill value
  18. That rebuilt with OFT need to be on or not? BTW, i always get thet SQL is nill also and I dont understand your advance discussion here
  19. I'm trying that same thing also and still cant figure it out hahahahaha
  20. Anyone ? or can anyone shared their working code files for 1.36 ? Thanks for your time
  21. Hi my dear dev community, I have been trying many days and I still can't figured it out on how to get it work. This are some question I had. 1. LuaSQL.dll attach to GS, i already successfully did it base on the community guide but why the loading in GS only shows, load LuaSQL.dll but there is no definitive prove of connection. 2. Looking into other guide, I did the init.lua files and inserting the code provided by community that @Angelix shared back the content code from the zip files but it still wont load in GS if I did not put a dofile script in other lua files such as inside the MissionSDK.lua and yet it still wont work as intended. 3. I had TradeServer work well as I have my IGS Shop open. So I'm not sure where to go as I dont find definitive guide. Really hope to get an assist on this. Thanks for your people time.
  22. Can anyone provide details step by step on how to implement SQL, mobs function and igs function ?
  23. For this part, I able to figure it out after reading the translated reply from comment regarding other account able to see it instead ur own. i'm content seeing others name with level instead of mine. thanks
×
×
  • Create New...