SHOW:
|
|
- or go back to the newest paste.
1 | --[[ | |
2 | Script made by Blyitgen @ AC-Web.org | |
3 | These credits must stay in place! | |
4 | ]] | |
5 | ||
6 | -- Varibles | |
7 | local NPC = 78000 -- NPC entry for gossip | |
8 | ||
9 | - | local p1_X = 31000 -- X location for Player 1 |
9 | + | local x1,y1,z1 = 1.1, 1.2, 1.3 -- location for Player 1 |
10 | - | local p1_Y = 31000 -- Y location for Player 1 |
10 | + | local x2,y2,z2 = 1.1, 1.2, 1.3 -- location for Player 2 |
11 | - | local p1_Z = 31000 -- Z location for Player 1 |
11 | + | |
12 | local started = false -- Status of the arena (false = not started, true = started) | |
13 | - | local p2_X = 31000 -- X location for Player 2 |
13 | + | |
14 | - | local p2_Y = 31000 -- Y location for Player 2 |
14 | + | |
15 | - | local p2_Z = 31000 -- Z location for Player 2 |
15 | + | |
16 | ||
17 | - | local started = 0 -- Status of the arena (0 = not started, 1 = started) |
17 | + | |
18 | ||
19 | local function getRandom(array) | |
20 | local size = #array | |
21 | if(size == 0) then | |
22 | return 0 -- false, nil? | |
23 | elseif(size > 1) then | |
24 | - | function addPlayer(player,unit) |
24 | + | |
25 | - | local pid = player |
25 | + | elseif(size == 1) then |
26 | return array[1] | |
27 | - | local p1s = table.getn(p1) |
27 | + | |
28 | - | local p2s = table.getn(p2) |
28 | + | |
29 | ||
30 | local function sendPlayers() | |
31 | - | p2[p2s + 1] = pid |
31 | + | |
32 | - | else if(p2s > p1s) then |
32 | + | |
33 | - | p1[p1s + 1] = pid |
33 | + | |
34 | - | else if(p1s == p2s) then |
34 | + | local function addPlayer(player,unit) |
35 | - | local chance = math.random(1,2) |
35 | + | local p1s = #p1 |
36 | - | if(chance == 1) then |
36 | + | local p2s = #p2 |
37 | - | p1[p1s + 1] = pid |
37 | + | -- p1[p1s + 1] = player Lets use table insert instead. Less code and a cleaner table and it might just be better later on. |
38 | - | else |
38 | + | |
39 | - | p2[p2s + 1] = pid |
39 | + | table.insert(player, p2) |
40 | - | end |
40 | + | elseif(p1s < p2s or p1s = p2s) then |
41 | table.insert(player, p1) | |
42 | end | |
43 | player:SendBroadcastMessage("You are now added to the queue! Good luck!") | |
44 | end | |
45 | ||
46 | - | function getRandom(array) |
46 | + | local function Hello(Unit, Event, player) |
47 | - | local size = table.getn(array) |
47 | + | |
48 | ||
49 | Unit:GossipMenuAddItem(6, "Add me to the queue!", 1) | |
50 | - | return 0 |
50 | + | Unit:GossipMenuAddItem(7, "Nevermind", 2) |
51 | - | else if(size > 1) then |
51 | + | |
52 | - | local m = math.random(1,size) |
52 | + | |
53 | end | |
54 | - | else if(size == 1) then |
54 | + | |
55 | local function Select(Unit, Event, player, id, intid, code, pMisc) | |
56 | if(intid == 1) then | |
57 | addPlayer(player) | |
58 | end | |
59 | - | function sendPlayers() |
59 | + | player:GossipComplete() |
60 | end | |
61 | ||
62 | -- Registers | |
63 | RegisterTimedEvent("sendPlayers", 30000, 0) | |
64 | - | function onGossipTalk(Unit, Event, player) |
64 | + | RegisterUnitGossipEvent(NPC, 1, Hello) |
65 | RegisterUnitGossipEvent(NPC, 2, Select) |