Jump to content

[help] Need help with my script.


Recommended Posts

Posted

i made this script with scripdev2 , when i try compile it it gives me some errors. So i need help and is it script problem or something else.

#include "precompiled.h"
bool GossipHello_resetnpc(Player *player, Creature * _Creature)
{
   Player->Add_Gossip_Item(7,"Want to reset(lvl-170 only)",Gossip_Sender_Main,1201)
   player->Send_Gossip_Menu(DEFAULT_GOSSIP_MASSAGE,_Creature->GetGUID());

   return true;
}
void SenderDefaultMenu_resetnpc(Player *player, Creature * _Creature,uint32 action)
{
   if (action == 1201)
   {
       if (player->GetLevel() == 170)
       {
       if (player->GetMoney() == 2500000)
       {
           player->Say("Im Fully reseted",LANG_UNIVERSAL);
           player->CLOSE_GOSSIP_MENU();
           Player->ModifyMoney(-2500000);
           Player->GiveLevel(1);
       }
       else
       {
           player->Say("I must be level 170 to reset",LANG_UNIVERSAL);
           player->CLOSE_GOSSIP_MENU();
       }
       }
       else
       {
           player->Say("I must have 250 gold to reset",LANG_UNIVERSAL);
           player->CLOSE_GOSSIP_MENU();
       }
   }
   bool GossipSelect_resetnpc(Player *player, Creatur * _Creature, uint32 sender, uint32 action)
   {
       if (sender == GOSSIP_SENDER_MAIN)
           SendDefaultMenu_resetnpc(player,_Creature,action);
       return true;
   }

   void AddSC_resetnpc();
   {
       Script *newscript;
       newscript = new Script;
       newscript ->Name = "resetnpc";
       newscript ->pGossipHello = &GossipHello_resetnpc;
       newscript ->pGossipSelect = &GossipSelect_resetnpc;
       newscript ->registerSelf();
   }

and this error.

1>------ Build started: Project: ScriptDev2, Configuration: Release Win32 ------
1>Extracting revision
1>Compiling...
1>resetnpc.cc
1>..\\scripts\\custom\\resetnpc.cc(4) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(4) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(13) : error C2039: 'GetLevel' : is not a member of 'Player'
1>        c:\\mangos\\src\\src\\game\\Player.h(1037) : see declaration of 'Player'
1>..\\scripts\\custom\\resetnpc.cc(19) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(19) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(20) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(20) : error C2143: syntax error : missing ';' before '->'
1>..\\scripts\\custom\\resetnpc.cc(34) : error C2061: syntax error : identifier 'Creatur'
1>..\\scripts\\custom\\resetnpc.cc(35) : error C2601: 'GossipSelect_resetnpc' : local function definitions are illegal
1>        ..\\scripts\\custom\\resetnpc.cc(10): this line contains a '{' which has not yet been matched
1>..\\scripts\\custom\\resetnpc.cc(47) : error C2440: '=' : cannot convert from 'bool (__cdecl *)(Player *)' to 'bool (__cdecl *)(Player *,Creature *,uint32,uint32)'
1>        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
1>..\\scripts\\custom\\resetnpc.cc(48) : error C2039: 'registerSelf' : is not a member of 'Script'
1>        c:\\mangos\\src\\src\\bindings\\scriptdev2\\include\\../ScriptMgr.h(28) : see declaration of 'Script'
1>..\\scripts\\custom\\resetnpc.cc(52) : fatal error C1075: end of file found before the left brace '{' at '..\\scripts\\custom\\resetnpc.cc(10)' was matched
1>Build log was saved at "file://c:\\Mangos\\src\\src\\bindings\\ScriptDev2\\VC90\\ScriptDev2__Win32_Release\\BuildLog.htm"
1>ScriptDev2 - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

again thx in adv.

And sry for long post just dont know how to insert it in code snipet.

Posted

1) All references to "Player->" should be changed to "player->"

2) "if (Player->Getlevel() = 170)" change it to "if (Player->Getlevel() == 170)" (u are comparing two values "==" not asigning "=")

3) Please... use correct code identation or it will be a pain to read it

Posted

I'm sure you've figured this out already but you didn't, make sure to read over your code, and make sure you close out each line

Player->Add_Gossip_Item(7,"Want to reset(lvl-170 only)",Gossip_Sender_Main,1201)

to

Player->Add_Gossip_Item(7,"Want to reset(lvl-170 only)",Gossip_Sender_Main,1201); <----- semicolon

Posted

#include "precompiled.h"

bool GossipHello_resetnpc(Player *player, Creature *_Creature)
{
   player->ADD_GOSSIP_ITEM(7,"Want to reset (lvl-170 only)",GOSSIP_SENDER_MAIN,1201);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());
return true;
}

void SendDefaultMenu_resetnpc(Player *player, Creature *_Creature,uint32 action)
{
if (player->getLevel() < 170)
{
   player->CLOSE_GOSSIP_MENU();
   player->Say("I must be level 170 to reset",LANG_UNIVERSAL);
   return;
}

switch(action) {
case 1201:
   if (player->GetMoney() < 2500000) {
   player->CLOSE_GOSSIP_MENU();
   player->Say("I must have 250 gold to reset",LANG_UNIVERSAL);
}else{
   player->ModifyMoney(-2500000);
   player->GiveLevel(1);
   player->CLOSE_GOSSIP_MENU();
}
break;
}
}

bool GossipSelect_resetnpc(Player *player, Creature *_Creature, uint32 sender, uint32 action)
{
   if (sender == GOSSIP_SENDER_MAIN) {
       SendDefaultMenu_resetnpc(player,_Creature,action);
   }
return true;
}

void AddSC_resetnpc()
{
Script *newscript;
   newscript = new Script;
   newscript->Name = "resetnpc";
   newscript->pGossipHello = &GossipHello_resetnpc;
   newscript->pGossipSelect = &GossipSelect_resetnpc;
   newscript->RegisterSelf();
}

Now no compile errors.

// Edit: Script works correctly now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use