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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×