Advertisement
Shaddow32

Ludo [German]

Nov 4th, 2011
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 37.78 KB | None | 0 0
  1. -------------------------------------------------------
  2. -------------------------------------------------------
  3. --Ludo Script by Shaddow, for you!
  4. --
  5. --Needs LSA Link: http://pastebin.com/jYDX4yPr
  6. --
  7. --
  8. --Last Update: 13/11/2011 (DD/MM/YYYY)
  9. -------------------------------------------------------
  10. -------------------------------------------------------
  11.  
  12.  
  13. --[[ -- SQL --
  14. INSERT INTO `creature_names` VALUES ('521120', 'Ludo!', '', '', '0', '10', '0', '0', '0', '0', '347', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0');
  15. INSERT INTO `creature_names` VALUES ('521121', 'Red NPC', '', '', '0', '10', '0', '0', '0', '0', '5488', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0');
  16. INSERT INTO `creature_names` VALUES ('521122', 'Green NPC', '', '', '0', '10', '0', '0', '0', '0', '14527', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0');
  17. INSERT INTO `creature_names` VALUES ('521123', 'Yellow NPC', '', '', '0', '10', '0', '0', '0', '0', '18404', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0');
  18. INSERT INTO `creature_names` VALUES ('521124', 'Blue NPC!', '', '', '0', '10', '0', '0', '0', '0', '13444', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0');
  19. INSERT INTO `creature_proto` VALUES ('521120', '1', '1', '35', '100', '100', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  20. INSERT INTO `creature_proto` VALUES ('521121', '1', '1', '35', '100', '100', '0', '0.7', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  21. INSERT INTO `creature_proto` VALUES ('521122', '1', '1', '35', '100', '100', '0', '0.5', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  22. INSERT INTO `creature_proto` VALUES ('521123', '1', '1', '35', '100', '100', '0', '0.3', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  23. INSERT INTO `creature_proto` VALUES ('521124', '1', '1', '35', '100', '100', '0', '0.2', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  24. INSERT INTO `gameobject_names` VALUES ('505504', '5', '5411', 'Ludo gamefield', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  25. INSERT INTO `gameobject_names` VALUES ('505501', '5', '264', 'Red Aura', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  26. INSERT INTO `gameobject_names` VALUES ('505502', '5', '3612', 'Green Aura', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  27. INSERT INTO `gameobject_names` VALUES ('505503', '5', '1310', 'Yellow Aura', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  28. INSERT INTO `gameobject_names` VALUES ('505500', '5', '1309', 'Blue Aura', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  29. ]]
  30.  
  31. local NPCID_LUDO = 521120           --Main NPC EntryID
  32. local COLOR_BLUE_NPC = 521124       --Blue NPC EntryID
  33. local COLOR_GREEN_NPC = 521122      --Green NPC EntryID
  34. local COLOR_RED_NPC = 521121        --Red NPC EntryID
  35. local COLOR_YELLOW_NPC = 521123     --Yellow NPC EntryID
  36.  
  37. local GAMEFIELD_OBJ = 505504        --Gamefield Object EntryID
  38. local COLOR_BLUE_OBJ = 505500       --Blue Object EntryID
  39. local COLOR_GREEN_OBJ = 505502      --Green Object EntryID
  40. local COLOR_RED_OBJ = 505501        --Red Object EntryID
  41. local COLOR_YELLOW_OBJ = 505503     --Yellow Object EntryID
  42.  
  43.  
  44.  
  45. local wintab = {--here you can add items for the player who wins this match:
  46.               --{ITEMID, ITEMCOUNT},
  47.                 }
  48.  
  49.                
  50.                
  51. local REGISTERSOUND = 8462      --Player join sound ID
  52. local STARTSOUND = 8463         --Player start sound ID
  53. local PLAYERMAX = 2             --playercap, default: 4 (Max: 4 Min: 2)
  54.  
  55. local rdymsg = "#bereit"        --ready message
  56.  
  57.  
  58. --Menunames:
  59. local menu1 = "Anmelden"
  60. local menu2 = "Abmelden"
  61. local menu3 = "Beenden"
  62. local menu4 = "Bewegen"
  63. local menu5 = "W\195\188rfeln"
  64. local menu6 = "Ins Spielfeld bringen"
  65. local menu7 = "Zug weitergeben"
  66. local menu8 = "Aufgeben"
  67.  
  68. local color_blue = "Blau"
  69. local color_green = "Gr\195\188n"
  70. local color_red = "Rot"
  71. local color_yellow = "Gelb"
  72.  
  73. --Main NPC name:
  74. local mainnpcname = "Ludo"
  75.  
  76. --Gamemessages:
  77. local message1 = "Derzeit kannst du dich nicht anmelden!"
  78. local message2 = "Bitte #bereit schreiben, um das Spiel zu beginnen!"
  79. local message3 = "Warte auf Gegner..."
  80. local message4 = "Spiel beginnt!"
  81. local message5 = "NAME ist dran."
  82. local message6 = "NAME f\195\164ngt an. (Du bist COLOR)"
  83. local message7 = "Du hast bereits gew\195\188rfelt."
  84. local message8 = "NAME hat eine NUMBER gew\195\188rfelt."
  85. local message9 = "Du musst zuerst w\195\188rfeln."
  86. local message10 = "Du musst eine 6 w\195\188rfeln."
  87. local message11 = "Du kannst diese Figur nicht bewegen!"
  88. local message12 = "NAME darf noch NUMBER mal."
  89. local message13 = "NAME hat den NUMBER Platz belegt."
  90. local message14 = "NAME wurde aus dem Spiel entfernt!"
  91. local message15 = "NAME hat leider verloren."
  92. local message16 = "NAME darf nochmal w\195\188rfeln."
  93. local message17 = "Jemand hat sich abgemeldet, ihr wurdet erstrangig der Warteschleife hinzugef\195\188gt."
  94.  
  95.  
  96. local gamefield = {--{ENTRYID, X, Y, Z, O, SCALE}, ONLY NPC Coords+XYZ
  97.                     {GAMEFIELD_OBJ, 20, -4, 0, 0, 0.80, "field"},
  98.                     {GAMEFIELD_OBJ, 16, -4, 0, 0, 0.80, "field"},
  99.                     {GAMEFIELD_OBJ, 12, -4, 0, 0, 0.80, "field"},
  100.                     {GAMEFIELD_OBJ, 8, -4, 0, 0, 0.80, "field"},
  101.                     {GAMEFIELD_OBJ, 4, -4, 0, 0, 0.80, "field"},                   
  102.                     {GAMEFIELD_OBJ, 4, -8, 0, 0, 0.80, "field"},
  103.                     {GAMEFIELD_OBJ, 4, -12, 0, 0, 0.80, "field"},
  104.                     {GAMEFIELD_OBJ, 4, -16, 0, 0, 0.80, "field"},
  105.                     {GAMEFIELD_OBJ, 4, -20, 0, 0, 0.80, "field"},                  
  106.                     {GAMEFIELD_OBJ, 0, -20, 0, 0, 0.80, "field"},                  
  107.                     {GAMEFIELD_OBJ, -4, -20, 0, 0, 0.80, "field"},
  108.                     {GAMEFIELD_OBJ, -4, -16, 0, 0, 0.80, "field"},
  109.                     {GAMEFIELD_OBJ, -4, -12, 0, 0, 0.80, "field"},
  110.                     {GAMEFIELD_OBJ, -4, -8, 0, 0, 0.80, "field"},                  
  111.                     {GAMEFIELD_OBJ, -4, -4, 0, 0, 0.80, "field"},
  112.                     {GAMEFIELD_OBJ, -8, -4, 0, 0, 0.80, "field"},
  113.                     {GAMEFIELD_OBJ, -12, -4, 0, 0, 0.80, "field"},
  114.                     {GAMEFIELD_OBJ, -16, -4, 0, 0, 0.80, "field"},
  115.                     {GAMEFIELD_OBJ, -20, -4, 0, 0, 0.80, "field"},                 
  116.                     {GAMEFIELD_OBJ, -20, 0, 0, 0, 0.80, "field"},                      
  117.                     {GAMEFIELD_OBJ, -20, 4, 0, 0, 0.80, "field"},
  118.                     {GAMEFIELD_OBJ, -16, 4, 0, 0, 0.80, "field"},
  119.                     {GAMEFIELD_OBJ, -12, 4, 0, 0, 0.80, "field"},
  120.                     {GAMEFIELD_OBJ, -8, 4, 0, 0, 0.80, "field"},
  121.                     {GAMEFIELD_OBJ, -4, 4, 0, 0, 0.80, "field"},
  122.                     {GAMEFIELD_OBJ, -4, 8, 0, 0, 0.80, "field"},
  123.                     {GAMEFIELD_OBJ, -4, 12, 0, 0, 0.80, "field"},
  124.                     {GAMEFIELD_OBJ, -4, 16, 0, 0, 0.80, "field"},
  125.                     {GAMEFIELD_OBJ, -4, 20, 0, 0, 0.80, "field"},
  126.                     {GAMEFIELD_OBJ, 0, 20, 0, 0, 0.80, "field"},               
  127.                     {GAMEFIELD_OBJ, 4, 20, 0, 0, 0.80, "field"},
  128.                     {GAMEFIELD_OBJ, 4, 16, 0, 0, 0.80, "field"},
  129.                     {GAMEFIELD_OBJ, 4, 12, 0, 0, 0.80, "field"},
  130.                     {GAMEFIELD_OBJ, 4, 8, 0, 0, 0.80, "field"},                
  131.                     {GAMEFIELD_OBJ, 4, 4, 0, 0, 0.80, "field"},
  132.                     {GAMEFIELD_OBJ, 8, 4, 0, 0, 0.80, "field"},
  133.                     {GAMEFIELD_OBJ, 12, 4, 0, 0, 0.80, "field"},
  134.                     {GAMEFIELD_OBJ, 16, 4, 0, 0, 0.80, "field"},
  135.                     {GAMEFIELD_OBJ, 20, 4, 0, 0, 0.80, "field"},                   
  136.                     {GAMEFIELD_OBJ, 20, 0, 0, 0, 0.80, "field"},
  137.                     {GAMEFIELD_OBJ, 16, 0, 0, 0, 0.80, "winblue"},
  138.                     {GAMEFIELD_OBJ, 12, 0, 0, 0, 0.80, "winblue"},
  139.                     {GAMEFIELD_OBJ, 8, 0, 0, 0, 0.80, "winblue"},
  140.                     {GAMEFIELD_OBJ, 4, 0, 0, 0, 0.80, "winblue"},
  141.                     {GAMEFIELD_OBJ, -16, 0, 0, 0, 0.80, "wingreen"},
  142.                     {GAMEFIELD_OBJ, -12, 0, 0, 0, 0.80, "wingreen"},
  143.                     {GAMEFIELD_OBJ, -8, 0, 0, 0, 0.80, "wingreen"},
  144.                     {GAMEFIELD_OBJ, -4, 0, 0, 0, 0.80, "wingreen"},
  145.                     {GAMEFIELD_OBJ, 0, 16, 0, 0, 0.80, "winred"},
  146.                     {GAMEFIELD_OBJ, 0, 12, 0, 0, 0.80, "winred"},
  147.                     {GAMEFIELD_OBJ, 0, 8, 0, 0, 0.80, "winred"},
  148.                     {GAMEFIELD_OBJ, 0, 4, 0, 0, 0.80, "winred"},
  149.                     {GAMEFIELD_OBJ, 0, -16, 0, 0, 0.80, "winyellow"},
  150.                     {GAMEFIELD_OBJ, 0, -12, 0, 0, 0.80, "winyellow"},
  151.                     {GAMEFIELD_OBJ, 0, -8, 0, 0, 0.80, "winyellow"},
  152.                     {GAMEFIELD_OBJ, 0, -4, 0, 0, 0.80, "winyellow"},
  153.                     {COLOR_YELLOW_OBJ, -20, -20, 0, 0, 0.80, "spawnyellow"},
  154.                     {COLOR_YELLOW_OBJ, -20, -16, 0, 0, 0.80, "spawnyellow"},
  155.                     {COLOR_YELLOW_OBJ, -16, -20, 0, 0, 0.80, "spawnyellow"},
  156.                     {COLOR_YELLOW_OBJ, -16, -16, 0, 0, 0.80, "spawnyellow"},
  157.                     {COLOR_BLUE_OBJ, 20, -20, 0, 0, 0.80, "spawnblue"},
  158.                     {COLOR_BLUE_OBJ, 20, -16, 0, 0, 0.80, "spawnblue"},
  159.                     {COLOR_BLUE_OBJ, 16, -20, 0, 0, 0.80, "spawnblue"},
  160.                     {COLOR_BLUE_OBJ, 16, -16, 0, 0, 0.80, "spawnblue"},
  161.                     {COLOR_GREEN_OBJ, -20, 20, 0, 0, 0.80, "spawngreen"},
  162.                     {COLOR_GREEN_OBJ, -20, 16, 0, 0, 0.80, "spawngreen"},
  163.                     {COLOR_GREEN_OBJ, -16, 20, 0, 0, 0.80, "spawngreen"},
  164.                     {COLOR_GREEN_OBJ, -16, 16, 0, 0, 0.80, "spawngreen"},
  165.                     {COLOR_RED_OBJ, 20, 20, 0, 0, 0.80, "spawnred"},
  166.                     {COLOR_RED_OBJ, 20, 16, 0, 0, 0.80, "spawnred"},
  167.                     {COLOR_RED_OBJ, 16, 20, 0, 0, 0.80, "spawnred"},
  168.                     {COLOR_RED_OBJ, 16, 16, 0, 0, 0.80, "spawnred"},
  169.                     {COLOR_YELLOW_OBJ, -4, -20, 0, 0, 0.80, "startyellow"},
  170.                     {COLOR_RED_OBJ, 4, 20, 0, 0, 0.80, "startred"},
  171.                     {COLOR_GREEN_OBJ, -20, 4, 0, 0, 0.80, "startgreen"},
  172.                     {COLOR_BLUE_OBJ, 20, -4, 0, 0, 0.80, "startblue"},
  173.                     {GAMEFIELD_OBJ, -20, -20, 0, 0, 0.80},
  174.                     {GAMEFIELD_OBJ, -20, -16, 0, 0, 0.80},
  175.                     {GAMEFIELD_OBJ, -16, -20, 0, 0, 0.80},
  176.                     {GAMEFIELD_OBJ, -16, -16, 0, 0, 0.80},                   
  177.                     {GAMEFIELD_OBJ, 20, -20, 0, 0, 0.80},
  178.                     {GAMEFIELD_OBJ, 20, -16, 0, 0, 0.80},
  179.                     {GAMEFIELD_OBJ, 16, -20, 0, 0, 0.80},
  180.                     {GAMEFIELD_OBJ, 16, -16, 0, 0, 0.80},                    
  181.                     {GAMEFIELD_OBJ, -20, 20, 0, 0, 0.80},
  182.                     {GAMEFIELD_OBJ, -20, 16, 0, 0, 0.80},
  183.                     {GAMEFIELD_OBJ, -16, 20, 0, 0, 0.80},
  184.                     {GAMEFIELD_OBJ, -16, 16, 0, 0, 0.80},                    
  185.                     {GAMEFIELD_OBJ, 20, 20, 0, 0, 0.80},
  186.                     {GAMEFIELD_OBJ, 20, 16, 0, 0, 0.80},
  187.                     {GAMEFIELD_OBJ, 16, 20, 0, 0, 0.80},
  188.                     {GAMEFIELD_OBJ, 16, 16, 0, 0, 0.80},
  189.                     {COLOR_BLUE_OBJ, 4, 0, 0, 0, 1},
  190.                     {COLOR_BLUE_OBJ, 8, 0, 0, 0, 1},
  191.                     {COLOR_BLUE_OBJ, 12, 0, 0, 0, 1},
  192.                     {COLOR_BLUE_OBJ, 16, 0, 0, 0, 1},
  193.                     {COLOR_GREEN_OBJ, -4, 0, 0, 0, 1},
  194.                     {COLOR_GREEN_OBJ, -8, 0, 0, 0, 1},
  195.                     {COLOR_GREEN_OBJ, -12, 0, 0, 0, 1},
  196.                     {COLOR_GREEN_OBJ, -16, 0, 0, 0, 1},
  197.                     {COLOR_RED_OBJ, 0, 4, 0, 0, 1},
  198.                     {COLOR_RED_OBJ, 0, 8, 0, 0, 1},
  199.                     {COLOR_RED_OBJ, 0, 12, 0, 0, 1},
  200.                     {COLOR_RED_OBJ, 0, 16, 0, 0, 1},
  201.                     {COLOR_YELLOW_OBJ, 0, -4, 0, 0, 1},
  202.                     {COLOR_YELLOW_OBJ, 0, -8, 0, 0, 1},
  203.                     {COLOR_YELLOW_OBJ, 0, -12, 0, 0, 1},
  204.                     {COLOR_YELLOW_OBJ, 0, -16, 0, 0, 1},
  205.                   }
  206.  
  207. ------------------------------------------------------------------------
  208. -------------------------------Tables-----------------------------------
  209. local ludo = {}
  210.       ludo.register = {}
  211.       ludo.game = {}
  212. ------------------------------------------------------------------------
  213. ------------------------------------------------------------------------
  214.  
  215. math.randomseed(os.clock())
  216.  
  217. ------------------------------------------------------------------------
  218. -------------------------------MainNPC----------------------------------
  219. function LudoNPC_Gossip(unt, _, plr)
  220.     unt:GossipCreateMenu(1, plr, 0)
  221.     if(ludo.game.plrs~=nil)then
  222.         if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])then
  223.             unt:GossipMenuAddItem(3,menu7,4,0)
  224.             unt:GossipMenuAddItem(3,menu5.."\n",3,0)
  225.         end
  226.     end
  227.     if(LSA.tabsearch(ludo.register, plr:GetName()))then
  228.     unt:GossipMenuAddItem(3,menu2,2,0)
  229.     else
  230.     if(ludo.game.plrs==nil)then
  231.         unt:GossipMenuAddItem(3,menu1.." "..table.getn(ludo.register).."/"..PLAYERMAX,1,0)
  232.     end
  233.     end
  234.     if(ludo.game.plrs~=nil)then
  235.         for k,v in pairs(ludo.game.plrs)do
  236.             if(v[2]==plr:GetName())then
  237.                 unt:GossipMenuAddItem(3,menu8,5,0)
  238.             end
  239.         end
  240.     end
  241.     unt:GossipMenuAddItem(7,"["..menu3.."]", 99, 0)
  242.     unt:GossipSendMenu(plr)
  243. end
  244.  
  245. function LudoNPC_Select(unt, _, plr, _, id, code)
  246.     if(id==1)then
  247.         plr:GossipComplete()
  248.         if(table.getn(ludo.register)<PLAYERMAX)and(ludo.game.plrs==nil)then
  249.             plr:PlaySoundToPlayer(REGISTERSOUND)
  250.             table.insert(ludo.register, plr:GetName())
  251.             if(table.getn(ludo.register)>=PLAYERMAX)then
  252.                 ludo.game.rdy = true
  253.                 ludo.game.diced = false
  254.                 ludo.game.rdys = {}
  255.                 ludo.game.unt = unt
  256.                 ludo.game.x = unt:GetX()
  257.                 ludo.game.y = unt:GetY()
  258.                 ludo.game.z = unt:GetZ()
  259.                 ludo.game.gametyp = "rdy"
  260.                 for x=1,PLAYERMAX,1 do
  261.                     GetPlayer(ludo.register[x]):SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message2.."|R")
  262.                     GetPlayer(ludo.register[x]):PlaySoundToPlayer(STARTSOUND)
  263.                 end
  264.             end
  265.         else
  266.             plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message1.."|R")
  267.         end
  268.     end
  269.     if(id==2)then
  270.         plr:GossipComplete()
  271.         for k,v in pairs(ludo.register)do
  272.             if(v==plr:GetName())then
  273.                 ludo.register[k] = nil
  274.                 break;
  275.             end
  276.         end
  277.     end
  278.     if(id==3)then
  279.         plr:GossipComplete()
  280.         if(ludo.game.diced~=true)then
  281.                 local s = true
  282.                 ludo.game.diced = true
  283.                 ludo.game.numb = math.random(6)
  284.                 ludo.sendmessages(string.gsub(string.gsub(message8, "NAME", ludo.game.plrs[ludo.game.round][2]), "NUMBER", ludo.game.numb))
  285.            
  286.                 for k,v in pairs(ludo.game.figurespawns[ludo.game.plrs[ludo.game.round][3]])do
  287.                     if(v[5]==true)then
  288.                         s = false
  289.                         break
  290.                     end
  291.                 end
  292.                
  293.            
  294.                 if(s==true)then
  295.                     if(ludo.game.numb<6)then
  296.                         ludo.game.diced = false
  297.                         ludo.game.maxplays = ludo.game.maxplays-1
  298.                             ludo.sendmessages(string.gsub(string.gsub(message12, "NAME", ludo.game.plrs[ludo.game.round][2]), "NUMBER", ludo.game.maxplays))
  299.                             if(ludo.game.maxplays==0)and(ludo.game.numb~=6)then
  300.                                 ludo.change_player()
  301.                             end
  302.                     end
  303.                 end
  304.            
  305.         else
  306.             plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message7.."|R")
  307.         end
  308.     end
  309.     if(id==4)then
  310.         plr:GossipComplete()
  311.         ludo.change_player()
  312.     end
  313.     if(id==5)then
  314.         plr:GossipComplete()
  315.         for k,v in pairs(ludo.game.plrs)do
  316.             if(v[2]==plr:GetName())then
  317.                 ludo.removeplayer(ludo.game.plrs[k])
  318.             end
  319.         end
  320.     end
  321.     if(id==99)then
  322.         plr:GossipComplete()
  323.     end
  324. end
  325. RegisterUnitGossipEvent(NPCID_LUDO,1,"LudoNPC_Gossip")
  326. RegisterUnitGossipEvent(NPCID_LUDO,2,"LudoNPC_Select")
  327. ------------------------------------------------------------------------
  328. ------------------------------------------------------------------------
  329.  
  330.  
  331.  
  332. ------------------------------------------------------------------------
  333. -------------------------------Game Start------------------------------
  334. function LUDO_commands(_, plr, msg)
  335.     if(msg==rdymsg)then
  336.         if(ludo.game.rdy)then
  337.             if(ludo.game.rdys[plr:GetName()]~=true)then
  338.                 ludo.game.rdys[plr:GetName()] = true
  339.                 if(LSA.tabget(ludo.game.rdys)>=PLAYERMAX)then
  340.                     ludo.create_game()
  341.                 else
  342.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message3.."|R")
  343.                 end
  344.             end
  345.         end
  346.     end
  347. --[[if(msg:find("#command ")==1)then        --CHEATCODE
  348.         if(ludo.game.diced~=true)then
  349.                 local s = true
  350.                 ludo.game.diced = true
  351.                 local numbii = msg:gsub("#wurf ", "")
  352.                 ludo.game.numb = tonumber(numbii)
  353.                 ludo.sendmessages(string.gsub(string.gsub(message8, "NAME", ludo.game.plrs[ludo.game.round][2]), "NUMBER", ludo.game.numb))
  354.            
  355.                 for k,v in pairs(ludo.game.figurespawns[ludo.game.plrs[ludo.game.round][3]REMOVETHISTEXT])do
  356.                     if(v[5]==true)then
  357.                         s = false
  358.                         break
  359.                     end
  360.                 end
  361.                
  362.            
  363.                 if(s==true)then
  364.                     if(ludo.game.numb<6)then
  365.                         ludo.game.diced = false
  366.                         ludo.game.maxplays = ludo.game.maxplays-1
  367.                             ludo.sendmessages(string.gsub(string.gsub(message12, "NAME", ludo.game.plrs[ludo.game.round][2]), "NUMBER", ludo.game.maxplays))
  368.                             if(ludo.game.maxplays==0)and(ludo.game.numb~=6)then
  369.                                 ludo.change_player()
  370.                             end
  371.                     end
  372.                 end
  373.         end
  374.     end ]]
  375. end
  376. RegisterServerHook(16, "LUDO_commands")
  377. ------------------------------------------------------------------------
  378. ------------------------------------------------------------------------
  379.  
  380.  
  381. ------------------------------------------------------------------------
  382. -------------------------------Game Create------------------------------
  383. function ludo.create_game()
  384.     ludo.game.plrs = {}
  385.     for x=1,PLAYERMAX,1 do
  386.         ludo.game.plrs[x] = {}
  387.         ludo.game.plrs[x][1] = GetPlayer(ludo.register[x])
  388.         ludo.game.plrs[x][2] = ludo.register[x]
  389.         ludo.game.plrs[x][3] = ludo.randomgenerator(x)
  390.     end
  391.     ludo.sendmessages(message4)
  392.     ludo.game.gametyp = "rdy"
  393.     ludo.game.maxplays = 3
  394.     ludo.game.winnerplace = 1
  395.     ludo.game.spawns = {}
  396.     ludo.register = {}
  397.     ludo.game.round = math.random(table.getn(ludo.game.plrs))
  398.     ludo.game.field = {}
  399.     ludo.game.starts = {}
  400.     ludo.game.figurespawns = {["yellow"] = {}, ["red"] = {}, ["green"] = {}, ["blue"] = {} }
  401.     ludo.game.figurewins = {["yellow"] = {}, ["red"] = {}, ["green"] = {}, ["blue"] = {} }
  402.     for x=1,PLAYERMAX,1 do
  403.         ludo.game.plrs[x][1]:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..string.gsub(string.gsub(message6, "NAME", ludo.game.plrs[ludo.game.round][2]), "COLOR", ludo.get_color(ludo.game.plrs[x][3])).."|R")
  404.     end
  405.     ludo.game.figures = {}
  406.     for k,v in pairs(gamefield)do
  407.         table.insert(ludo.game.spawns, ludo.game.unt:SpawnGameObject(v[1], ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], v[5], 0, v[6]*100, 1))
  408.             if(v[7]=="field")then
  409.                 local tab = {false, ludo.game.x+v[2],ludo.game.y+v[3],ludo.game.z+v[4], false}
  410.                 table.insert(ludo.game.field, tab)
  411.             end
  412.                 if(v[7]=="startyellow")then
  413.                     ludo.game.starts["yellow"] = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4]}
  414.                     local tab = {false, ludo.game.x+v[2],ludo.game.y+v[3],ludo.game.z+v[4], true}
  415.                     table.insert(ludo.game.field, tab)
  416.                 elseif(v[7]=="startred")then
  417.                     ludo.game.starts["red"] = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4]}
  418.                     local tab = {false, ludo.game.x+v[2],ludo.game.y+v[3],ludo.game.z+v[4], true}
  419.                     table.insert(ludo.game.field, tab)
  420.                 elseif(v[7]=="startgreen")then
  421.                     ludo.game.starts["green"] = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4]}
  422.                     local tab = {false, ludo.game.x+v[2],ludo.game.y+v[3],ludo.game.z+v[4], true}
  423.                     table.insert(ludo.game.field, tab)
  424.                 elseif(v[7]=="startblue")then
  425.                     ludo.game.starts["blue"] = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4]}
  426.                     local tab = {false, ludo.game.x+v[2],ludo.game.y+v[3],ludo.game.z+v[4], true}
  427.                     table.insert(ludo.game.field, tab)
  428.                 end            
  429.                 if(v[7]=="spawnyellow")then
  430.                     local unit = ludo.game.unt:SpawnCreature(COLOR_YELLOW_NPC, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], 0, 35, 0,0,0,0,1)
  431.                     ludo.game.figurespawns["yellow"][tostring(unit)] = {unit, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  432.                     table.insert(ludo.game.spawns, unit)
  433.                 elseif(v[7]=="spawnred")then
  434.                     local unit = ludo.game.unt:SpawnCreature(COLOR_RED_NPC, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], 0, 35, 0,0,0,0,1)
  435.                     ludo.game.figurespawns["red"][tostring(unit)] = {unit, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  436.                     table.insert(ludo.game.spawns, unit)
  437.                 elseif(v[7]=="spawngreen")then
  438.                     local unit = ludo.game.unt:SpawnCreature(COLOR_GREEN_NPC, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], 0, 35, 0,0,0,0,1)
  439.                     ludo.game.figurespawns["green"][tostring(unit)] = {unit, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  440.                     table.insert(ludo.game.spawns, unit)
  441.                 elseif(v[7]=="spawnblue")then
  442.                     local unit = ludo.game.unt:SpawnCreature(COLOR_BLUE_NPC, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], 0, 35, 0,0,0,0,1)
  443.                     ludo.game.figurespawns["blue"][tostring(unit)] = {unit, ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  444.                     table.insert(ludo.game.spawns, unit)
  445.                 end
  446.                 if(v[7]=="winblue")then
  447.                     local tab = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  448.                     table.insert(ludo.game.figurewins["blue"], tab)
  449.                 elseif(v[7]=="winred")then
  450.                     local tab = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  451.                     table.insert(ludo.game.figurewins["red"], tab)
  452.                 elseif(v[7]=="wingreen")then
  453.                     local tab = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  454.                     table.insert(ludo.game.figurewins["green"], tab)
  455.                 elseif(v[7]=="winyellow")then
  456.                     local tab = {ludo.game.x+v[2], ludo.game.y+v[3], ludo.game.z+v[4], false}
  457.                     table.insert(ludo.game.figurewins["yellow"], tab)
  458.                 end
  459.     end
  460. end
  461. ------------------------------------------------------------------------
  462. ------------------------------------------------------------------------
  463.  
  464.  
  465.  
  466. ------------------------------------------------------------------------
  467. --------------------------------functions-------------------------------
  468. function ludo.sendmessages(msg)
  469.     if(ludo.game.plrs[1]~=nil)then
  470.         ludo.game.plrs[1][1]:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..msg.."|R")
  471.     end
  472.     if(ludo.game.plrs[2]~=nil)then
  473.         ludo.game.plrs[2][1]:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..msg.."|R")
  474.     end
  475.     if(ludo.game.plrs[3]~=nil)then
  476.         ludo.game.plrs[3][1]:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..msg.."|R")
  477.     end
  478.     if(ludo.game.plrs[4]~=nil)then
  479.         ludo.game.plrs[4][1]:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..msg.."|R")
  480.     end
  481. end
  482.  
  483. local rndgenerate = false
  484. function ludo.randomgenerator(x)
  485.         if(x==1)then
  486.             local tab = {
  487.                          {"green","red","blue","yellow"},
  488.                          {"red","blue","yellow","green"},
  489.                          {"blue","yellow","green","red"},
  490.                          {"yellow","green","red","blue"}
  491.                         }
  492.             rndgenerate = tab[math.random(table.getn(tab))]
  493.         end
  494.     return rndgenerate[x];
  495. end
  496.  
  497. function ludo.change_player()
  498.         if(ludo.game.round<table.getn(ludo.game.plrs))then
  499.             ludo.game.round = ludo.game.round+1
  500.         else
  501.             ludo.game.round = 1
  502.         end
  503.         if(ludo.game.plrs[ludo.game.round]~=nil)then
  504.             ludo.sendmessages(string.gsub(message5, "NAME", ludo.game.plrs[ludo.game.round][2]))
  505.         end
  506.         ludo.game.diced = false
  507.         ludo.game.maxplays = 3
  508. end
  509.  
  510. function ludo.get_color(color)
  511.     if(color=="green")then return color_green; end
  512.     if(color=="red")then return color_red; end
  513.     if(color=="blue")then return color_blue; end
  514.     if(color=="yellow")then return color_yellow; end
  515. end
  516.  
  517. function ludo.throw(tab)
  518. ludo.game.figurespawns[tab[2]][tab[1]][1]:TeleportCreature(ludo.game.figurespawns[tab[2]][tab[1]][2], ludo.game.figurespawns[tab[2]][tab[1]][3], ludo.game.figurespawns[tab[2]][tab[1]][4])
  519. ludo.game.figurespawns[tab[2]][tab[1]][5] = false
  520. end
  521.  
  522. function ludo.wincontroll(typ)
  523. local win = true
  524.     for k,v in pairs(ludo.game.figurewins[typ])do
  525.         if(v[4]==false)then
  526.             win = false
  527.             break
  528.         end
  529.     end
  530.     if(win==true)then
  531.         ludo.playerwin(ludo.game.plrs[ludo.game.round])
  532.         return true;
  533.     end
  534. end
  535.  
  536. function ludo.playerwin(plrtab)
  537. if(ludo.game.winnerplace==1)then
  538.     for k,v in pairs(wintab)do
  539.     plrtab[1]:AddItem(v[1], v[2])  
  540.     end
  541. end
  542. ludo.sendmessages(string.gsub(string.gsub(message13, "NAME", plrtab[2]), "NUMBER", ludo.game.winnerplace))
  543. ludo.game.winnerplace = ludo.game.winnerplace+1
  544. ludo.removeplayer(plrtab, "win")
  545. end
  546.  
  547. function ludo.removeplayer(plrtab, wl)
  548.     if(table.getn(ludo.game.plrs)>2)then
  549.     ludo.sendmessages(string.gsub(message14, "NAME", plrtab[2]))
  550.         for k,v in pairs(ludo.game.plrs)do
  551.             if(v[2]==plrtab[2])then
  552.                 table.remove(ludo.game.plrs, k)
  553.                 ludo.change_player()
  554.             end
  555.         end
  556.     else
  557.         if(wl~="win")then
  558.             ludo.sendmessages(string.gsub(message15, "NAME", plrtab[2]))
  559.         end
  560.         RegisterTimedEvent("ludo_removegame",2000,1)
  561.         --ludo.removegame()
  562.     end
  563. end
  564.  
  565. function ludo_removegame()
  566.     for k,v in pairs(ludo.game.spawns)do
  567.             if(v:IsInWorld())then
  568.                 v:RemoveFromWorld()
  569.             end
  570.         ludo.register = {}
  571.         ludo.game = {}
  572.         rndgenerate = false
  573.     end
  574. end
  575.  
  576. function Logout_Ludo(_, plr)
  577.     if(ludo.game.plr~=nil)then
  578.         for k,v in pairs(ludo.game.plr)do
  579.             if(v[2]==plr:GetName())then
  580.                 if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])then
  581.                     ludo.change_player()
  582.                 end
  583.                 ludo.removeplayer(ludo.game.plrs[k])
  584.             end
  585.         end
  586.     end
  587.     for k,v in pairs(ludo.register)do
  588.         if(v==plr:GetName())then
  589.             ludo.register[k] = nil
  590.                 if(ludo.game.gametyp=="rdy")then
  591.                     ludo.game = {}
  592.                     for k,v in pairs(ludo.register)do
  593.                         GetPlayer(v):SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message17.."|R")
  594.                     end
  595.                 end
  596.         end
  597.     end
  598. end
  599. RegisterServerHook(13, "Logout_Ludo")
  600.  
  601.  
  602. function ludo.getnewpos(currentpos, newpos)
  603.     if(currentpos+newpos>40)then
  604.         return currentpos-40+newpos
  605.     else
  606.         return currentpos+newpos
  607.     end
  608. end
  609.  
  610.  
  611. function ludo.movesystem(color, unit, plr)
  612.     if(ludo.game.diced==true)then
  613.         local current = ludo.game.figurespawns[color][unit].pos
  614.             if(ludo.game.figurespawns[color][unit].moves<=40)then
  615.                 ludo.game.field[ludo.game.figurespawns[color][unit].pos][1] = false
  616.             else
  617.                 ludo.game.figurewins[color][ludo.game.figurespawns[color][unit].moves-40][4] = false
  618.             end
  619.    
  620.         if(ludo.game.figurespawns[color][unit].moves+ludo.game.numb<=40)then
  621.             local posii = ludo.getnewpos(ludo.game.figurespawns[color][unit].pos, ludo.game.numb)
  622.             local x = 0            
  623.                     if(ludo.game.field[posii][1]~=false)then
  624.                         if(ludo.game.field[posii][1][2]~=color)then
  625.                             if(ludo.game.field[posii][5]~=true)then
  626.                                 ludo.throw(ludo.game.field[posii][1])
  627.                             end
  628.                             ludo.game.field[posii][1] = {unit, color}
  629.                         else
  630.                             x = 1
  631.                             while(ludo.game.field[posii+x][1]~=false)do
  632.                                 if(ludo.game.field[posii+x][1][2]~=color)then
  633.                                     if(ludo.game.field[posii][5]~=true)then
  634.                                         ludo.throw(ludo.game.field[posii][1])
  635.                                     end
  636.                                     ludo.game.field[posii][1] = {unit, color}
  637.                                     break
  638.                                 end
  639.                                 if(posii+x>=40)then
  640.                                     x = x-40
  641.                                 else
  642.                                     x = x+1                    
  643.                                 end
  644.                             end
  645.                            
  646.                            
  647.                         end
  648.                     else
  649.                         ludo.game.field[posii][1] = {unit, color}
  650.                     end
  651.            
  652.             ludo.game.figurespawns[color][unit].pos = posii+x
  653.             ludo.game.figurespawns[color][unit].moves = ludo.game.figurespawns[color][unit].moves+ludo.game.numb+x
  654.  
  655.         ludo.moveto(ludo.game.figurespawns[color][unit][1], ludo.game.numb+x, current, ludo.game.figurespawns[color][unit].moves-ludo.game.numb, 0, color)
  656.         if(ludo.game.numb<6)then
  657.             ludo.change_player()
  658.         else
  659.             ludo.game.diced = false
  660.             ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  661.         end    
  662.         else
  663.             if(ludo.game.figurespawns[color][unit].moves+ludo.game.numb<=44)then
  664.                 local posi = ludo.game.figurespawns[color][unit].moves-40+ludo.game.numb
  665.                 if(posi<=table.getn(ludo.game.figurewins[color]))then
  666.                     if(ludo.game.figurewins[color][posi][4]==false)then
  667.                         ludo.game.figurespawns[color][unit].moves = posi+40
  668.                         ludo.game.figurespawns[color][unit][5] = "finish"
  669.                         ludo.game.figurewins[color][posi][4] = true
  670.                         ludo.moveto(ludo.game.figurespawns[color][unit][1], ludo.game.numb, current, ludo.game.figurespawns[color][unit].moves-ludo.game.numb, 1, color)
  671.                         if(ludo.wincontroll(ludo.game.plrs[ludo.game.round][3])==true)then
  672.                             return;
  673.                         end
  674.                         if(ludo.game.numb<6)then
  675.                             ludo.change_player()
  676.                         else
  677.                             ludo.game.diced = false
  678.                             ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  679.                         end
  680.                     else
  681.                         plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message11.."|R")
  682.                     end                        
  683.                 else
  684.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message11.."|R")
  685.                 end
  686.             else
  687.                 plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message11.."|R")
  688.             end    
  689.         end
  690.     else
  691.         plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message9.."|R")
  692.     end
  693. end
  694.  
  695. function ludo.moveto(unt, newpos, currentpos, moves, typ, color)
  696.         if(typ==0)then
  697.             if(newpos>1)then
  698.                 local movetab = {}
  699.                 for x=1,newpos,1 do
  700.                     if(currentpos+x<=40)then
  701.                         if(x<newpos)then
  702.                             movetab[x] = {ludo.game.field[currentpos+x][2],ludo.game.field[currentpos+x][3],ludo.game.field[currentpos+x][4],0,1}
  703.                         else
  704.                             movetab[x] = {ludo.game.field[currentpos+x][2],ludo.game.field[currentpos+x][3],ludo.game.field[currentpos+x][4],0,false}
  705.                         end
  706.                     else
  707.                         if(x<newpos)then
  708.                             movetab[x] = {ludo.game.field[currentpos+x-40][2],ludo.game.field[currentpos+x-40][3],ludo.game.field[currentpos+x-40][4],0,1}
  709.                         else
  710.                             movetab[x] = {ludo.game.field[currentpos+x-40][2],ludo.game.field[currentpos+x-40][3],ludo.game.field[currentpos+x-40][4],0,false}
  711.                         end        
  712.                     end
  713.                 end
  714.                 MP.StartPath(unt, movetab)
  715.             else
  716.                 if(currentpos+1<=40)then
  717.                     unt:MoveTo(ludo.game.field[currentpos+1][2],ludo.game.field[currentpos+1][3],ludo.game.field[currentpos+1][4])
  718.                 else
  719.                     unt:MoveTo(ludo.game.field[1][2],ludo.game.field[1][3],ludo.game.field[1][4])
  720.                 end
  721.             end
  722.         end
  723.        
  724.         if(typ==1)then
  725.             if(newpos>1)then
  726.                 local movetab = {}
  727.                 for x=1,newpos,1 do
  728.                     if(moves+x<=40)then
  729.                         if(x<newpos)then
  730.                             movetab[x] = {ludo.game.field[currentpos+x][2],ludo.game.field[currentpos+x][3],ludo.game.field[currentpos+x][4],0,1}
  731.                         else
  732.                             movetab[x] = {ludo.game.field[currentpos+x][2],ludo.game.field[currentpos+x][3],ludo.game.field[currentpos+x][4],0,false}
  733.                         end
  734.                     else
  735.                         if(x<newpos)then
  736.                             movetab[x] = {ludo.game.figurewins[color][moves+x-40][1],ludo.game.figurewins[color][moves+x-40][2],ludo.game.figurewins[color][moves+x-40][3],0,1}
  737.                         else
  738.                             movetab[x] = {ludo.game.figurewins[color][moves+x-40][1],ludo.game.figurewins[color][moves+x-40][2],ludo.game.figurewins[color][moves+x-40][3],0,false}
  739.                         end        
  740.                     end
  741.                 end
  742.                 MP.StartPath(unt, movetab)
  743.             else
  744.                 unt:MoveTo(ludo.game.figurewins[color][moves+1-40][1],ludo.game.figurewins[color][moves+1-40][2],ludo.game.figurewins[color][moves+1-40][3])
  745.             end
  746.         end
  747. end
  748. ------------------------------------------------------------------------
  749. ------------------------------------------------------------------------
  750.  
  751.  
  752.  
  753. ------------------------------------------------------------------------
  754. -------------------------------Gamefigures------------------------------
  755. function LudoBLUE_NPC_Gossip(unt, _, plr)
  756.     if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])and(ludo.game.plrs[ludo.game.round][3]=="blue")then
  757.     unt:GossipCreateMenu(1, plr, 0)
  758.         if(ludo.game.figurespawns["blue"][tostring(unt)][5]==true)or(ludo.game.figurespawns["blue"][tostring(unt)][5]=="finish")then
  759.             unt:GossipMenuAddItem(7,menu4, 1, 0)
  760.         elseif(ludo.game.figurespawns["blue"][tostring(unt)][5]==false)then
  761.             unt:GossipMenuAddItem(7,menu6, 2, 0)
  762.         end
  763.     unt:GossipMenuAddItem(7,"["..menu3.."]", 99, 0)
  764.     unt:GossipSendMenu(plr)
  765.     end
  766. end
  767.  
  768. function LudoBLUE_NPC_Select(unt, _, plr, _, id, code)
  769.     if(id==1)then
  770.         plr:GossipComplete()
  771.         ludo.movesystem("blue", tostring(unt), plr)
  772.     end
  773.  
  774.     if(id==2)then
  775.         plr:GossipComplete()
  776.             if(ludo.game.diced==true)then
  777.                 if(ludo.game.numb==6)then
  778.                     ludo.game.figurespawns["blue"][tostring(unt)][5]=true
  779.                     unt:TeleportCreature(ludo.game.starts["blue"][1], ludo.game.starts["blue"][2], ludo.game.starts["blue"][3])
  780.                     ludo.game.figurespawns["blue"][tostring(unt)].pos = 1
  781.                     ludo.game.figurespawns["blue"][tostring(unt)].moves = 1
  782.                     ludo.game.diced = false
  783.                     ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  784.                 else
  785.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message10.."|R")
  786.                 end
  787.             else
  788.                 plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message9.."|R")
  789.             end
  790.     end
  791.    
  792.     if(id==99)then
  793.         plr:GossipComplete()
  794.     end
  795. end
  796.  
  797. RegisterUnitGossipEvent(COLOR_BLUE_NPC,1,"LudoBLUE_NPC_Gossip")
  798. RegisterUnitGossipEvent(COLOR_BLUE_NPC,2,"LudoBLUE_NPC_Select")
  799.  
  800.  
  801.  
  802. function LudoRED_NPC_Gossip(unt, _, plr)
  803.     if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])and(ludo.game.plrs[ludo.game.round][3]=="red")then
  804.     unt:GossipCreateMenu(1, plr, 0)
  805.         if(ludo.game.figurespawns["red"][tostring(unt)][5]==true)or(ludo.game.figurespawns["red"][tostring(unt)][5]=="finish")then
  806.             unt:GossipMenuAddItem(7,menu4, 1, 0)
  807.         elseif(ludo.game.figurespawns["red"][tostring(unt)][5]==false)then
  808.             unt:GossipMenuAddItem(7,menu6, 2, 0)
  809.         end
  810.     unt:GossipMenuAddItem(7,"["..menu3.."]", 99, 0)
  811.     unt:GossipSendMenu(plr)
  812.     end
  813. end
  814.  
  815. function LudoRED_NPC_Select(unt, _, plr, _, id, code)
  816.     if(id==1)then
  817.         plr:GossipComplete()
  818.         ludo.movesystem("red", tostring(unt), plr)
  819.     end
  820.  
  821.     if(id==2)then
  822.         plr:GossipComplete()
  823.             if(ludo.game.diced==true)then
  824.                 if(ludo.game.numb==6)then
  825.                     ludo.game.figurespawns["red"][tostring(unt)][5]=true
  826.                     unt:TeleportCreature(ludo.game.starts["red"][1], ludo.game.starts["red"][2], ludo.game.starts["red"][3])
  827.                     ludo.game.figurespawns["red"][tostring(unt)].pos = 31
  828.                     ludo.game.figurespawns["red"][tostring(unt)].moves = 1
  829.                     ludo.game.diced = false
  830.                     ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  831.                 else
  832.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message10.."|R")
  833.                 end
  834.             else
  835.                 plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message9.."|R")
  836.             end
  837.     end
  838.    
  839.     if(id==99)then
  840.         plr:GossipComplete()
  841.     end
  842. end
  843.  
  844. RegisterUnitGossipEvent(COLOR_RED_NPC,1,"LudoRED_NPC_Gossip")
  845. RegisterUnitGossipEvent(COLOR_RED_NPC,2,"LudoRED_NPC_Select")
  846.  
  847.  
  848.  
  849.  
  850. function LudoGREEN_NPC_Gossip(unt, _, plr)
  851.     if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])and(ludo.game.plrs[ludo.game.round][3]=="green")then
  852.     unt:GossipCreateMenu(1, plr, 0)
  853.         if(ludo.game.figurespawns["green"][tostring(unt)][5]==true)or(ludo.game.figurespawns["green"][tostring(unt)][5]=="finish")then
  854.             unt:GossipMenuAddItem(7,menu4, 1, 0)
  855.         elseif(ludo.game.figurespawns["green"][tostring(unt)][5]==false)then
  856.             unt:GossipMenuAddItem(7,menu6, 2, 0)
  857.         end
  858.     unt:GossipMenuAddItem(7,"["..menu3.."]", 99, 0)
  859.     unt:GossipSendMenu(plr)
  860.     end
  861. end
  862.  
  863. function LudoGREEN_NPC_Select(unt, _, plr, _, id, code)
  864.     if(id==1)then
  865.         plr:GossipComplete()
  866.         ludo.movesystem("green", tostring(unt), plr)
  867.     end
  868.  
  869.     if(id==2)then
  870.         plr:GossipComplete()
  871.             if(ludo.game.diced==true)then
  872.                 if(ludo.game.numb==6)then
  873.                     ludo.game.figurespawns["green"][tostring(unt)][5]=true
  874.                     unt:TeleportCreature(ludo.game.starts["green"][1], ludo.game.starts["green"][2], ludo.game.starts["green"][3])
  875.                     ludo.game.figurespawns["green"][tostring(unt)].pos = 21
  876.                     ludo.game.figurespawns["green"][tostring(unt)].moves = 1
  877.                     ludo.game.diced = false
  878.                     ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  879.                 else
  880.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message10.."|R")
  881.                 end
  882.             else
  883.                 plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message9.."|R")
  884.             end
  885.     end
  886.    
  887.     if(id==99)then
  888.         plr:GossipComplete()
  889.     end
  890. end
  891.  
  892. RegisterUnitGossipEvent(COLOR_GREEN_NPC,1,"LudoGREEN_NPC_Gossip")
  893. RegisterUnitGossipEvent(COLOR_GREEN_NPC,2,"LudoGREEN_NPC_Select")
  894.  
  895.  
  896.  
  897.  
  898. function LudoYELLOW_NPC_Gossip(unt, _, plr)
  899.     if(plr:GetName()==ludo.game.plrs[ludo.game.round][2])and(ludo.game.plrs[ludo.game.round][3]=="yellow")then
  900.     unt:GossipCreateMenu(1, plr, 0)
  901.         if(ludo.game.figurespawns["yellow"][tostring(unt)][5]==true)or(ludo.game.figurespawns["yellow"][tostring(unt)][5]=="finish")then
  902.             unt:GossipMenuAddItem(7,menu4, 1, 0)
  903.         elseif(ludo.game.figurespawns["yellow"][tostring(unt)][5]==false)then
  904.             unt:GossipMenuAddItem(7,menu6, 2, 0)
  905.         end
  906.     unt:GossipMenuAddItem(7,"["..menu3.."]", 99, 0)
  907.     unt:GossipSendMenu(plr)
  908.     end
  909. end
  910.  
  911. function LudoYELLOW_NPC_Select(unt, _, plr, _, id, code)
  912.     if(id==1)then
  913.         plr:GossipComplete()
  914.         ludo.movesystem("yellow", tostring(unt), plr)
  915.     end
  916.  
  917.     if(id==2)then
  918.         plr:GossipComplete()
  919.             if(ludo.game.diced==true)then
  920.                 if(ludo.game.numb==6)then
  921.                     ludo.game.figurespawns["yellow"][tostring(unt)][5]=true
  922.                     unt:TeleportCreature(ludo.game.starts["yellow"][1], ludo.game.starts["yellow"][2], ludo.game.starts["yellow"][3])
  923.                     ludo.game.figurespawns["yellow"][tostring(unt)].pos = 11
  924.                     ludo.game.figurespawns["yellow"][tostring(unt)].moves = 1
  925.                     ludo.game.diced = false
  926.                     ludo.sendmessages(string.gsub(message16, "NAME", ludo.game.plrs[ludo.game.round][2]))
  927.                 else
  928.                     plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message10.."|R")
  929.                 end
  930.             else
  931.                 plr:SendBroadcastMessage("|CFFFF0000["..mainnpcname.."]: |R|CFFFFFFFF"..message9.."|R")
  932.             end
  933.     end
  934.    
  935.     if(id==99)then
  936.         plr:GossipComplete()
  937.     end
  938. end
  939.  
  940. RegisterUnitGossipEvent(COLOR_YELLOW_NPC,1,"LudoYELLOW_NPC_Gossip")
  941. RegisterUnitGossipEvent(COLOR_YELLOW_NPC,2,"LudoYELLOW_NPC_Select")
  942. ------------------------------------------------------------------------
  943. ------------------------------------------------------------------------
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950. print("Ludo successfully loaded")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement