Quote:
Originally posted by wonderboysp2p
-now what am i doing wrong?
|
You are not using code tags and you named this thread so it tells nothing about your problem.
I think the problem is that you use keypressed and keydown. You should either figure out the key that was pressed by the #p thingies you get along with keypressed, or you should use a timeout loop and check whether the key was already pressed in the previous frame (by doing this.oldkeydown = keydown(6) after everything).
Otherwise, any keypress while A is pressed will trigger the action again. It is not true, though, that this gets looped as someone said.
Other than that, you should do some precalculating instead of writing everything in the replacestring line. It helps not only readability but also might be more efficient, if it takes less time to access variables than it takes to call lindexof and stuff. But readability still wins.
NPC Code:
else {
itemindex = lindexof(#s(this.item),client.inv);
itemcount = strtofloat(#I(client.invcount, itemindex)) + 1;
replacestring client.invcount,itemindex,#v(itemcount);
}
destroy; // Assuming it is supposed to be "picked up" now
Next, you might consider allowing items to not only have a type but also a quantity so if many items of the same type are close, they get put together into one NPC.
And have a look at
my item system, perhaps.