-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGiveGossip.lua
More file actions
72 lines (63 loc) · 2.38 KB
/
Copy pathGiveGossip.lua
File metadata and controls
72 lines (63 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
local MenuId = 123 -- Unique ID to recognice player gossip menu among others
local TokenID = 3000003
local function OnGossipHello(event, player, object, unit)
player:GossipClearMenu() -- required for player gossip
uRank = player:GetGMRank();
uID = player:GetAccountId();
Query = AuthDBQuery("SELECT eventquota FROM account WHERE id = " .. uID);
if(Query) then
cota = Query:GetUInt32(0);
if(cota <= 0) then
player:SendNotification("Vous n'avez pas de jetons à donner.");
return false;
end
else
player:SendNotification("Vous n'êtes pas autorisé à donner des récompenses aux events.");
return false;
end
for _, v in pairs(GetPlayersInWorld()) do
pName = v:GetName();
local pGuid = v:GetGUIDLow();
local pRank = v:GetGMRank();
if(pRank == 0) then
pName = "|cFF808000" .. pName .. "|r";
prefix = " (Joueur)";
else
pName = "|cFF000080" .. pName .. "|r";
prefix = " (Mj)";
end
player:GossipMenuAddItem(0, "Pseudo : " .. pName .. prefix, 1, pGuid, true, nil)
end
player:GossipSetText("A quel joueur souhaitez vous donner des jetons event ?\n\nVous avez " .. cota .." jetons encore à disposition.\n\nRappel: 'Code' désigne le nombre de jetons à donner. " )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
end
local function OnGossipSelect(event, player, object, sender, intid, code, menuid)
uID = player:GetAccountId();
local code = tonumber(code);
if(code > cota) then
player:SendNotification("Vous n'avez pas assez de jetons à donner.");
player:GossipComplete();
return false;
end
Query2 = AuthDBExecute("UPDATE account SET eventquota = eventquota - " .. code .." WHERE id = " .. uID);
player:SendBroadcastMessage("Vous avez donné " .. code .. " jetons event à " .. pName .. " !");
player:GossipComplete();
for _, v in pairs(GetPlayersInWorld()) do
pName = v:GetName();
local pGuid = v:GetGUIDLow();
if(pGuid == intid) then
v:AddItem(TokenID, code);
end
end
end
local function OnPlayerCommand(event, player, command)
if (command == "event reward") then
OnGossipHello(event, player, player)
return false
end
end
RegisterPlayerEvent(42, OnPlayerCommand)
RegisterPlayerGossipEvent(MenuId, 2, OnGossipSelect)
-- ListFile
local console = debug.getinfo (1, "S").short_src;
print("- "..console);