Forums » Community Projects
/givemoney
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.
Thanks all.
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")
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")
Thank you!
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")
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")
Thanks, looks like a regex
:)
:)
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
CHAT_MSG_SECTOR
CHAT_MSG_SECTORD
CHAT_MSG_SECTORD_MISSION
CHAT_MSG_SECTORD_SECTOR
CHAT_MSG_SECTOR_EMOTE
Thanks
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.
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.
Thank you
"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?
Might the 'you are in a storm' message be from that?
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).
Noted.