-
Member
pvp reward need help
Hello
i use this script
Code:
-- Variables
local gold = math.random(200,250)
local goldonkill = true -- use true or false for on or off
local lvlforkill = true -- use true to give gold by player killed level or false to go by fixed rate
local rate = 1
local xp = math.random(30,40)
local xponkill = true -- use true or false for on or off
function OnKill(event, pPlayer, pKilled)
if(pKilled:IsPlayer()) then
if(goldonkill == true) then
if(lvlforkill == true) then
killedlevel = pKilled:GetPlayerLevel()
pPlayer:DealGoldMerit(gold*killedlevel)
elseif(lvlforkill == false) then
pPlayer:DealGoldMerit(gold*rate)
end
end
if(xponkill == true) then
pPlayer:GiveXp(xp)
pPlayer:SendAreaTriggerMessage("add xp = "..xp.." ")
end
end
end
if (GetLuaEngine() ~= "LuaHypArc") then
print("[LuaHypArc]: [Stats] not loaded.")
else
-- Keep one commented out the other or when a player gets and honorable kill, both will execute.
--RegisterServerHook(23, "OnKill") -- Hook for honorable kills
RegisterServerHook(2, "OnKill") -- Hook for killing a player
print("[LuaHypArc]: [Stats] loaded.")
end
but it's for single player . how i can add pAssist on this ?
i want after kill player give xp all group member nearest killed .
and how i can change battleground reward with lua ?
-
Member
-
WorldObject:GetPlayersInRange - Eluna
Player:IsInSameGroupWith - Eluna
Player:GiveXP - Eluna
Something like:
Code:
for _,plr in pairs(pPlayer:GetPlayersInRange(40)) do
if pPlayer:IsInSameGroupWith(plr) then
plr:GiveXP(xp)
end
end
-
Post Thanks / Like - 1 Thanks
shahin (1 members gave Thanks to stoneharry for this useful post)
-
Member
thank you for answer . it's best list of object's
i use you'r code but give some error
it's : attempt to call method 'GetPlayersInRange' (a nil value)
second question :
Is there a list of valid function?
Last edited by shahin; 02-14-2020 at 08:03 AM.
-
Originally Posted by
shahin
thank you for answer . it's best list of object's
i use you'r code but give some error
it's : attempt to call method 'GetPlayersInRange' (a nil value)
second question :
Is there a list of valid function?
Please share the code you are using. Also what emulator and Lua engine are you using?
I use this function in this script: ZombiesProject/1_Entrance.lua at master . stoneharry/ZombiesProject . GitHub
Eluna - 3.3.5a TrinityCore
Code:
local function SiegeGossip1(event, player, pUnit)
player:GossipMenuAddItem(9, "We are ready.", 0, 1)
player:GossipMenuAddItem(0, "Nevermind.", 0, 0)
player:GossipSendMenu(90000, pUnit)
end
local function SiegeGossip2(event, player, pUnit, sender, initid, code)
if initid == 1 then
local t = pUnit:GetPlayersInRange(40)
if #t >= 5 or _debug then
pUnit:SetNPCFlags(0)
pUnit:RegisterEvent(StartEvent, 1000, 1)
else
player:SendBroadcastMessage("There are not enough players nearby to start the event. There needs to be five people minimum.")
end
end
player:GossipComplete()
end
RegisterCreatureGossipEvent(90071, 1, SiegeGossip1)
RegisterCreatureGossipEvent(90071, 2, SiegeGossip2)
Only starts the event if there are 5 players within 40 yards or debug mode is enabled.
It may be that this method is not available on a player object, but that seems unlikely.
Last edited by stoneharry; 02-14-2020 at 02:25 PM.
-
Post Thanks / Like - 1 Thanks
shahin (1 members gave Thanks to stoneharry for this useful post)
-
Member
i use you'r code on my script
Code:
-- Variables
local gold = math.random(200,250)
local goldonkill = true -- use true or false for on or off
local lvlforkill = true -- use true to give gold by player killed level or false to go by fixed rate
local rate = 1
local xp = math.random(30,40)
local xponkill = true -- use true or false for on or off
function OnKill(event, pPlayer, pKilled)
if(pKilled:IsPlayer()) then
if(goldonkill == true) then
if(lvlforkill == true) then
killedlevel = pKilled:GetPlayerLevel()
pPlayer:DealGoldMerit(gold*killedlevel)
elseif(lvlforkill == false) then
pPlayer:DealGoldMerit(gold*rate)
end
end
if(xponkill == true) then
pPlayer:GiveXp(xp)
pPlayer:SendAreaTriggerMessage("add xp = "..xp.." ")
for _,plr in pairs(pPlayer:GetPlayersInRange(100,2,1)) do
if pPlayer:IsInSameGroupWith(plr) then
plr:GiveXp(xp)
plr:SendAreaTriggerMessage("add xp = "..xp.." ")
end
end
end
end
end
if (GetLuaEngine() ~= "LuaHypArc") then
print("[LuaHypArc]: [Stats] not loaded.")
else
-- Keep one commented out the other or when a player gets and honorable kill, both will execute.
--RegisterServerHook(23, "OnKill") -- Hook for honorable kills
RegisterServerHook(2, "OnKill") -- Hook for killing a player
print("[LuaHypArc]: [Stats] loaded.")
end
Last edited by shahin; 02-14-2020 at 02:45 PM.
-
Member
I've been looking for these for a long time. thank you!
Please share the code you are using. Also what emulator and Lua engine are you using?
I use this function in this script: ZombiesProject/1_Entrance.lua at master . stoneharry/ZombiesProject . GitHub
Eluna - 3.3.5a TrinityCore
i use arcemu . Because I think it's much easier than Trinity
-
Originally Posted by
shahin
I've been looking for these for a long time. thank you!
i use arcemu . Because I think it's much easier than Trinity
ArcEmu has a different API. Example: Misc-WoW-Stuff/CoT-TheHunt.lua at master . stoneharry/Misc-WoW-Stuff . GitHub
Code:
local found = false
for _,v in pairs(pUnit:GetInRangePlayers()) do
if v:IsAlive() and v:GetDistanceYards(pUnit) < 50 then
found = true
if v:GetZ() < 36.8 then
v:Teleport(429, 815, 478, 37.4)
v:CastSpell(64446)
end
end
end
I do not recommend using ArcEmu. It's not been actively developed in many years and is light years behind other emulators now. It was very unstable and buggy, as sad as that is to say. I had to abandon a project I worked on for years because I used ArcEmu. It would be too much work to migrate it to another emulator.
TrinityCore has Eluna Lua support which allows for the scripting of content in a very similar way to ArcEmu's Lua. AzerothCore allows you to use C++ modules, another possible way to script.
-
Post Thanks / Like - 1 Thanks
shahin (1 members gave Thanks to stoneharry for this useful post)
-
Member
Can I have a Trinity Core download link without a problem? The Trinity Core I downloaded has problems
-
Member
like your help i change GetPlayersInRange to GetInRangePlayers and fix it !
but i cant find equivalent IsInSameGroupWith
-
It has this: Edge-of-Chaos/UnitFunctions.h at master . stoneharry/Edge-of-Chaos . GitHub
Code:
static int GetGroupPlayers(lua_State* L, Unit* ptr)
{
TEST_PLAYER()
Player* _player = TO_PLAYER(ptr);
Group* party = _player->GetGroup();
uint32 count = 0;
lua_newtable(L);
if(party)
{
GroupMembersSet::iterator itr;
SubGroup* sgrp;
party->getLock().Acquire();
for(uint32 i = 0; i < party->GetSubGroupCount(); i++)
{
sgrp = party->GetSubGroup(i);
for(itr = sgrp->GetGroupMembersBegin(); itr != sgrp->GetGroupMembersEnd(); ++itr)
{
if((*itr)->m_loggedInPlayer && (*itr)->m_loggedInPlayer->GetZoneId() == _player->GetZoneId() && _player->GetInstanceID() == (*itr)->m_loggedInPlayer->GetInstanceID())
{
count++,
lua_pushinteger(L, count);
PUSH_UNIT(L, (*itr)->m_loggedInPlayer);
lua_rawset(L, -3);
}
}
}
party->getLock().Release();
}
return 1;
}
So:
Code:
local group = player:GetGroupPlayers()
for _,partyPlr in pairs(group) do
partyPlr:GiveXp(100)
end
On TrinityCore: TrinityCore Collaboration Platform
TrinityCore Collaboration Platform
Eluna can be got here: ElunaLuaEngine . GitHub
GitHub - ElunaLuaEngine/ElunaTrinityWotlk: Eluna Lua Engine merged with Trinity 3.3.5
-
Post Thanks / Like - 1 Thanks
shahin (1 members gave Thanks to stoneharry for this useful post)
-
Member
It was really great ! Thank you for your help
Is it possible to build a Honor vendor with eluna ?
-
Originally Posted by
shahin
It was really great ! Thank you for your help
Is it possible to build a Honor vendor with eluna ?
I don't see why not: Eluna API
-
Member
Thanks for taking the time for me.
i cant find it .
Can you write an example ?
item buy and decrease 1000 honor