How to use CallPlugin with gmcpval

Posted by Whininguser on Thu 17 Nov 2011 12:43 AM — 5 posts, 18,408 views.

Canada #0
The client I'm using is right on Aardwolf's homepage.

If I ran this:

print(CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.vitals.hp"))

The output would be 0 100, and 100 is my hp. But how can I store this 100 in a script that's not a plugin? I tried doing s = (CallPlugin...) and print(s), and it simply printed 0.

Thanks for any help.
Amended on Thu 17 Nov 2011 12:56 AM by Whininguser
USA Global Moderator #1
instead of s = (CallPlugin...) do
err,s = CallPlugin...
to get the second returned value put into s instead of the first.
Amended on Thu 17 Nov 2011 02:52 PM by Fiendish
Canada #2
I hardly know any Lua, so could you elaborate?

I just tried

err,s = (CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.vitals.hp"))

and print(s) showed nil.

I must be doing something wrong, but I have no idea what it is. More help please.
Amended on Thu 17 Nov 2011 04:13 AM by Whininguser
Australia Forum Administrator #3
Lose the brackets around CallPlugin. That forces Lua to throw away all returned values except the first. For example:


function foo ()
  return 1, 2
end 

a, b = foo ()

print (a, b)   --> prints: 1, 2

a, b = (foo ())

print (a, b)   --> prints: 1, nil

Canada #4
Got it. Thanks guys.