关灯
开启左侧

修改玩家姓名的脚本代码

  [复制链接]
admin实名认证 发表于 2016-4-18 22:48:09 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
修改玩家姓名的脚本代码:
diff -r a09fe1125922 src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp
--- a/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp        Wed Sep 30 04:26:35 2009 -0700
+++ b/src/bindings/scripts/scripts/examples/example_gossip_codebox.cpp        Wed Sep 30 20:11:23 2009 +0200
@@ -31,7 +31,8 @@

     SAY_NOT_INTERESTED      = -1999922,
     SAY_WRONG               = -1999923,
-    SAY_CORRECT             = -1999924
+    SAY_CORRECT             = -1999924,
+        SAY_BYE_BYE                                = -1999915
};

#define GOSSIP_ITEM_1       "A quiz: what's your name?"
@@ -97,3 +98,85 @@
     newscript->pGossipSelectWithCode = &GossipSelectWithCode_example_gossip_codebox;
     newscript->RegisterSelf();
}
+
+
+
+/* Begin custom code for the NPC Renamer */
+/*****************************************/
+/* ScriptData
+Author: 1RR3QU13T0 - ricci77
+SDName: npc_rename_script
+SD%Complete: 100
+SDComment: Npc that can change pg name after a login
+SDCategory: Script Examples
+EndScriptData */
+
+//This function is called when the player opens the gossip menubool
+bool GossipHello_custom_rename_codebox(Player *player, Creature *_Creature)
+{
+    player->ADD_GOSSIP_ITEM_EXTENDED(0, "Rename? Put yes or no in the box. If you choose yes, you need 500 gold.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
+    player->ADD_GOSSIP_ITEM(0, "You're not interested.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+    player->PlayerTalkClass->SendGossipMenu(907,_Creature->GetGUID());
+    return true;
+}
+
+//This function is called when the player clicks an option on the gossip menubool
+bool GossipSelect_custom_rename_codebox(Player *player, Creature *_Creature, uint32 sender, uint32 action )
+{
+    if(action == GOSSIP_ACTION_INFO_DEF+2)
+    {
+                DoScriptText(SAY_NOT_INTERESTED, _Creature);
+        player->CLOSE_GOSSIP_MENU();
+    }
+    return true;
+}
+
+bool GossipSelectWithCode_custom_rename_codebox( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode )
+{
+        // "cost" is the amount of gold needed for renaming - set to 500g
+        uint32 cost = 5000000;
+    if(sender == GOSSIP_SENDER_MAIN)
+    {
+        if(action == GOSSIP_ACTION_INFO_DEF+1)
+        {
+            if(std::strcmp(sCode, "yes") ==0)
+            {
+                                if (player->GetMoney() < cost)
+                                {
+                                        player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
+                                        player->CLOSE_GOSSIP_MENU();
+                                }
+                                else
+                                {
+                DoScriptText(SAY_BYE_BYE, _Creature);
+                player->SetAtLoginFlag(AT_LOGIN_RENAME);
+                player->CLOSE_GOSSIP_MENU();
+                                player->SetMoney( player->GetMoney() - cost );
+                                }
+            }
+            else if (std::strcmp(sCode, "no") ==0)
+            {
+                DoScriptText(SAY_BYE_BYE, _Creature);
+                                player->CLOSE_GOSSIP_MENU();
+            }
+            else
+            {
+                player->CLOSE_GOSSIP_MENU();
+            }
+            return true;
+        }
+    }
+    return false;
+}
+
+void AddSC_custom_rename_codebox()
+{
+    Script *newscript;
+
+    newscript = new Script;
+    newscript->Name="custom_rename_codebox";
+    newscript->pGossipHello =           &GossipHello_custom_rename_codebox;
+    newscript->pGossipSelect =          &GossipSelect_custom_rename_codebox;
+    newscript->pGossipSelectWithCode =  &GossipSelectWithCode_custom_rename_codebox;
+    newscript->RegisterSelf();
+}
diff -r a09fe1125922 src/bindings/scripts/system/ScriptLoader.cpp
--- a/src/bindings/scripts/system/ScriptLoader.cpp        Wed Sep 30 04:26:35 2009 -0700
+++ b/src/bindings/scripts/system/ScriptLoader.cpp        Wed Sep 30 20:11:23 2009 +0200
@@ -11,6 +11,7 @@
extern void AddSC_example_escort();
extern void AddSC_example_gossip_codebox();
extern void AddSC_example_misc();
+extern void AddSC_custom_rename_codebox();

//world
extern void AddSC_areatrigger_scripts();
@@ -425,6 +426,7 @@
     AddSC_example_escort();
     AddSC_example_gossip_codebox();
     AddSC_example_misc();
+        AddSC_custom_rename_codebox();

     //world
     AddSC_areatrigger_scripts();

标签:姓名
 

精彩评论1

倒序浏览
admin实名认证 发表于 2016-4-18 22:48:22 | 显示全部楼层
 
SQL的部分代码

/*
SQLyog Community Edition- MySQL GUI
MySQL - 5.1.33-community
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;


insert into `creature_template` (`entry`, `heroic_entry`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `minlevel`, `maxlevel`, `minhealth`, `maxhealth`, `minmana`, `maxmana`, `armor`, `faction_A`, `faction_H`, `npcflag`, `speed`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `dmg_multiplier`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `unk16`, `unk17`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `movementId`, `RegenHealth`, `equipment_id`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`) values('99999','0','0','0','4602','4602','4602','4601','NPC Renamer',NULL,'Directions','75','75','15952','15952','0','0','8219','1797','1797','268435457','1.2','1','0','342','485','0','392','1','2000','0','1','36864','0','0','0','0','0','0','295','438','68','7','0','0','3296','0','0','0','0','0','0','0','40505','8599','0','0','0','0','0','0','0','0','0','0','','0','1','1.5','1','0','0','0','0','0','0','1','295','0','0','custom_rename_codebox');
 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

    注册账号后积极发帖的会员
  • 活跃会员

    经常参与各类话题的讨论,发帖内容较有主见
  • 热心会员

    经常帮助其他会员答疑
  • 推广达人

    积极宣传本站,为本站带来更多注册会员
  • 宣传达人

    积极宣传本站,为本站带来更多的用户访问量
  • 灌水之王

    经常在论坛发帖,且发帖量较大
  • 突出贡献

    长期对论坛的繁荣而不断努力,或多次提出建设性意见
  • 优秀版主

    活跃且尽责职守的版主
  • 荣誉管理

    曾经为论坛做出突出贡献目前已离职的版主
  • 论坛元老

    为论坛做出突出贡献的会员

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

吾爱尚玩资源基地永久域名:

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

Copyright   ©2015-2116  吾爱尚玩资源基地|523play.comPowered by©523Pplay.Com技术支持:吾爱尚玩资源基地