kyleflow 35 Report post Posted March 23, 2022 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. 1 Quote Share this post Link to post Share on other sites