Jump to content
Ximboliex

[RELEASE]GetChaGuildLeaderID Whit LuaSQL

Recommended Posts

function GetGuildID2(Player)
	local Name = GetChaDefaultName(Player)
	local String = "SELECT guild_id FROM GameDB.dbo.character WHERE cha_name = '"..Name.."'"
	local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			local Data = LuaSQL("fetch", ConnectID, Query)
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
			return Data["guild_id"]
		end
	end
end

function GuildLeaderID(Player)
	local Guild_ID = GetGuildID2(Player)
	local String = "SELECT leader_id FROM GameDB.dbo.guild WHERE name = '"..GuildID.."'"
	local Connect, ConnectID = LuaSQL("connect", SQL.AccServer.Host, SQL.AccServer.User, SQL.AccServer.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			local Data = LuaSQL("fetch", ConnectID, Query)
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
			return Data["leader_id"]
		end
	end
end

function GetChaGuildLeaderID(Player)
	local leader = GetLeaderID(Player)
	local cha_id = GetChaID(Player)
	if leader == cha_id then
		return 1
	else
		LG("LuaSqlErr", "GetLeaderID Failed", "\n")
		return 0
	end
end

**UPTADE**

Edited by Ximboliex
  • Like 2

xbx3.png

Share this post


Link to post
Share on other sites

Thank you @Ximboliex for useful release!

 

The topic has been moved to Server Releases section.

  • Like 1

Share this post


Link to post
Share on other sites
19 minutes ago, Riizq said:

Please guide us senpai, on how to use this. For newbies like me, have no idea what to do.

Make sure you have LuaSql dll set on your files, and inside functions.lua set the value of the following variables: SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password, SQL.AccServer.Host, SQL.AccServer.User, SQL.AccServer.Password

and paste the script ximboliex released

 

Then just call the functions: GetGuildID2(Player) will return the GUILD ID of a player and function GetChaGuildLeader(Player) will return the id of the leader of that guild

Edited by iZae
typo
  • Like 2

Share this post


Link to post
Share on other sites

I believe Wrexor released before in discord LUASQL V2.0 which registers every function without the person intervention and works way much better than the ones released by Xeon here.

Share this post


Link to post
Share on other sites
3 hours ago, Sk3let0n said:

I believe Wrexor released before in discord LUASQL V2.0 which registers every function without the person intervention and works way much better than the ones released by Xeon here.

 

Share this post


Link to post
Share on other sites

hey !~
you can use this only tho 
 

------------ get guild leader id --		
function GuildLeaderID(Player)
local Guild_ID =  GetChaGuildID(Player)
	local String = "SELECT leader_id FROM GameDB.dbo.guild WHERE guild_id = '"..Guild_ID.."'"
	local Connect, ConnectID = LuaSQL("connect", SQL.GameDB.Host, SQL.GameDB.User, SQL.GameDB.Password)
	if Connect == SQL_SUCCESS_WITH_INFO then
		local Success, Query = LuaSQL("query", ConnectID, String)
		if Success == SQL_SUCCESS_WITH_INFO then
			local Data = LuaSQL("fetch", ConnectID, Query)
			LuaSQL("freehandle", ConnectID, Query)
			LuaSQL("close", ConnectID)
			return Data["leader_id"]
		end
	end
end
--  example --
function getgleaderids(player)
local leaderid = GuildLeaderID(player)
local guildid = GetChaGuildID(player)
local guildname = GetGuildName(guildid)
	Notice("Guild id["..guildid..'] Guild Name['..guildname..'] leader is['..leaderid.."]")
end	

 

Edited by mkhzaleh
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...