Forums » Community Projects

/givemoney

Sep 17, 2007 csgno1 link
Does anyone have a bit of LUA code that shows how to test for receiving credits? I want to be able to do stuff based on how many credits were given. I didn't see any specific stuff in the docs for it. Is it like a private message? If there is no sample available I'll gladly take advice.

Thanks all.
Sep 17, 2007 drazed link
The "CHAT_MSG_SECTORD" event is triggered when you receive credits. Try this code.

function creditsrecv:OnEvent(eventname, data)
local msg = data.msg
local sendstart, sendend = string.find(msg, " sent you ", 1)
local creditstart, creditend = string.find(msg, " credits.", 1)
local playername = string.sub(msg, 1, splitstart-1)
local amount = string.sub(msg, splitend+1, creditstart-1)
-- playername and amount are what you're looking for ;)
end

RegisterEvent(creditsrecv, "CHAT_MSG_SECTORD")
Sep 17, 2007 csgno1 link
Thank you!
Sep 17, 2007 Scuba Steve 9.0 link
Here's a better version of that same code:

function creditsrecv:OnEvent(eventname, data)
local _, _, playername, amount = string.find(data.msg, "^(%a-) sent you (%d-) credits.")
-- playername and amount are what you're looking for ;)
end

RegisterEvent(creditsrecv, "CHAT_MSG_SECTORD")
Sep 18, 2007 csgno1 link
Thanks, looks like a regex
:)
Sep 18, 2007 csgno1 link
Is there a place that had an explanation of these? The first seems obvious, but I'm not clear on the differences of the rest.

CHAT_MSG_SECTOR
CHAT_MSG_SECTORD
CHAT_MSG_SECTORD_MISSION
CHAT_MSG_SECTORD_SECTOR
CHAT_MSG_SECTOR_EMOTE

Thanks
Sep 18, 2007 Scuba Steve 9.0 link
CHAT_MSG_SECTOR:
A message from a player in the sector.

CHAT_MSG_SECTORD:
A message from the sector daemon.

CHAT_MSG_SECTORD_MISSION:
A mission message from the sector daemon.

CHAT_MSG_SECTORD_SECTOR:
A sector message from the sector daemon(never seen this happen before).

CHAT_MSG_SECTOR_EMOTE:
A /me from a player in-sector.

Edit: It's not quite a regex, but lua has semi-similar pattern-matching facilities.
Sep 18, 2007 csgno1 link
Thank you
Sep 18, 2007 csgno1 link
"CHAT_MSG_SECTORD_SECTOR: A sector message from the sector daemon(never seen this happen before)."

Might the 'you are in a storm' message be from that?
Sep 18, 2007 slime73 link
CHAT_MSG_SECTORD_SECTOR has the temp KOS standing messages and the 'You've been caught in an Ion Storm.' messages (there might be more, but those are the ones I know).
Sep 18, 2007 Scuba Steve 9.0 link
Noted.