当前位置:首页>>魔兽单机>>正文
修改玩家姓名的脚本代码
2013-07-05 17:43:49 作者:网络 来源: 浏览次数:0
摘要:魔兽单机版修改玩家姓名的脚本代码
 修改玩家姓名的脚本代码:
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();




相关报道:

[关闭] [返回顶部]


  返回首页 | 最新资讯 | 资源下载 | 魔兽图片 | 单机文档 | 技术攻略 | 玩家视频
备案号:蜀ICP备2024062380号-1
免责声明:本网站为热爱怀旧WOW的玩家们建立的魔兽世界资料网站,仅供交流和学习使用,非盈利和商用.如有侵权之处,请联系我们,我们会在24小时内确认删除侵权内容,谢谢合作。
Copyright © 2024 - 2024 WOWAII.COM Corporation, All Rights Reserved

机器人国度