SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Test = {}
  2.  
  3. --[[CONFIGS]]----[[CONFIGS]]----[[CONFIGS]]----[[CONFIGS]]----[[CONFIGS]]----[[CONFIGS]]----[[CONFIGS]]--
  4.  
  5. --ONLY ONE OF THE FOLLOWING MAY BE TRUE
  6. IsRewardItem =      false   -- Change this to true if the reward is an item.
  7. IsRewardGold =      false   -- Change this to true if the reward is gold.
  8. IsRewardXP =        false   -- Change this to true if the reward is XP.
  9.  
  10. --ONLY change the following two IF IsRewardItem = true, if its not true make sure they are nil.
  11. RewardItemId =      nil     -- Change nil with the item id you want to be added to the winners backpack.
  12. RewardItemAmount =  nil     -- Change nil to the the amount of items of the specified id will be added to the winners backpack.
  13. RewardItemName =    nil     -- Change nil with the Item name of the item id you put in as RewardItemId
  14.  
  15. --ONLY change the following IF IsRewardGold = true, if its not true make sure this is nil.
  16. RewardGoldAmount =  nil     -- Change nil with the amount of gold you would like to add to the winner, ex 5 = 5g.
  17.  
  18.  
  19. --ONLY change the following IF IsRewardXP = true, if its not true make sure this is nil.
  20. RewardXPAmount =    nil     -- Change nil to the amount of experiance you want to be added to the winner of the math equasion.
  21.  
  22. --[[END OF CONFIGS]]----[[END OF CONFIGS]]----[[END OF CONFIGS]]----[[END OF CONFIGS]]----[[END OF CONFIGS]]--
  23.  
  24. Awsnerable = false
  25. Start = false
  26.  
  27. function Test.OnChat(event, player, message, type, language)
  28. local LCM = message:lower()
  29.     if (LCM == ".test math") then
  30.         if(player:IsGm() == true) then
  31.             if (Start == false) then
  32.                 Start = true
  33.                 RegisterTimedEvent("Test.mathhook", 10000, 0, player)
  34.             elseif (Start == true) and
  35.             (player:IsGm() == true) then
  36.                 player:SendAreaTriggerMessage("|cFF03E6FFThe math quiz is already in session, please type .test stop to stop it")
  37.             end
  38.         end
  39.     return 0
  40.     elseif (LCM == ""..tonumber(Awsner).."") then
  41.         if (Awsnerable == true) then
  42.             --if (player:IsGm() == false) then
  43.                 if (IsRewardItem == true) then
  44.                     Awsnerable = false
  45.                     player:AddItem(RewardItemId, RewardItemAmount)
  46.                     for k, v in pairs(GetPlayersInWorld()) do
  47.                         v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]:|r "..player:GetName().." Has Won this math question and has been awarded "..RewardItemAmount.." X of "..RewItemName.."!")
  48.                     end
  49.                 elseif (IsRewardGold == true) then
  50.                     player:DealGoldMerit(RewardGoldAmount*10000)
  51.                     Awsnerable = false
  52.                     for k, v in pairs(GetPlayersInWorld()) do
  53.                         v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]:|r "..player:GetName().." Has Won this math question and has been awarded "..RewardGoldAmount.." Gold!")
  54.                     end
  55.                 elseif (IsRewardXP == true) then
  56.                     player:GiveXp(RewardXPAmount)
  57.                     Awsnerable = false
  58.                     for k, v in pairs(GetPlayersInWorld()) do
  59.                         v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]:|r "..player:GetName().." Has Won this math question and has been awarded "..RewardXPAmount.." Experiance!")
  60.                     end
  61.                 end
  62.             --end
  63.         end
  64.     elseif (LCM == ".test stop") and
  65.         (player:IsGm() == true) and
  66.         (Start == true) then
  67.         Start = false
  68.         Awsnerable = false
  69.         for k, v in pairs(GetPlayersInWorld()) do
  70.             v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]:|r The math quiz has ended! Better luck next time!")
  71.         end
  72.     return 0
  73.     end
  74. end
  75.  
  76. RegisterServerHook(16, "Test.OnChat")
  77.  
  78. function Test.mathhook(player, event)
  79.     if (Start == true) and
  80.     (Awsnerable == false) then
  81.         WhatType = math.random(3)
  82.         if (WhatType == 1) then
  83.             Number1 = math.random(400)
  84.             Number2 = math.random(1000)
  85.             Awsner = Number2 - Number1
  86.             Awsnerable = true
  87.             for k, v in pairs(GetPlayersInWorld()) do
  88.                 v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]|r: What is "..Number2..", Minus "..Number1.."??")
  89.             end
  90.         elseif (WhatType == 2) then
  91.             Number1 = math.random(400)
  92.             Number2 = math.random(1000)
  93.             Awsner = Number2 + Number1
  94.             Awsnerable = true
  95.             for k, v in pairs(GetPlayersInWorld()) do
  96.                 v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]|r: What is "..Number2..", Plus "..Number1.."??")
  97.             end
  98.         elseif (WhatType == 3) then
  99.             Number1 = math.random(50)
  100.             Number2 = math.random(10)
  101.             Awsner = Number1 * Number2
  102.             Awsnerable = true
  103.             for k, v in pairs(GetPlayersInWorld()) do
  104.                 v:SendBroadcastMessage("|cFFF2FF03[|r|cFF03E6FFMath Script|cFFF2FF03]|r: What is "..Number2..", Times "..Number1.."??")
  105.             end
  106.         end
  107.     end
  108. end
  109.  
  110. if (IsRewardItem == true) and
  111.     (RewardItemId == nil) then
  112.     logcol(4+8)
  113.     print("The math test script has not loaded correctly, Please Check the Item configs!!")
  114.     logcol(7)
  115. elseif (IsRewardItem == true) and
  116.     (RewardItemAmount == nil) then
  117.     logcol(4+8)
  118.     print("The math test script has not loaded correctly, Please Check the Item configs!!")
  119.     logcol(7)
  120. elseif (IsRewardItem == true) and
  121.     (RewardItemName == nil) then
  122.     logcol(4+8)
  123.     print("The math test script has not loaded correctly, Please Check the Item configs!!")
  124.     logcol(7)
  125. elseif (IsRewardGold == true) and
  126.     (RewardGoldAmount == nil) then
  127.     logcol(4+8)
  128.     print("The math test script has not loaded correctly, Please Check the Gold configs!!")
  129.     logcol(7)
  130. elseif (IsRewardXP == true) and
  131.     (RewardXPAmount == nil) then
  132.     logcol(4+8)
  133.     print("The math test script has not loaded correctly, Please Check the Experiance configs!!")
  134.     logcol(7)
  135. else
  136. logcol(4+8)
  137. print("The math test script has sucessfully loaded!, made by brathus!")
  138. logcol(7)
  139. end
RAW Paste Data
Top