Log in

View Full Version : Fixed Quest Item Turn-in using $ItemCount()


krich
06-21-2003, 07:24 PM
This was a pain...

In client_process.cpp, Client::HandlePacket

FROM:
parse->Event(EVENT_ITEM, tmp->GetNPCTypeID(), 0, tmp, this->CastToMob());

TO:
char tradeliststring[100];
memset(tradeliststring, 0, sizeof(tradeliststring));
for (int k = 0; k <=3; k++) {
strncat(tradeliststring, itoa(TradeList[k]), sizeof(tradeliststring));
strncat(tradeliststring, " ", sizeof(tradeliststring));
}
parse->Event(EVENT_ITEM, tmp->GetNPCTypeID(), tradeliststring, tmp, this->CastToMob());


Then, In parser.cpp, Parser::Event

FROM:
case EVENT_ITEM: {
SendCommands("event_item", qstID, npcmob, mob);
break;
}

TO:
case EVENT_ITEM: {
char varname[20];
int token = 1;
char varvalue[10];
int v = 0;

memset(varname, 0, sizeof(varname));
memset(varvalue, 0, sizeof(varvalue));

for (int k=0; k<=strlen(data); k++) {
if (data[k] == ' ') {
snprintf(varname, sizeof(varname), "item%d.%d", token, npcid);
AddVar(varname, varvalue);
memset(varvalue, 0, sizeof(varvalue));
memset(varname, 0, sizeof(varname));
token++;
v=0;
}
else {
varvalue[v] = data[k];
v++;
}
}
SendCommands("event_item", qstID, npcmob, mob);
break;
}


And finally, In parser.cpp, Parser:ParseVars

FROM:
if (record == 1 && pch[i] != ')')


TO:
if (record == 1 && pch[i] != ')' && pch[i]!='\"')

That should do it...

Regards,

krich

used_pawn
06-21-2003, 08:52 PM
sorry for a stupid question, but what does this fix? (having trouble following the code)
hope im not offending, I just cant see it I guess.

krich
06-22-2003, 07:49 AM
No problem. Hey, if I'm submitting bad code, no mercy...lol.

It passes the contents of the NPC trade window into the Event method so that they can be made into the variables $item1 through $item4 and then be used by the $itemcount() function.

I am going to take my name out of it though...hehe

Regards,

krich

Bigpull
06-22-2003, 08:02 AM
TO:
Code:
if (record == 1 && pch[i] != ')' && pch[i]!='\"')


Here is the actual problem, functions require " variables however didn't like them. Without digging out the code i'd assume just this would remedy most scripts.