Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Arena Score 1.2

i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
what do you mean by no luck you have some errors? or...
 
X

xFuture

Guest
what do you mean by no luck you have some errors? or...

It means he can't make it work without crash(or add it to the source /ridi).


Also DB save part is easy to make(Using the example pieces of Pumbaaa or doing it with another, the most easy way).
 
i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
It means he can't make it work without crash(or add it to the source /ridi).


Also DB save part is easy to make(Using the example pieces of Pumbaaa or doing it with another, the most easy way).
fail. xD

you're right sir db part is really easy just read the source...
Code:
sprintf( szQuery, "[B]uspLoadArena[/B] @serverindex='%02d', @idPlayer='%07d' ",g_appInfo.dwSys, nidPlayer );    //can add arguments directly %s %d..     //RUN QUERY
Code:
 sprintf( szQuery, "[B]uspSaveArena[/B] @serverindex='%02d', @idPlayer='%07d', @nArenaKills='%d', @nArenaDeaths='%d'", g_appInfo.dwSys, idPlayer, nArenaKills, nArenaDeaths );
Code:
 sprintf( szQuery, "TRUNCATE TABLE [B]dbo.ArenaScore[/B]");
im not sure with this procedures xD
Code:
CREATE proc [dbo].[uspLoadArena]     @serverindex char(2),            @idPlayer char(7) as set nocount on     Select serverindex, m_idPlayer, nArenaKills, nArenaDeaths from [B][COLOR=#ff0000]ArenaScore[/COLOR][/B] with (nolock) where serverindex = @serverindex and m_idPlayer = @m_idPlayer
Code:
CREATE proc [dbo].[uspSaveArena]     @serverindex char(2),            @idPlayer char(7),      @nArenaKills int,     @nArenaDeaths int as set nocount on set xact_abort on  update [B][COLOR=#ff0000]ArenaScore[/COLOR][/B] set nArenaKills = @nArenaKills, nArenaDeaths = @nArenaDeaths where serverindex = @serverindex and m_idPlayer = @m_idPlayer
and for the table
Code:
CREATE TABLE [dbo].[ArenaScore](     [serverindex] [char](2) NULL,     [m_idPlayer] [char](7) NULL,     [nArenaKills] [int] NULL,     [nArenaDeaths] [int] NULL )
:laugh:
 
Last edited:
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
I added the data but did mistake something, hopefully it will now work :)
 
Experienced Elementalist
Joined
Sep 8, 2009
Messages
296
Reaction score
78
One thing that people might want to change with this system is, when a player logs out INSIDE the arena, they stay in the list and are marked as another person inside the arena while offline. When logging off make it so that it removes them from the scoreboard. Any easy fix (in my head, havent tried it) would probably be to make it so that when any player logs off within the arena, edit the savecharacter procedure and make it save them in Flaris and remove them from the scoreboard.
 
Flyff Developer
Loyal Member
Joined
Apr 6, 2009
Messages
1,873
Reaction score
384
One thing that people might want to change with this system is, when a player logs out INSIDE the arena, they stay in the list and are marked as another person inside the arena while offline. When logging off make it so that it removes them from the scoreboard. Any easy fix (in my head, havent tried it) would probably be to make it so that when any player logs off within the arena, edit the savecharacter procedure and make it save them in Flaris and remove them from the scoreboard.

The simplest way would be to call the OnArenaExit function when someone logs out. The only problem with that, is it wouldn't catch DCs or crashes. The best way would be to periodically check all players that are currently in the score list and make sure they're still online.
 
[R8]ℓσℓ32
Loyal Member
Joined
Oct 6, 2008
Messages
1,396
Reaction score
198
Using CUser::process() function will fix that, no matter how the player gets there, so that will fix dc, crashes, exit, summon,... It's more usseful than using ArenaJoin and Exit functions.

In the first version of arena score I used OnArenaJoin and OnArenaExit functions, but there was lot of bugs, like ShadowDragon said.

CUser::process()
Code:
#ifdef __ARENA_SCORE
    if( GetWorld()->IsArena() ) // This hook fixes the Score and ID of the player no matter where they are
        if( !g_ArenaScore.IsArenaUser( this ) )
        {
                g_ArenaScore.ArenaOnJoin( this );                // or how they got into thr Arena.

        }
    if( !GetWorld()->IsArena() )
{
            if( g_ArenaScore.IsArenaUser( this ) )
                    g_ArenaScore.ArenaOnExit( this );
            }
#endif

Checking the world is an easy way to send the arena join and exit functions without edit the original function.

@Alemap
CREATE proc [dbo].[uspSaveArena] @serverindex char(2), @idPlayer char(7), @nArenaKills int, @nArenaDeaths int as set nocount on set xact_abort on update ArenaScore set nArenaKills = @nArenaKills, nArenaDeaths = @nArenaDeaths where serverindex = @serverindex and m_idPlayer = @m_idPlayer

You can't update a table if there is nothing to edit.

And why this TRUNCATE TABLE dbo.ArenaScore
Uh, deleting the table?
 
Last edited:
Flyff Developer
Loyal Member
Joined
Apr 6, 2009
Messages
1,873
Reaction score
384
Oh, speaking of which, I meant that they could call the g_ArenaScore.ArenaOnExit when logging out. Not OnArenaExit lol (similar names and I typed that reply from memory xD).

@caja
I just reread your post, and I'm not sure you quite understood what I meant. CUser::process would only be triggered by the client. But if the client crashed or DCed, it would never trigger the ArenaOnExit function and you'd still have the same problem.

You know how when you're in a Party and you get DCed? Everyone else in the party sees a black box in the party window showing that you're offline. After so long, it automatically kicks you from the party. Essentially, you'd have to do the same thing here. You might not need the offline indicator, but you do have to periodically check everyone on the arena list and remove ones that are offline. (The best way would be to keep track of how long they've been offline, and cut them out after a certain amount of time).
 
Last edited:
i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
@Alemap


You can't update a table if there is nothing to edit.

And why this TRUNCATE TABLE dbo.ArenaScore
Uh, deleting the table?
i dont know i just look in the dbmanager.cpp

Code:
#ifdef __ARENA_SCORE
void CDbManager::LoadArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
    CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );
    
    u_long nidPlayer;
    int    nArenaKills; 
    int    nArenaDeaths;
    arRead >> nidPlayer;
    char szQuery[QUERY_SIZE] = {0,};
    sprintf( szQuery, "uspLoadArena @serverindex='%02d', @idPlayer='%07d' ",g_appInfo.dwSys, nidPlayer );    //can add arguments directly %s %d..
    //RUN QUERY

    


    //RUN QUERY
    if( FALSE == qry->Exec( szQuery ) )
    {
        WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );

    }



            while( qry->Fetch() )
            {    
                    nArenaKills    =    qry->GetInt("nArenaKills");
                    nArenaDeaths    =    qry->GetInt("nArenaDeaths");
            }

    
    CDPTrans::GetInstance()->SendArenaScore( nidPlayer, nArenaKills, nArenaDeaths );

    FreeRequest( lpDbOverlappedPlus );
}

void CDbManager::SaveArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
    CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );
    
    u_long idPlayer;
    int    nArenaKills;
    int    nArenaDeaths;
    BOOL bCreate;
    arRead >> idPlayer >> nArenaKills >> nArenaDeaths >> bCreate;

    char szQuery[250] = {0,};
if( !bCreate )
    sprintf( szQuery, "uspSaveArena @serverindex='%02d', @idPlayer='%07d', @nArenaKills='%d', @nArenaDeaths='%d'", g_appInfo.dwSys, idPlayer, nArenaKills, nArenaDeaths );
else
   [B] sprintf( szQuery, "TRUNCATE TABLE dbo.ArenaScore");[/B]


        if( FALSE == qry->Exec( szQuery ) )
        {
            WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );
            FreeRequest( lpDbOverlappedPlus );
            return;
        }
    

    FreeRequest( lpDbOverlappedPlus );
}
#endif
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
Only problem is now you can't attack people in the arena or you dicsonnect the whole server, why would this be?

This is really wierd it shows then entering and exiting arena as fine, but when someone attacks someone the whole world server crashes, please help me
 
Inactive
Joined
Jan 20, 2009
Messages
1,014
Reaction score
1,830
ArenaScore
Code:
GO

/****** Object:  Table [dbo].[ArenaScore]    Script Date: 05/04/2012 14:16:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ArenaScore](
	[idPlayer] [char](7) NOT NULL,
	[nArenaKills] [int] NULL,
	[nArenaDeaths] [int] NULL,
	[serverindex] [int] NULL,
 CONSTRAINT [PK_ArenaScore] PRIMARY KEY CLUSTERED 
(
	[idPlayer] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

LoadArena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspLoadArena]    Script Date: 05/04/2012 14:17:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspLoadArena]
		@serverindex	char(2),
		@idPlayer		char(7)
AS
SET NOCOUNT ON
BEGIN
IF EXISTS ( SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore WHERE	idPlayer =@idPlayer AND	serverindex=@serverindex )
	BEGIN
		SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore 
		WHERE 	idPlayer =@idPlayer 
		AND		serverindex=@serverindex
	END
ELSE BEGIN
		INSERT INTO	ArenaScore VALUES( @idPlayer, '0', '0', @serverindex )
		SELECT idPlayer , nArenaKills, nArenaDeaths FROM ArenaScore 
		WHERE 	idPlayer =@idPlayer 
		AND		serverindex=@serverindex	
	END
END

RETURN

SET NOCOUNT OFF
GO

Save Arena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspSaveArena]    Script Date: 05/04/2012 14:17:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspSaveArena]
		@serverindex 		char(2),
		@idPlayer			char(7),
		@nArenaKills			int,
		@nArenaDeaths			int
AS
SET NOCOUNT ON

	BEGIN
	IF EXISTS ( SELECT * FROM dbo.ArenaScore WHERE serverindex=@serverindex AND idPlayer=@idPlayer )
		BEGIN
			UPDATE	ArenaScore 	SET	nArenaKills=@nArenaKills,nArenaDeaths=@nArenaDeaths 
			WHERE	serverindex=@serverindex AND idPlayer=@idPlayer

		END
		ELSE BEGIN
					INSERT INTO	ArenaScore VALUES( @idPlayer, @nArenaKills, @nArenaDeaths, @serverindex )
				
		END

	END
		
	RETURN

SET NOCOUNT OFF

GO

Enjoy...
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
Seriously it won't work, i keep getting disconnected after attacking someone, is this the mover problem or something else?
 
Newbie Spellweaver
Joined
Sep 27, 2008
Messages
30
Reaction score
0
ArenaScore
Code:
GO

/****** Object:  Table [dbo].[ArenaScore]    Script Date: 05/04/2012 14:16:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ArenaScore](
	[idPlayer] [char](7) NOT NULL,
	[nArenaKills] [int] NULL,
	[nArenaDeaths] [int] NULL,
	[serverindex] [int] NULL,
 CONSTRAINT [PK_ArenaScore] PRIMARY KEY CLUSTERED 
(
	[idPlayer] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

LoadArena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspLoadArena]    Script Date: 05/04/2012 14:17:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspLoadArena]
		@serverindex	char(2),
		@idPlayer		char(7)
AS
SET NOCOUNT ON
BEGIN
IF EXISTS ( SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore WHERE	idPlayer =@idPlayer AND	serverindex=@serverindex )
	BEGIN
		SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore 
		WHERE 	idPlayer =@idPlayer 
		AND		serverindex=@serverindex
	END
ELSE BEGIN
		INSERT INTO	ArenaScore VALUES( @idPlayer, '0', '0', @serverindex )
		SELECT idPlayer , nArenaKills, nArenaDeaths FROM ArenaScore 
		WHERE 	idPlayer =@idPlayer 
		AND		serverindex=@serverindex	
	END
END

RETURN

SET NOCOUNT OFF
GO

Save Arena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspSaveArena]    Script Date: 05/04/2012 14:17:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspSaveArena]
		@serverindex 		char(2),
		@idPlayer			char(7),
		@nArenaKills			int,
		@nArenaDeaths			int
AS
SET NOCOUNT ON

	BEGIN
	IF EXISTS ( SELECT * FROM dbo.ArenaScore WHERE serverindex=@serverindex AND idPlayer=@idPlayer )
		BEGIN
			UPDATE	ArenaScore 	SET	nArenaKills=@nArenaKills,nArenaDeaths=@nArenaDeaths 
			WHERE	serverindex=@serverindex AND idPlayer=@idPlayer

		END
		ELSE BEGIN
					INSERT INTO	ArenaScore VALUES( @idPlayer, @nArenaKills, @nArenaDeaths, @serverindex )
				
		END

	END
		
	RETURN

SET NOCOUNT OFF

GO

Enjoy...

It work ... but

the score not update to database but data new user insert to database and cannot to load score from database into game

how to fix pls....:blink:
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
It all works i added it fine, but when i try to attack someone or someone attacks me the whole server disconnects, please someone help me here :/

It all works fine now, but it doesn't update data, e.g when i kill someone it doesn't actually show i killed someone
 
i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
ArenaScore
Code:
GO

/****** Object:  Table [dbo].[ArenaScore]    Script Date: 05/04/2012 14:16:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ArenaScore](
    [idPlayer] [char](7) NOT NULL,
    [nArenaKills] [int] NULL,
    [nArenaDeaths] [int] NULL,
    [serverindex] [int] NULL,
 CONSTRAINT [PK_ArenaScore] PRIMARY KEY CLUSTERED 
(
    [idPlayer] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO
LoadArena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspLoadArena]    Script Date: 05/04/2012 14:17:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspLoadArena]
        @serverindex    char(2),
        @idPlayer        char(7)
AS
SET NOCOUNT ON
BEGIN
IF EXISTS ( SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore WHERE    idPlayer =@idPlayer AND    serverindex=@serverindex )
    BEGIN
        SELECT idPlayer, nArenaKills, nArenaDeaths FROM ArenaScore 
        WHERE     idPlayer =@idPlayer 
        AND        serverindex=@serverindex
    END
ELSE BEGIN
        INSERT INTO    ArenaScore VALUES( @idPlayer, '0', '0', @serverindex )
        SELECT idPlayer , nArenaKills, nArenaDeaths FROM ArenaScore 
        WHERE     idPlayer =@idPlayer 
        AND        serverindex=@serverindex    
    END
END

RETURN

SET NOCOUNT OFF
GO
Save Arena
Code:
USE [CHARACTER_01_DBF]
GO

/****** Object:  StoredProcedure [dbo].[uspSaveArena]    Script Date: 05/04/2012 14:17:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspSaveArena]
        @serverindex         char(2),
        @idPlayer            char(7),
        @nArenaKills            int,
        @nArenaDeaths            int
AS
SET NOCOUNT ON

    BEGIN
    IF EXISTS ( SELECT * FROM dbo.ArenaScore WHERE serverindex=@serverindex AND idPlayer=@idPlayer )
        BEGIN
            UPDATE    ArenaScore     SET    nArenaKills=@nArenaKills,nArenaDeaths=@nArenaDeaths 
            WHERE    serverindex=@serverindex AND idPlayer=@idPlayer

        END
        ELSE BEGIN
                    INSERT INTO    ArenaScore VALUES( @idPlayer, @nArenaKills, @nArenaDeaths, @serverindex )
                
        END

    END
        
    RETURN

SET NOCOUNT OFF

GO
Enjoy...

100% working... :love:

no any f*cking bugs/disconnect. ^_^

thanks to Defiance.
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
OKay, am i being stupid here, does anyone else have this problem that it won't actually update the database at all with new info, when ever someone is killed or i kill someone it just leaves all points at 0, no changes in numbered position or anything, someone please help me i don't know if it is a database or source error as i don't get any errors in my CQuery_Log files to suggest a source error

i don't think this is database related as i am using the database tables and procedures provided by Defiance and people keep saying they work, so if it is source related would it be likely the database or worldserver source i need to look through?
 
Last edited:
i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
i dont know what's your problem sir nick...

Code:
it won't actually update the database at all with new info, when ever  someone is killed or i kill someone it just leaves all points at 0, no  changes in numbered position or anything

here is my dbmanager.cpp

#ifdef __SCORE_PVP
void CDbManager::LoadArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );

u_long nidPlayer;
int nArenaKills;
int nArenaDeaths;
arRead >> nidPlayer;
char szQuery[QUERY_SIZE] = {0,};
sprintf( szQuery, "uspLoadArena @serverindex='%02d', @idPlayer='%07d' ",g_appInfo.dwSys, nidPlayer ); //can add arguments directly %s %d..
//RUN QUERY




//RUN QUERY
if( FALSE == qry->Exec( szQuery ) )
{
WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );

}



while( qry->Fetch() )
{
nArenaKills = qry->GetInt("nArenaKills");
nArenaDeaths = qry->GetInt("nArenaDeaths");
}


CDPTrans::GetInstance()->SendArenaScore( nidPlayer, nArenaKills, nArenaDeaths );

FreeRequest( lpDbOverlappedPlus );
}

void CDbManager::SaveArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );

u_long idPlayer;
int nArenaKills;
int nArenaDeaths;
BOOL bCreate;
arRead >> idPlayer >> nArenaKills >> nArenaDeaths >> bCreate;

char szQuery[250] = {0,};
if( !bCreate )
sprintf( szQuery, "uspSaveArena @serverindex='%02d', @idPlayer='%07d', @nArenaKills='%d', @nArenaDeaths='%d'", g_appInfo.dwSys, idPlayer, nArenaKills, nArenaDeaths );
else
sprintf( szQuery, "TRUNCATE TABLE dbo.tblArenaScore");


if( FALSE == qry->Exec( szQuery ) )
{
WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );
FreeRequest( lpDbOverlappedPlus );
return;
}


FreeRequest( lpDbOverlappedPlus );
}
#endif
did you try to execute the uspLoadArena or uspSaveArena procedure? in programmability(sql)
this is only the example:
serverindex= 01
idPlayer= 0000001
nArenaKills= 30
nArenaDeaths= 5


then i use the table and procedure's of sir Defiance
and no problem with load and save of arena scores (when i exit in arena or log out it will load and save the scores.)
 
Flyff Developer
Loyal Member
Joined
Oct 14, 2011
Messages
1,275
Reaction score
121
@Nickthough - They're good in this moves that's why they keep telling it's easy even they only beg help as well in this problem. Even me has it but still no way in fixing.

Anyway, does anyone has a proper fix for this dc problem that Nick has as well? (Sounds stupid but it's actually not)
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
@Intelligence I fixed that disconnection problem, you need to make sure you are putting the right information in the right places, otherwise it will not work.

@Deviant Thanks for your help, both procedures are working fine as i used the Save to input information, then used the load to grab the information, That all works fine it inserts correctly and grabs it back correctly but it doesn't seem to work still when inside the arena killing people.
 
Back
Top