Here's a Guild Leader change script wrote in SQL. It is a stored procedure so you can call it from php or whatever you are using.
There are many comments so you shouldn't be lost when reading through it. I haven't tested it. What I did was rewrite old procedure I had lying around. If you get any errors, post them here.
Code:
USE PS_GAMEDATA
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Tomasz Wiacek
-- Create date: 10.IV.2010
-- Description: Change guild leader
/*
Provide the procedure with character name of new
and old guild leader - @OldGuildLeader is old GL
and @NewGuildLeader is new GL respectively.
The rest will be done by the procedure.
*/
-- =============================================
CREATE PROCEDURE dbo.ausp_ChangeGuildLeader
@OldGuildLeader varchar(30),
@NewGuildLeader varchar(30)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @GuildID int -- GuildID where change of leadership will take place
DECLARE @MasterCharID int -- stores new GL CharID
DECLARE @MasterUserID varchar(30) -- stores new GL UserID
DECLARE @OldGLCharID int -- used to store CharID of current GL
DECLARE @MasterName varchar(40) -- stores new GL CharName
-- select GuildID and old GuildLeader CharID
SELECT @GuildID = GuildID, @OldGLCharID = MasterCharID
FROM PS_GameData.dbo.Guilds
WHERE MasterName = @OldGuildLeader;
-- check if any results were returned
IF @@ROWCOUNT = 0
begin
PRINT 'Guild leader - ' + @OldGuildLeader + ' does not exist.';
end
ELSE
begin
-- get CharID, UserID and CharName of new GuildLeader
SELECT @MasterCharID = CharID, @MasterUserID = UserID, @MasterName = CharName
FROM PS_GameData.dbo.Chars
WHERE CharName = @NewGuildLeader;
-- if new GuildLeader CharName is correct and it exists (result was returned by above statement)
-- and new GuildLeader is part of the guild execute leadership change
IF @@ROWCOUNT <> 0 AND @MasterCharID IN (SELECT CharID FROM PS_GameData.dbo.GuildChars WHERE GuildID=@GuildID AND Del=0 AND (LeaveDate IS NULL OR LeaveDate=0))
begin
-- update information about who's the current GuildLeader
UPDATE PS_GameData.dbo.Guilds
SET MasterCharID = @MasterCharID, MasterUserID = @MasterUserID, MasterName = @MasterName
WHERE GuildID = @GuildID;
-- make new GL leader of the guild
UPDATE PS_GameData.dbo.GuildChars
SET GuildLevel = 1 WHERE CharID = @MasterCharID AND GuildID = @GuildID;
-- give old GL GuildLevel=3 to be on the safe side if there are too many Lv2's in guild
UPDATE PS_GameData.dbo.GuildChars
SET GuildLevel = 3 WHERE CharID = @OldGLCharID AND GuildID = @GuildID;
PRINT 'Guild leadership between - ' + @OldGuildLeader + ' - and - ' + @NewGuildLeader + ' was changed.'
end
ELSE
begin
PRINT 'No such character: ' + @NewGuildLeader + ' or character is not part of the guild.';
end
end
END
To those new to SQL, paste the above code as new query in Server Management Studio and execute it. To run it do this:
I will check my SQL quiry i got lying around, mine seems to work without a restart as long as the person relogs, i think it has a readressing function or something, will check out, either way, nice script, bit more advanced then mine.
You can see I wrote it in April 2010, when I didn't know as much. I don't remember why I chose CharName, I guess I wanted to know who's taking part in the process or I thought CharNames is a good idea to do this. GuildName would work better but I believe any name change should be reflected in other tables so the current version should still work.
If you want to optimize a little more you can save a query in Lilpro's version if you change this:
Code:
--Get the Guild ID
SELECT @GuildID = GuildID FROM PS_GameData.dbo.GuildChars WHERE [CharID]=@NewGuildLeaderID AND Del=0 AND (LeaveDate IS NULL OR LeaveDate=0)
-- Get old GuildLeader CharID
SELECT @OldGLCharID = MasterCharID
FROM PS_GameData.dbo.Guilds
WHERE GuildID = @GuildID
To this:
Code:
--Get the Guild ID and old GuildLeader CharID
SELECT @GuildID = gc.GuildID, @OldGLCharID = g.MasterCharID
FROM PS_GameData.dbo.GuildChars AS gc
INNER JOIN PS_GameData.dbo.Guilds AS g ON gc.GuildID = g.GuildID
WHERE gc.[CharID]=@NewGuildLeaderID
AND gc.Del=0
AND (gc.LeaveDate IS NULL OR gc.LeaveDate=0)
Also it looks like you fat-fingered a comma in place of your DECLARE statement for @GuildID int.
If you want to optimize a little more you can save a query in Lilpro's version...
Thanks for this. I Just quickly modified the current one above to it current state, I didn't think about going though and optimizing it, But since you already have, Thanks! it makes it easier on me.
Guild leader help me please 05/18/2010 - Dekaron Private Server - 8 Replies hi all,
for create guild.
bug create guild no guild leader:rtfm:.
who can help me.
thanks. for help.
How to change 'Guild Leader' 08/01/2009 - CO2 Private Server - 3 Replies Alright, i'm making the 'clan' system.
I kind of have it made, because i mostly made it from the guild, but it can't find out how to change 'guild leader' to 'clan leader'.
i searched 'guild leader' in my source in entire source, there is nothing.
any help?
Guild Deputy Leader Glitch 01/20/2009 - Conquer Online 2 - 4 Replies I've heard of a glitch to have more than 5 deputy leaders for a guild, I'm just unsure of how to do it. Does anyone know how? Will be greatly appreciated if someone knew how.
how to change guild leader after ban ? 05/29/2007 - Silkroad Online - 3 Replies hey guys i have a question ... im banned on olympus at lvl 72 -.-*
but dosnt metter can some1 tell me how i can change the guild leader now ?
and how long i have to wait till i can vote for one ?
Guild Leader Question 03/08/2006 - Conquer Online 2 - 12 Replies hey everyone. ive got a really wierd question.
i remember reading/hearing from somewhere that if a GL isnt active for a month or something, a guild member could donate 100k to the guild to become GL? does anyone know the details of this (how long, how much) and where and how to do it? thanks a lot guys!
shadowHacker