|
You last visited: Today at 03:43
Advertisement
[RELEASE] Guild Leader change - SQL version
Discussion on [RELEASE] Guild Leader change - SQL version within the Shaiya PServer Development forum part of the Shaiya Private Server category.
01/07/2011, 17:41
|
#1
|
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 647
|
[RELEASE] Guild Leader change - SQL version
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:
Code:
EXEC PS_GameData..ausp_ChangeGuildLeader 'OldGLName','NewGLName'
replacing the words in-between quotes with real character names.
NOTE:
The changes won't take effect until server restart.
|
|
|
01/07/2011, 17:44
|
#2
|
elite*gold: 0
Join Date: Apr 2010
Posts: 148
Received Thanks: 171
|
Haha, I probably could have written one, I have been doing it manually.
Thanks for the release.
Tyler
|
|
|
01/07/2011, 17:57
|
#3
|
elite*gold: 0
Join Date: Jul 2010
Posts: 498
Received Thanks: 449
|
Thank you prof, I will test it and report any error
Thanks also for your global skill/stat reset, this query has been a life saver in last maint.
Envotion from Rebirth.
|
|
|
01/07/2011, 18:09
|
#4
|
elite*gold: 20
Join Date: Jun 2009
Posts: 790
Received Thanks: 2,729
|
The problem with this is that it wont take effect until a server restart. Cause the Guild Info is stored in memory while the server is running.
|
|
|
01/07/2011, 18:10
|
#5
|
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 647
|
Quote:
Originally Posted by lilprohacker
The problem with this is that it wont take effect until a server restart. Cause the Guild Info is stored in memory while the server is running.
|
I know. I remember you posted how to reload any particular data into server memory from database, but I don't remember where it was.
I added the info to first post.
|
|
|
01/07/2011, 19:28
|
#6
|
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
|
I used a test guild to test it, and it looks like it made us both rank 1. Would that be correct?
*Edit* After rerunning it, it seemed to work, so nevermind. ._.
|
|
|
01/07/2011, 19:42
|
#7
|
elite*gold: 0
Join Date: Jan 2009
Posts: 348
Received Thanks: 260
|
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.
|
|
|
01/07/2011, 22:12
|
#8
|
elite*gold: 0
Join Date: Aug 2010
Posts: 136
Received Thanks: 343
|
Was there something wrong with using GuildName and NewLeaderName as inputs?
I thought it was odd you got the Guild ID from the guild leader rather than using the guild name as an input.
I felt using the Guild Name rather than old guild leader name has less room for error, since the guild leader can change names and such.
|
|
|
01/07/2011, 23:48
|
#9
|
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 647
|
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.
|
|
|
01/07/2011, 23:49
|
#10
|
elite*gold: 0
Join Date: Mar 2010
Posts: 2,334
Received Thanks: 1,777
|
# added to my collection of gudies.
|
|
|
01/10/2011, 03:34
|
#11
|
elite*gold: 20
Join Date: Jun 2009
Posts: 790
Received Thanks: 2,729
|
removed
|
|
|
01/10/2011, 04:06
|
#12
|
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 812
|
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.
|
|
|
01/10/2011, 09:26
|
#13
|
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 255
|
Quote:
|
Also it looks like you fat-fingered a comma in place of your DECLARE statement for @GuildID int.
|
Nah it works, it's same as
DECLARE a int, b int. The comments are ignored during execution
|
|
|
01/10/2011, 14:28
|
#14
|
elite*gold: 20
Join Date: Jun 2009
Posts: 790
Received Thanks: 2,729
|
Quote:
Originally Posted by abrasive
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.
|
|
|
01/17/2011, 13:07
|
#15
|
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 255
|
Go into the command of the Game service and type /help.
Code:
/remob(1) - Takes 1 parameter namely mobid. Resets a Mob
/remobitem(1) - Takes 1 parameter namely MobID. Resets the items of a mob
/reitem(1) - Takes 1 parameter amely ItemID. Resets an Item
/reskill(2) - Takes 2 parameters hopegully SkillID and Level. Resets a skill
/remobskill(1) - Takes 1 paramater namely MobID. Resets the skills of a mob
/reseqitem(0)
/reitemenh(0)
/reitemcre(0)
|
|
|
 |
|
Similar Threads
|
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
|
All times are GMT +1. The time now is 03:46.
|
|