Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

Reply
 
Thread Tools Display Modes
  #1  
Old 11-16-2018, 12:50 PM
irongut_av's Avatar
irongut_av
Fire Beetle
 
Join Date: Sep 2018
Posts: 20
Default TakeMoneyFromPP() not working for this script

I've tried to use TakeMoneyFromPP() in Lua, in several different scripts and can't seem to get it working. I'm using an EQEMU version from October. Perhaps I'm just doing it wrong.

Example from global\global_player.lua (there is no global_player.pl):


Code:
function event_enter_zone(e)
  if(e.self:GetName() == "Raccoon") then
    if(e.self:TakeMoneyFromPP(1000, true)) then
      e.self:Message(14,"Thanks for the cash!")
    else
      e.self:Message(14,"You're broke, sucker!")
    end
  end 
end
Reply With Quote
  #2  
Old 11-16-2018, 01:01 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,594
Default

Value is in copper. I.E the 1,000 you have is 1 Platunum, not 1,000 Platinum. For 1,000 you’d need to put 1,000,000 there.
Reply With Quote
  #3  
Old 11-16-2018, 01:09 PM
irongut_av's Avatar
irongut_av
Fire Beetle
 
Join Date: Sep 2018
Posts: 20
Default

Thanks for the reply... I understand about the value being copper.

The problem is that no money is being taken at all. The method is not returning a Boolean, and no message is shown to the entering client that has the proper name. I wanted to know if this script will fire on someone else's server, of course checking for a different client name, etc.


Edit: I've updated the script, to verify the event is firing correctly... and it does:
Code:
function event_enter_zone(e)
  if(e.self:GetName() == "Raccoon") then
    e.self:Message(14, "Hi Raccoon")
    if(e.self:TakeMoneyFromPP(1000, true)) then
      e.self:Message(14,"Thanks for the cash!")
    else
      e.self:Message(14,"You're broke, sucker!")
    end
  end 
end

The only message I see with my test client is "Hi Raccoon". I don't see either of the 'if' statement branch messages, with no money taken.
Reply With Quote
  #4  
Old 11-16-2018, 02:12 PM
irongut_av's Avatar
irongut_av
Fire Beetle
 
Join Date: Sep 2018
Posts: 20
Default

Looks like I figured out the problem:

zone/lua_client.h
Code:
bool TakeMoneyFromPP(uint64 copper);
bool TakeMoneyFromPP(uint64 copper, bool update_client);
When I changed the param from uint64 to uint32, as well as the lua binding call from uint64 to uint32 , it worked.

The wrapped client function still uses uint64, so I just a cast inside of it:

Code:
…
bool Lua_Client::TakeMoneyFromPP(uint32 copper)
{
	Lua_Safe_Call_Bool();
	return self->TakeMoneyFromPP(static_cast<uint64>(copper));
}

bool Lua_Client::TakeMoneyFromPP(uint32 copper, bool update_client)
{
	Lua_Safe_Call_Bool();
	return self->TakeMoneyFromPP(static_cast<uint64>(copper), update_client);
}
…

.def("TakeMoneyFromPP", (bool(Lua_Client::*)(uint32))&Lua_Client::TakeMoneyFromPP)
.def("TakeMoneyFromPP", (bool(Lua_Client::*)(uint32, bool))&Lua_Client::TakeMoneyFromPP)
...
Reply With Quote
  #5  
Old 11-16-2018, 05:42 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

I think your original problem was that you were trying to call a client function off of an entity/mob object.

You would either need to pull the client pointer from entity list or cast e to client - after an IsClient() check.

I could be wrong...
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #6  
Old 11-17-2018, 09:14 PM
irongut_av's Avatar
irongut_av
Fire Beetle
 
Join Date: Sep 2018
Posts: 20
Default

Quote:
Originally Posted by Uleat View Post
I think your original problem was that you were trying to call a client function off of an entity/mob object.

You would either need to pull the client pointer from entity list or cast e to client - after an IsClient() check.

I could be wrong...
I think if it was a pointer issue, changing the bound return type from a 64 bit to 32bit unsigned int wouldn't have fixed it. I think that Lua binding doesn't like uint64 functions for some reason, at least maybe on 32 bit builds (my server build is 32 bit).
Reply With Quote
  #7  
Old 11-18-2018, 12:12 AM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

Disregard..I always forget semicolons are optional in lua...
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
Reply


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 05:40 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3