Hello,
i´ve got a problem i found a script witch is very intresting for me the one problem ive got is the only compiling tutorial is for windows ... and visual Studio. Iam using UNIX Debian Etch and did Following settings to compile.
==========================================================
Folder where the script is:
==========================================================
arcemu/trunk/src/scripts/src/WOL
==========================================================
The folder contains: (insides below)
==========================================================
HouseNPC.cpp
Makefile
Makefile.am
Setup.cpp
Setup.h
==========================================================
HouseNPC.cpp
==========================================================
Code:
#include "StdAfx.h"
#include "Setup.h"
#include "mysql/mysql.h"
#include <stdio.h>
#ifdef WIN32
#pragma warning(disable:4305)
#pragma warning(disable:4244)
#endif
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
#define server "xxx.xxx.xxx.xxx"
#define user "xxxxx"
#define password "xxxxx"
#define database "xxxxx"
class SCRIPT_DECL HouseNPC : public GossipScript
{
public:
#pragma region Hello
void GossipHello(Object * pObject, Player* plr, bool AutoSend)
{
GossipMenu *menu;
objmgr.CreateGossipMenuForPlayer(&menu, pObject->GetGUID(), 1, plr);
if(!plr->CombatStatus.IsInCombat())
{
menu->AddItem(1, "Get a house", 1);
menu->AddItem(2, "Teleport to your house", 2);
}
else
plr->BroadcastMessage("You are in combat.");
if(AutoSend)
menu->SendTo(plr);
};
#pragma endregion
#pragma region Selection
void GossipSelectOption(Object * pObject, Player* plr, uint32 id, uint32 intId, const char * code)
{
switch(intId)
{
case 1: //Get a house
{
bool haveHouse = false;
//Init the mysql client
conn = mysql_init(NULL);
//Connect to the database
if(!mysql_real_connect(conn, server, user, password, database, 3306, NULL, 0))
{
sLog.outString("HouseNPC: %s.", mysql_error(conn));
return;
}
//Send a query that loads the houses table
mysql_query(conn, "SELECT * FROM houses");
res = mysql_use_result(conn);
if(res)
{
while((row = mysql_fetch_row(res)) != NULL)
{
//Get guids
uint32 plr_guid = plr->GetGUID();
uint32 r_guid = atol(row[0]);
if(r_guid == plr_guid)
haveHouse = true; break;
}
}
else
{
sLog.outString("HouseNPC: %s.", mysql_error(conn));
return;
}
if(!haveHouse)
{
char sql[512];
snprintf(sql, 512, "INSERT INTO houses(ownerguid, posX, posY, posZ, mapId) VALUES(%u, 242.284, 0.74529, 1.75938, 598);", plr->GetGUID());
mysql_query(conn, sql);
plr->BroadcastMessage("You just got a house.");
}
else
{
plr->BroadcastMessage("You do alredy have a house.");
}
mysql_free_result(res);
mysql_close(conn);
}break;
case 2: //Teleport to your house
{
bool haveHouse = false;
//Init the mysql client
conn = mysql_init(NULL);
//Connect to the database
if(!mysql_real_connect(conn, server, user, password, database, 3306, NULL, 0))
{
sLog.outString("HouseNPC: %s.", mysql_error(conn));
return;
}
//Send a query that loads the houses table
mysql_query(conn, "SELECT * FROM houses");
res = mysql_use_result(conn);
if(res)
{
while((row = mysql_fetch_row(res)) != NULL)
{
//Get guids
uint32 plr_guid = plr->GetGUID();
uint32 r_guid = atol(row[0]);
if(r_guid == plr_guid)
{
plr->EventTeleport(atol(row[4]), atol(row[1]), atol(row[2]), atol(row[3]));
haveHouse = true;
break;
}
}
}
if(!haveHouse)
{
plr->BroadcastMessage("You don't have a house.");
}
mysql_free_result(res);
mysql_close(conn);
}break;
}
};
#pragma endregion
#pragma region Dispose
void HouseNPC::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
};
void Destroy()
{
delete this;
};
#pragma endregion
};
void SetupHouseNPC(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new HouseNPC();
mgr->register_gossip_script(160000, gs);
};
==========================================================
Makefile.am
==========================================================
Code:
INCLUDES = -I$(top_srcdir)/src/arcemu-logonserver \
-I$(top_srcdir)/src/arcemu-realmserver -I$(top_srcdir)/src/arcemu-shared -I$(top_srcdir)/src/arcemu-voicechat \
-I$(top_srcdir)/src/arcemu-world -I$(srcdir) -I$(srcdir)/../../../../dep/include \
-I$(srcdir)/../../../../dep/src -I$(srcdir)/../../../../src
AM_CXXFLAGS = -DSCRIPTLIB
lib_LTLIBRARIES = libSunGossipScripts.la
libSunGossipScripts_la_SOURCES = \
HouseNPC.cpp \
Setup.cpp
==========================================================
Setup.cpp
==========================================================
Code:
#include "StdAfx.h"
#include "Setup.h"
#define SKIP_ALLOCATOR_SHARING 1
#include <scriptSetup.h>
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupHouseNPC(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
==========================================================
Setup.h
==========================================================
Code:
#ifndef INSTANCE_SCRIPTS_SETUP_H
#define INSTANCE_SCRIPTS_SETUP_H
void SetupHouseNPC(ScriptMgr * mgr);
#endif
==========================================================
Including Dir in Makefile.am:
==========================================================
/arcemu/trunk/src/scripts/src/Makefile.am
Code:
SUBDIRS = InstanceScripts WOL GossipScripts ExtraScripts ServerStatusPlugin SpellHandlers LUAScripting QuestScripts EventScripts MiscScripts
==========================================================
Including Script on configure.ac:
==========================================================
/arcemu/trunk/configure.ac
Code:
AC_CONFIG_FILES([
Makefile
src/Makefile
src/arcemu-shared/Makefile
src/arcemu-world/Makefile
src/arcemu-logonserver/Makefile
src/arcemu-crashreport/Makefile
src/scripts/Makefile
src/scripts/src/Makefile
src/scripts/src/GossipScripts/Makefile
src/scripts/src/ExtraScripts/Makefile
src/scripts/src/MiscScripts/Makefile
src/scripts/src/InstanceScripts/Makefile
src/scripts/src/ServerStatusPlugin/Makefile
src/scripts/src/WOL/Makefile
src/scripts/src/SpellHandlers/Makefile
src/scripts/src/LUAScripting/Makefile
src/scripts/src/QuestScripts/Makefile
src/scripts/src/EventScripts/Makefile
src/collision/Makefile
])
==========================================================
==========================================================
After all of This config includes and after doing following commands on SSH:
# svn update
# make clear
# autoreconf -i -f
# ./configure prefix=/home/arcemu/trunk --enable-lua-scripting --enable-collision --enable-debug && make -j 4 && make install
i`ve got this error:
HouseNPC.cpp:25: warning: ignoring #pragma region Hello
HouseNPC.cpp:43: warning: ignoring #pragma endregion
HouseNPC.cpp:45: warning: ignoring #pragma region Selection
HouseNPC.cpp:147: warning: ignoring #pragma endregion
HouseNPC.cpp:149: warning: ignoring #pragma region Dispose
HouseNPC.cpp:159: warning: ignoring #pragma endregion
HouseNPC.cpp:150: error: extra qualification 'HouseNPC::' on member 'GossipEnd'
HouseNPC.cpp: In member function 'virtual void HouseNPC::GossipSelectOption(Object*, Player*, uint32, uint32, const char*)':
HouseNPC.cpp:89: warning: format '%u' expects type 'unsigned int', but argument 4 has type 'long long unsigned int'
HouseNPC.cpp:89: warning: format '%u' expects type 'unsigned int', but argument 4 has type 'long long unsigned int'
make[5]: *** [HouseNPC.lo] Error 1
make[5]: Leaving directory `/home/arcemu/trunk/src/scripts/src/WOL'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/arcemu/trunk/src/scripts/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/arcemu/trunk/src/scripts'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/arcemu/trunk/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/arcemu/trunk
make: *** [all] Error 2
So now i hope i was detailed enough that some one can help me thru my problem ;D
best regards nOeX