What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

[Question] Plugin return XP of char

Glookie1

New Member
Joined
Oct 3, 2011
Messages
24
Reaction score
0
Hi,

I was just trying to write my first own plugin for HB, but I'm a little bit stuck right now.

What I want to do is to get the players XP. So I figuered I should do something like this:

Code:
get
{
      return Lua.GetReturnVal<int>("return UnitXPMax(\"player\")");
}

I do get the following error:
Code:
Das Plugin von C:\Users\***\Honorbuddy\HB\Plugins\ETALUp.cs konnte nicht erstellt werden! Erstellungsfehler:
Datei: ETALUp.cs Pfad: 67 Fehler: Keine ?berladung f?r die GetReturnVal-Methode nimmt 1 Argumente an.

I know it is probably a stupid error, but right now I'm too stupid to find it :/
I'll appreciate any help.

Glookie1

Edit: Never mind, I just found my mistake >.< It was a really stupid one. I forgot to add the , 1 at the end.
Lua.GetReturnVal<int>("return UnitXPMax(\"player\")", 1);

Edit2: Hmm seems that this doesn't work as expected - it just returns 0. Maybe someone else has another idea how to acomplish this?
 
Last edited:
This should do it
PHP:
Lua.GetReturnVal<int>("return UnitXPMax(\"player\")", 0);

EDIT: A little explanation of what you did wrong.
You wrote 1 at the end of Lua.GetReturnVal, but the lua function only returns a single number, and since they're 0-indexed it's returning a value that doesn't exist and hence it becomes 0.
If it was something else like GetItemInfo(itemID) it returns several different values. As an example, an output from HBConsole:
Code:
[0] = Copper Ore
[1] = |cffffffff|Hitem:2770:0:0:0:0:0:0:0:85:0|h[Copper Ore]|h|r
[2] = 1
[3] = 10
[4] = 0
[5] = Trade Goods
[6] = Metal & Stone
[7] = 20
[8] = 
[9] = Interface\Icons\INV_Ore_Copper_01
[10] = 5
Then the number you write at the end of Lua.GetReturnVal is the value you want to get, so for example if you wanted "Trade Goods" from this, you'd write
PHP:
Lua.GetReturnVal<int>("return GetItemInfo(2770)", 5);
 
Last edited:
or you can just use the API to do it, since its much safer and faster.
Code:
public int ExpToLevel = Me.Experience - Me.NextLevelExperience;
 
Thanks to both of you - I'll post later wether everything worked Out as planned.
Edit: Well everything works so far - only thing I still need to figure out is how to add my own Information to the Infotab in HB
 
Last edited:
or you can just use the API to do it, since its much safer and faster.
Code:
public int ExpToLevel = Me.Experience - Me.NextLevelExperience;
Ya this is better. I'm not good with HB's API :P
 
Thanks to both of you - I'll post later wether everything worked Out as planned.
Edit: Well everything works so far - only thing I still need to figure out is how to add my own Information to the Infotab in HB
you cant.
 
too bad D: would be the perfect place since it just provides some info^^
Nonetheless I'll try to get it to work.
 
Back
Top