Teste.lua

main 167 lines · 5.6 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local M = 0
2local S = 0
3function onUse(player, item, fromPosition, target, toPosition, isHotkey)
4 local id = {
5 [1] = { 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
6 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,
7 1020, 1021, 1022, 1023, 1024, 1025, 1026 },
8
9 [2] = { 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
10 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
11 2020, 2021, 2022, 2023, 2024 },
12
13 [3] = { 10500, 10501, 10502, 10503, 10504, 10505, 10506, 10507, 10508,
14 10509, 10510, 10511, 10512, 10513, 10514, 10515, 10516, 10517,
15 10518, 10519, 10520, 10521, 10522, 10523, 10524, 10525, 10526 },
16 --[[[3] = { 11001, 11002, 11003, 11004, 11005, 11006, 11007, 11008, 11009,
17 11010, 11011, 11012, 11013, 11014, 11015, 11016, 11017, 11018,
18 11019, 11020, 11021, 11022, 11023, 11024, 11025, 11026, 11027 },]]
19
20 [4] = { 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009,
21 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019,
22 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029,
23 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039,
24 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049 },
25
26 [5] = { 5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009,
27 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019,
28 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029,
29 5030, 5031, 5032, 5033, 5034, 5035, 5036, 5037, 5038, 5039,
30 5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048 },
31
32 [6] = { 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009,
33 6010, 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019,
34 6020, 6021, 6022, 6023 },
35
36 [7] = { 7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 7008, 7009, 7010 },
37
38 [8] = { 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009,
39 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8018, 8019,
40 8020, 8021, 8022, 8023, 8024 },
41
42 [9] = { 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9008, 9009,
43 9010, 9011, 9012, 9013, 9014, 9015, 9016, 9017, 9018, 9019,
44 9020 },
45 }
46
47 local type = 0
48 local slot = math.random(1, 1)
49 local itemid = 1002 --id[slot][math.random(01, #id[slot])]
50 local rare = 02 --math.random(00, 04)
51 local star = 01 --math.random(00, 02)
52 local qnt = 01 --math.random(01, 05)
53 local ext = 0
54
55 if type == 0 then
56 if _ITEMS[itemid] then
57 if doBackpack(player, 00, slot, ext, 01) then
58 if slot == 3 then
59 doBackpack(player, 03, slot, ext, 01, itemid) -- Procurar
60 if doBackpack(player, 01, slot, ext, 0, itemid, rare, star, qnt) then
61 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce recebeu o item [ " .._ITEMS[itemid].NAME.. ", x" ..qnt.." ].")
62 player:getPosition():sendMagicEffect(14)
63 end
64 else
65 if doBackpack(player, 01, slot, ext, 0, itemid, rare, star) then
66 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce recebeu o item [ " .._ITEMS[itemid].NAME.. " ].")
67 player:getPosition():sendMagicEffect(14)
68 end
69 end
70 else
71 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua Backpack esta cheia.")
72 player:getPosition():sendMagicEffect(03)
73 end
74 else
75 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Tente novamente.")
76 player:getPosition():sendMagicEffect(03)
77 end
78 elseif type == 1 then
79 local sumid = math.random(1000, 1156)
80 local star = _SUMMON[sumid].STAR
81 if doSummon(player, 02, star, sumid) == 0 then
82 doSummon(player, 00, star)
83 doSummon(player, 01, star, sumid)
84 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce recebeu o summon \n[ " .._SUMMON[sumid].NAME.. " ]\nEstrelas [ " ..star.. " ].")
85 player:getPosition():sendMagicEffect(14)
86 doSummon(player, 00, 00)
87 else
88 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Você já possui o summon [ " .._SUMMON[sumid].NAME.. " ].\nTente novamente")
89 player:getPosition():sendMagicEffect(03)
90 end
91 elseif type == 2 then
92 M = 00
93 S = 15
94 local party = player:getParty()
95 if not party then
96 player:sendCancelMessage("@DGTime 01")
97 else
98 local members = party:getMembers()
99 members[#members + 1] = party:getLeader()
100 for _, member in ipairs(members) do
101 member:sendCancelMessage("@DGTime 01")
102 end
103 end
104
105 addEvent(onCountTimer, 1000, player.uid)
106 else
107 player:sendCancelMessage("@TaskMSG")
108 end
109end
110
111function onCountTimer(cid)
112 local player = Player(cid)
113 if player then
114 if M == 0 and S == 0 then
115 local party = player:getParty()
116 if not party then
117 player:sendCancelMessage("@DGTime 00")
118 else
119 local members = party:getMembers()
120 members[#members + 1] = party:getLeader()
121 for _, member in ipairs(members) do
122 member:sendCancelMessage("@DGTime 00")
123 end
124 end
125 else
126 local M1 = 0 local S1 = 0
127 local M2 = 0 local S2 = 0
128
129 if M > 0 and S > 0 then
130 S = S - 1
131 elseif M > 0 and S == 0 then
132 S = 59
133 M = M - 1
134 elseif M == 0 and S > 0 then
135 S = S - 1
136 end
137
138 if string.len(M) == 2 then
139 M1 = string.sub(M, 1, 1)
140 M2 = string.sub(M, 2, 2)
141 else
142 M1 = 0
143 M2 = string.sub(M, 1, 1)
144 end
145 if string.len(S) == 2 then
146 S1 = string.sub(S, 1, 1)
147 S2 = string.sub(S, 2, 2)
148 else
149 S1 = 0
150 S2 = string.sub(S, 1, 1)
151 end
152
153 local party = player:getParty()
154 if not party then
155 player:sendCancelMessage("@CountTempo " ..M1.. " " ..M2.." " ..S1.. " " ..S2)
156 else
157 local members = party:getMembers()
158 members[#members + 1] = party:getLeader()
159 for _, member in ipairs(members) do
160 member:sendCancelMessage("@CountTempo " ..M1.. " " ..M2.." " ..S1.. " " ..S2)
161 end
162 end
163
164 addEvent(onCountTimer, 1000, player.uid)
165 end
166 end
167end
Top