Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::General Support

Support::General Support Post all topics here having to do with errors while trying to connect to an EQEMu server but not about the setup/running of the Server itself.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-04-2008, 02:47 PM
spider661
Discordant
 
Join Date: Oct 2005
Location: michigain
Posts: 260
Default adding new code help

im trying to add a new command for quest i came up with the ideal when i was trying to do a quest that did not work the way i wanted. well someone posted code that should work the way i wanted but i decided to go ahead and make the code just to do it as a learning exp well i am havering problems so ill post it here to see if anyone can see whats wrong.

what this should do is read a variable from a new table called server_globals and then the quest should return the correct int.
questmgr.cpp
Code:
////////////////////////////////////////////ADDED/////////////////////////////////////
int QuestManager::GetServerInt(const char *varname, int npcid, int zoneid)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
	MYSQL_ROW row;
	int var = 0;

if(npcid < 1){
npcid = 0;}

if(zoneid < 1){
zoneid = 0;}

		if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT value FROM server_globals WHERE name='%s' AND npcid = %i AND zoneid = %i", varname, npcid, zoneid), errbuf, &result)){
		safe_delete_array(query);
		if (mysql_num_rows(result) == 1){
			row = mysql_fetch_row(result);
				if (row[0])
					var = atoi(row[0]);
			}
		mysql_free_result(result);
		}
		else{
			LogFile->write(EQEMuLog::Error, "Error in GetServerInt query", query, errbuf);
			//cerr << "Error in GetServerInt query '" << query << "' " << errbuf << endl;
			safe_delete_array(query);
			}

	return var;
}
///////////////END ADD//////////////////////////////////////////////////////////////////////
questmgr.h
Code:
///////////////////ADDED//////////////////////////////////////////////////
	int QuestManager::GetServerInt(const char *varname, int npcid = 0, int zoneid = 0);
///////////////////DONE ADD///////////////////////////////////////////////
perlparser.cpp
Code:
/////////////////////////ADDED//////////////////////////////////////////////////
XS(XS__GetServerInt);
XS(XS__GetServerInt)
{
	dXSARGS;
	if (items == 1)
	{
		char *		varname = (char *)SvPV_nolen(ST(0));
		quest_manager.GetServerInt(varname);
	}
	else if(items == 3)
	{
		char *		varname = (char *)SvPV_nolen(ST(0));
		int	npcid = (int)SvIV(ST(1));
		int	zoneid = (int)SvIV(ST(2));
		quest_manager.GetServerInt(varname, npcid, zoneid);		
	}
	else 
	{
		Perl_croak(aTHX_ "Usage: GetServerInt(varname,npcid = 0,zoneid = 0)");
	}
	XSRETURN_EMPTY;
}
//////////////////////////END ADD////////////////////////////////////////////
/*



added at end
/////////////////////ADDED//////////////////////////////////////////////////////
		newXS(strcpy(buf, "GetServerInt"), XS__GetServerInt, file);
////////////////////END ADDED///////////////////////////////////////////////////
the quest on the npc
Code:
sub EVENT_SAY
{
if ($text =~/Hail/i)
 {
if(quest::GetServerInt("myquest") == 10)
{
quest::say ("yay it worked");
}
else
{
quest::say ("no 10 here");
}
 }
}
the error eqemu_quest_zone_3236.log
Code:
[07.04. - 07:40:02] Use of uninitialized value in numeric eq (==) at quests/qrg/testpet.pl line 6.
i have tryed the quest file many ways and still cant get it working. same error or close to it every time.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:45 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3