- Joined
- May 26, 2014
- Messages
- 482
- Reaction score
- 32
Hi guys i'm back and i just finish my buff system, i try this on AKCore but you can do it with your own soruces.
First Make a table for the buffs called skillsbuf with:
Note: Put id with auto increment
Next make a function and call it how do you want i call it CurrentBuff and put this inside
And
Next go to SendCharSkillCasting and before { put
Now go to SendCharSkillBuffDrop and at the end put this
And in SendAvatarBuffInfo change
app->db->prepare("SELECT * FROM skills WHERE owner_id = ?");
--->
app->db->prepare("SELECT * FROM skillsbuff WHERE owner_id = ?");
And
int SkillId = app->db->getInt("skill_id");
-->
int SkillId = app->db->getInt("effect_id");
First Make a table for the buffs called skillsbuf with:
Code:
Fields Type Length Decimals NotNull PrimaryKey
id int 11 0 yes Yes
effect_id int 10 0 yes no
owner_id int 11 0 yes no
TimeRemaining int 15 0 yes no
Note: Put id with auto increment
Next make a function and call it how do you want i call it CurrentBuff and put this inside
Code:
BEGIN
IF(SELECT EXISTS(SELECT 1 FROM skillsbuff WHERE effect_id = tblidx AND owner_id = ownerid)) THEN
UPDATE skillsbuff SET TimeRemaining=dwTimeRemaining WHERE owner_id = ownerid AND effect_id = tblidx;
SET removebuff = 1;
ELSE
INSERT INTO skillsbuff (effect_id, owner_id, TimeRemaining)
VALUES
(tblidx, ownerid, dwTimeRemaining);
SET removebuff = 0;
END IF;
END
And
Code:
Parameter
IN `dwTimeRemaining` int,IN `tblidx` int,IN `ownerid` int, OUT `removebuff` bit
Type
Procedure
Next go to SendCharSkillCasting and before { put
Code:
{
app->db->prepare("CALL CurrentBuff (?,?,?, @[I][B][URL="http://forum.ragezone.com/members/2000092514.html"]remove[/URL][/B][/I]buff)");
app->db->setInt(1, SkillNow->dwKeepTimeInMilliSecs);
app->db->setInt(2, SkillNow->tblidx);
app->db->setInt(3, this->plr->pcProfile->charId);
app->db->execute();
app->db->execute("SELECT @[I][B][URL="http://forum.ragezone.com/members/2000092514.html"]remove[/URL][/B][/I]buff");
app->db->fetch();
if (app->db->getBoolean( @[I][B][URL="http://forum.ragezone.com/members/2000092514.html"]remove[/URL][/B][/I]buff") == true)
{
//Get Skill to Remove
CSkillTable * pSkillTable = app->g_pTableContainer->GetSkillTable();
sSKILL_RESULT * pSkillData = (sSKILL_RESULT*)pPacket->GetPacketData();
//Response Prepare
CNtlPacket packet(sizeof(sGU_BUFF_DROP_RES));
sGU_BUFF_DROP_RES * res = (sGU_BUFF_DROP_RES*)packet.GetPacketData();
res->wOpCode = GU_BUFF_DROP_RES;
res->wResultCode = GAME_SUCCESS;
//Dropp Event Prepare
CNtlPacket packet2(sizeof(sGU_BUFF_DROPPED));
sGU_BUFF_DROPPED * pBuffDrop = (sGU_BUFF_DROPPED*)packet2.GetPacketData();
pBuffDrop->hHandle = this->GetavatarHandle();
pBuffDrop->bySourceType = DBO_OBJECT_SOURCE_SKILL;//Need be rechecked because this can be a type DBO_OBJECT_SOURCE_ITEM
pBuffDrop->wOpCode = GU_BUFF_DROPPED;
pBuffDrop->tblidx = SkillNow->tblidx;
//First Drop,Second Resp to client
packet2.SetPacketLen(sizeof(sGU_BUFF_DROPPED));
packet.SetPacketLen(sizeof(sGU_BUFF_DROP_RES));
g_pApp->Send(this->GetHandle(), &packet2);
g_pApp->Send(this->GetHandle(), &packet);
app->UserBroadcastothers(&packet2, this);
app->UserBroadcastothers(&packet, this);
}
Now go to SendCharSkillBuffDrop and at the end put this
Code:
app->db->prepare("DELETE FROM skillsbuff WHERE effect_id=? AND owner_id=?");
app->db->setInt(1, req->tblidx);
app->db->setInt(2, this->plr->pcProfile->charId);
app->db->execute();
}
And in SendAvatarBuffInfo change
app->db->prepare("SELECT * FROM skills WHERE owner_id = ?");
--->
app->db->prepare("SELECT * FROM skillsbuff WHERE owner_id = ?");
And
int SkillId = app->db->getInt("skill_id");
-->
int SkillId = app->db->getInt("effect_id");
Last edited: