- Joined
- May 21, 2008
- Messages
- 1,225
- Reaction score
- 110
Locking XP of a Player + No EXP Loose:
First, you might need to know that the EXP is added by the Database(as i know so far), The MatchServer is just calling Database Procedures to update the Database data like the EXP/XP of a player.
There are more than 1 Procedure which can update the XP of a player, but i think just 2 of them are the ones called while gaining XP in game.
The First Procedure is: spSimpleUpdateChar
The Second Procedure is: spUpdateCharInfoData
To lock Player(s) XP, simply check if the player exists in a list(a Table).
First Step so:
Creating a new Table called: explock, by Executting this:
Second Step:
Go to your GunzDB --> Saved Procedures --> spUpdateCharInfoData.
Click to modify it and replace it with this then execute (it will block negative XP to be add[subtracting XP] and will check the CID of the player if he is in the Table we created shortly:
Third Step:
Go to your GunzDB --> Saved Procedures --> spSimpleUpdateChar.
Click to modify it and replace this code(execute it then of course) This makes the same as in step 2 but this is just another Procedure:
Step 4 (optinal) file: characters.php:
Now a simple edit in your Admin Panel, this is a very old code, you might edit it to make it better, but this works 100%:
You might add this after or before any if and elseif, but be sure you close the brackets correctly:
config1.php:
and for the HTML code, paste it after or before any table there:
First, you might need to know that the EXP is added by the Database(as i know so far), The MatchServer is just calling Database Procedures to update the Database data like the EXP/XP of a player.
There are more than 1 Procedure which can update the XP of a player, but i think just 2 of them are the ones called while gaining XP in game.
The First Procedure is: spSimpleUpdateChar
The Second Procedure is: spUpdateCharInfoData
To lock Player(s) XP, simply check if the player exists in a list(a Table).
First Step so:
Creating a new Table called: explock, by Executting this:
Code:
USE [GunzDB]
GO
/****** Objekt: Table [dbo].[explock] Skriptdatum: 08/11/2010 13:47:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[explock](
[CID] [int] NOT NULL,
[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Staff] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[StaffAid] [int] NULL,
[Date] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
Second Step:
Go to your GunzDB --> Saved Procedures --> spUpdateCharInfoData.
Click to modify it and replace it with this then execute (it will block negative XP to be add[subtracting XP] and will check the CID of the player if he is in the Table we created shortly:
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/* 캐릭터 정보(XP, BP, KillCount, DeathCount) 업데이트 */
ALTER PROC [dbo].[spUpdateCharInfoData]
@XPInc int,
@BPInc int,
@KillInc int,
@DeathInc int,
@CID int
AS
SET NOCOUNT ON
DECLARE @CIDCount int
SELECT @CIDCount=COUNT(*) FROM explock(nolock) WHERE CID=@CID
If (@XPInc > 0 AND @CIDCount <> 1)
Begin
UPDATE Character
SET XP=XP+(@XPInc), BP=BP+(@BPInc), KillCount=KillCount+(@KillInc), DeathCount=DeathCount+(@DeathInc)
WHERE CID=@CID
End
else
Begin
UPDATE Character
SET BP=BP+(@BPInc), KillCount=KillCount+(@KillInc), DeathCount=DeathCount+(@DeathInc)
WHERE CID=@CID
End
Third Step:
Go to your GunzDB --> Saved Procedures --> spSimpleUpdateChar.
Click to modify it and replace this code(execute it then of course) This makes the same as in step 2 but this is just another Procedure:
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/* 캐릭터 정보 업데이트 - 한사람 죽일때마다 업데이트한다. */
ALTER PROC [dbo].[spSimpleUpdateChar]
@CID int,
@Name varchar(24),
@Level smallint,
@XP int,
@BP int
AS
SET NOCOUNT ON
DECLARE @CIDCount int
--DECLARE @UGradeID int
--DECLARE @AID int
SELECT @CIDCount=COUNT(*) FROM explock(nolock) WHERE CID=@CID
--SELECT @AID=AID FROM Character where CID=@CID
--SELECT @UGradeID=UGradeID FROM Account WHERE AID=@AID
If (@XP > 0 AND @CIDCount <> 1)
Begin
/*If (@UGradeID < 252)
begin*/
UPDATE Character WITH (rowlock)
SET Level=@Level, XP=@XP, BP=@BP
WHERE CID=@CID AND Name=@Name
End
else
Begin
UPDATE Character WITH (rowlock)
SET BP=@BP
WHERE CID=@CID AND Name=@Name
End
/*else if (@UGradeID >=252 and @UGradeID <> 253)
begin
UPDATE Character WITH (rowlock)
SET XP=@XP, BP=@BP
WHERE CID=@CID AND Name=@Name
End
*/
Step 4 (optinal) file: characters.php:
Now a simple edit in your Admin Panel, this is a very old code, you might edit it to make it better, but this works 100%:
You might add this after or before any if and elseif, but be sure you close the brackets correctly:
PHP:
}elseif ( isset($_POST['lockexp'])){
Require "config1.php"; //cuz i like mssql
$type = clean_sql($_POST['type']);
$lockname = clean_sql($_POST['lockname']);
if( $type == "" || $lockname == "" )
{
setmessage("EXP Lock Character", "Fill in the field!");
redirect("index.php?do=characters");
die();
}
if ($type == 0){
$lol = 'Name';
}else{
$lol = 'CID';
}
$swapper = mssql_query ("SELECT * FROM explock WHERE $lol = '$lockname'");
If (Mssql_num_rows ($swapper) == 1){
setmessage("EXP Lock Character", "The Entered Character $lol: $lockname is already EXP Locked :)");
redirect("index.php?do=characters");
die();
}
if ($type == 0){
$checkname = Mssql_query ("SELECT CID FROM Character WHERE Name = '$lockname'");
if (mssql_num_rows($checkname) != 1){
setmessage("EXP Lock Character", "The Entered Character Name: $lockname doesn't Exsit!");
redirect("index.php?do=characters");
die();
}elseif (mssql_num_rows($checkname) == 1){
$checknameinfo = mssql_fetch_object ($checkname);
$CID = $checknameinfo->CID;
Mssql_query ("INSERT INTO explock (CID, Name, Staff, StaffAid, Date) VALUES ('$CID', '$lockname', '$_SESSION[UserID]', '$_SESSION[AID]', GETDATE())");
setmessage("EXP Lock Character", "The Entered Character Name: $lockname has been EXP Locked Successfully!");
redirect("index.php?do=characters");
die();
}
}elseif ($type == 1){
$checkcid = mssql_query("SELECT CID, Name FROM Character WHERE CID = '$lockname'");
If (mssql_num_rows($checkcid ) == 1){
$info = mssql_fetch_object ($checkcid);
$Charname = $info->Name;
Mssql_query ("INSERT INTO explock (CID, Name, Staff, StaffAid, Date) VALUES ('$lockname', '$Charname', '$_SESSION[UserID]', '$_SESSION[AID]', GETDATE())");
setmessage("EXP Lock Character", "The Entered Character CID: $lockname Name: $Charname has been EXP Locked Successfully!");
redirect("index.php?do=characters");
die();
}else{
setmessage("EXP Lock Character", "The Entered Character CID: $lockname doesn't Exsit!");
redirect("index.php?do=characters");
die();
}
}
config1.php:
PHP:
<?php
$mssql_user = "me";
$mssql_pass = "1234";
$mssql_database = 'yahooDB';
$mssql_host = 'yahoo.com/sqlexpress';
$conn = mssql_connect($mssql_host, $mssql_user, $mssql_pass);
mssql_select_db($mssql_database);
?>
and for the HTML code, paste it after or before any table there:
PHP:
<br />
<table style="border-collapse: collapse;" id="lockchar"
border="1">
<tbody>
<tr>
<td colspan="2"><b>Lock EXP Character</b></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<form method="post" action="index.php?do=characters">
<tr>
<td>
<select name="type">
<option value="0">Name</option>
<option value="1">CID</option>
</select>
: <input name="lockname" type="text"> <input
name="lockexp" value="Lock EXP" type="submit">
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</form>
</tbody>
</table>
<br />