[DiscordArchive] I see file called core in the ac folder that the crash file?
[DiscordArchive] I see file called core in the ac folder that the crash file?
Archived author: Sanderis • Posted: 2025-03-21T09:09:30.306000+00:00
Original source
I see file called core in the ac folder that the crash file?
espawnOrUnsummon(0)Archived author: Sanderis • Posted: 2025-03-21T09:33:43.686000+00:00
Original source
local VENDOR_ENTRY = 9000002
local COMMAND_NAME = "vendor"
local COOLDOWN_TIME = 300
local function Debug(message)
print("[VendorScript] " .. message)
end
local function HandleCooldown(player)
local currentTime = os.time()
local lastUse = player:GetData("VendorSummonLastUse")
if lastUse then
local timeLeft = COOLDOWN_TIME - (currentTime - lastUse)
if timeLeft > 0 then
local minutes = math.floor(timeLeft / 60)
local seconds = timeLeft % 60
player:SendBroadcastMessage(string.format("Vendor is on cooldown. Please wait %d minutes and %d seconds.", minutes, seconds))
return false
end
end
player:SetData("VendorSummonLastUse", currentTime)
return true
end
local function OnSpawn(event, creature)
if creature:GetEntry() == VENDOR_ENTRY then
Debug("Vendor NPC spawned")
creature:SetLevel(83)
creature:SetNPCFlags(4225)
end
end
local function RegisterVendorCommand(event, player, command)
if command == COMMAND_NAME then
Debug("Command executed by player: " .. player:GetName())
if not HandleCooldown(player) then
Debug("Player is on cooldown")
return false
end
if player:InBattleground() then
player:SendBroadcastMessage("You cannot summon a Vendor while in a battleground!")
Debug("Player is in battleground")
return false
end
local x = player:GetX()
local y = player:GetY()
local z = player:GetZ()
local o = player:GetO()
Debug("Player position: " .. x .. ", " .. y .. ", " .. z)
local vendor = PerformIngameSpawn(1, VENDOR_ENTRY, player:GetMapId(), player:GetInstanceId(), x, y, z+0.5, o, false, 180000)
if vendor then
Debug("NPC spawned successfully with ID: " .. vendor:GetEntry())
player:SetData("VendorSummonedGUID", vendor:GetGUID())
vendor:SendUnitSay("at your service! You can sell items and repair your gear.", 0)
player:SendBroadcastMessage("Vendor summoned! They will despawn in 3 minutes.")
else
Debug("Failed to spawn NPC")
player:SendBroadcastMessage("Failed to summon Vendor. Please try again or contact a GM.")
player:SetData("VendorSummonLastUse", nil)
end
return false
end
end
local function OnPlayerLogout(event, player)
local vendorGUID = player:GetData("VendorSummonedGUID")
if vendorGUID then
Debug("Player " .. player:GetName() .. " logged out, cleaning up summoned NPC")
local map = player:GetMap()
if map then
local npc = map:GetCreature(vendorGUID)
if npc then
Debug("Despawning NPC with GUID: " .. vendorGUID)
npc
espawnOrUnsummon(0)
end
end
player:SetData("VendorSummonedGUID", nil)
end
end
RegisterPlayerEvent(42, RegisterVendorCommand)
RegisterPlayerEvent(4, OnPlayerLogout)
RegisterCreatureEvent(VENDOR_ENTRY, 5, OnSpawn)
Archived author: Sanderis • Posted: 2025-03-21T09:33:53.744000+00:00
Original source
**How does this look?**
Archived author: metallinos • Posted: 2025-03-21T15:29:44.067000+00:00
Original source
There's some chatGPT-like code and hallucinations in here, you should try to verify the functions against the API on https://www.azerothcore.org/eluna/index.html
[Embed: Eluna API]
API documentation for the Eluna engine.
https://www.azerothcore.org/eluna/index.html
Archived author: Sanderis • Posted: 2025-03-21T15:31:23.192000+00:00
Original source
Only used it to guide me since I'm new lol
Archived author: metallinos • Posted: 2025-03-21T15:31:30.935000+00:00
Original source
It looks a lot better than before though, much leaner and nice use of setdata. You don't have to set the data to nil on logout as it's destructed on logout anyway
Archived author: Sanderis • Posted: 2025-03-21T15:31:54.001000+00:00
Original source
Thank you
Archived author: metallinos • Posted: 2025-03-21T15:32:01.115000+00:00
Original source
Let me give it a quick spin to see if it's possible to store GUIDs in setdata. Pretty sure it's fine. Just gotta swap out GetCreature with GetWorldObject
Archived author: Sanderis • Posted: 2025-03-21T15:33:19.155000+00:00
Original source
It's currently working for me at the moment.