Lua Script menu

Shout-Out

User Tag List

Thread: Lua Script

Results 1 to 15 of 15
  1. #1
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lua Script

    Im just learning the basics of lua and wanted to start making scripts. But already at the first "non copy" script I made I got a error :P
    I can't realy figure out whats wrong with this one...

    Code:
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(99901, player, 0)
    unit:GossipMenuAddItem(4, "Bet 1 Coin", 1, 0)
    unit:GossipSendMenu(player)
    end
    
    function Got_Item(unit, event)
    unit:GetItemCount(32569) if Count == 0 then
    unit:SendChatMessage(14,0,"You don't have a coin to bet. Come back when you have one.")
    Unit:RemoveEvents()
    end
    
    function Win_Chance(unit, event, player, id, intid, code)
    unit:GetItemCount(32569) if Count > 1 then
    if(intid == 1) then
    Choice=math.random(1, 2)
    if Choice==1 then
    Misc:AddItem(32569, 1)
     end
    if Choice==2 then
    Misc:RemoveItem(32569, 1)
    Unit:RemoveEvents()
    end
    end
    RegisterUnitGossipEvent(191881, 1, "On_Gossip")
    RegisterUnitEvent(191881, 2, "Win_Chance")
    RegisterUnitEvent(191881, 3, "Got_Item")
    The Error part is displayed in red :P
    This is my first lua script so be gentle :P

    It is suposed to work so that you can give the npc 1 coin and then you can win back 2 coins or you lose your coin.
    Last edited by Sandile; 03-13-2009 at 10:21 AM.
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

    Lua Script
  2. #2
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(99901, player, 0)
    unit:GossipMenuAddItem(4, "Bet 1 Coin", 1, 0)
    unit:GossipSendMenu(player)
    end
    
    function Got_Item(unit, event)
    if unit:GetItemCount(32569) < 1 then
    unit:SendChatMessage(14,0,"You don't have a coin to bet. Come back when you have one.")
    Unit:RemoveEvents()
    end
    
    function Win_Chance(unit, event, player, id, intid, code)
    if unit:GetItemCount(32569) > 1 then
    if(intid == 1) then
    Choice=math.random(1, 2)
    if Choice==1 then
    Misc:AddItem(32569, 1)
     end
    if Choice==2 then
    Misc:RemoveItem(32569, 1)
    Unit:RemoveEvents()
    end
    end
    RegisterUnitGossipEvent(191881, 1, "On_Gossip")
    RegisterUnitEvent(191881, 2, "Win_Chance")
    RegisterUnitEvent(191881, 3, "Got_Item")

    Should be fixed!
    Last edited by Mircast; 03-13-2009 at 11:40 AM.

  3. #3
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I tried that before and it didn't work. But Ill try if again then. Ty for the reply.
    Nope, it didn't fix the error. To make it a lot easier for you to register the error I'm going to post it bellow :P

    Code:
    script/WOTLK/Custom/_____.lua:27: 'end' expected <to close 'if' at line 14> near '<eof>'
    Last edited by Sandile; 03-13-2009 at 12:04 PM.
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

  4. #4
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sandile View Post
    I think I tried that before and it didn't work. But Ill try if again then. Ty for the reply.
    What is the problem, post a screen shot or put it in code format.

  5. #5
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sandile View Post
    I think I tried that before and it didn't work. But Ill try if again then. Ty for the reply.
    Nope, it didn't fix the error. To make it a lot easier for you to register the error I'm going to post it bellow :P

    Code:
    script/WOTLK/Custom/_____.lua:27: 'end' expected <to close 'if' at line 14> near '<eof>'
    There ya go
    And +Rep for your time
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

  6. #6
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(99901, player, 0)
    unit:GossipMenuAddItem(4, "Bet 1 Coin", 1, 0)
    unit:GossipSendMenu(player)
    end
    
    function Got_Item(unit, event)
    if unit:GetItemCount(32569) < 1 then
    unit:SendChatMessage(14,0,"You don't have a coin to bet. Come back when you have one.")
    Unit:RemoveEvents()
    end
    
    function Win_Chance(unit, event, player, id, intid, code)
    if(intid == 1) then
    if unit:GetItemCount(32569) > 1 then
    Choice=math.random(1, 2)
    if Choice==1 then
    Misc:AddItem(32569, 1)
    end
    end
    if Choice==2 then
    Misc:RemoveItem(32569, 1)
    Unit:RemoveEvents()
    end
    end
    RegisterUnitGossipEvent(191881, 1, "On_Gossip")
    RegisterUnitEvent(191881, 2, "Win_Chance")
    RegisterUnitEvent(191881, 3, "Got_Item")
    If this doesn't work, may I rewrite the script? ^^

  7. #7
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here you go, sorry if there are errors.. I checked through it a couple of times.
    If there is, I can fix them, I'm just tired. I hope 32569 is your coin ID, if not you can change it.


    Code:
    function On_GossipMenu(unit, event, player)
    if (player:IsInCombat() == true) then
    player:SendAreaTriggerMessage("Sorry, you have to leave combat first!")
    else  
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    end
    
    function On_GossipSelect(unit, event, player, id, intid, code)
    
    if (intid == 7) then
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    
    if (intid == 1) then
    if (misc:GetItemCount(32569) < 1) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 50% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 5, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 5) then
    Choice=math.random(1, 2)
    if Choice==1 then
    player:AddItem(32569, 1)
    end
    if Choice==2 then
    player:RemoveItem(32569, 1)
    end
    end
    
    if (intid == 2) then
    if (misc:GetItemCount(32569) < 2) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 25% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 6, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 6) then
    Choice=math.random(1, 4)
    if Choice==1 then
    player:AddItem(32569, 2)
    end
    if Choice==2 then
    player:RemoveItem(32569, 2)
    end
    if Chocie==3 then
    player:RemoveItem(32569, 2)
    end
    if Choice==4 then
    player:RemoveItem(32569, 2)
    end
    end
    
    RegisterUnitGossipEvent(191881, 1, "On_GossipMenu")
    RegisterUnitGossipEvent(191881, 2, "On_GossipSelect")

  8. #8
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here you go, sorry if there are errors.. I checked through it a couple of times.
    If there is, I can fix them, I'm just tired. I hope 32569 is your coin ID, if not you can change it. I added a 2 coin system, but its riskier and there's a 75% chance of losing. =)


    Code:
    function On_GossipMenu(unit, event, player)
    if (player:IsInCombat() == true) then
    player:SendAreaTriggerMessage("Sorry, you have to leave combat first!")
    else  
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    end
    
    function On_GossipSelect(unit, event, player, id, intid, code)
    
    if (intid == 7) then
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    
    if (intid == 1) then
    if (misc:GetItemCount(32569) < 1) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 50% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 5, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 5) then
    Choice=math.random(1, 2)
    if Choice==1 then
    player:AddItem(32569, 1)
    end
    if Choice==2 then
    player:RemoveItem(32569, 1)
    end
    end
    
    if (intid == 2) then
    if (misc:GetItemCount(32569) < 2) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 25% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 6, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 6) then
    Choice=math.random(1, 4)
    if Choice==1 then
    player:AddItem(32569, 2)
    end
    if Choice==2 then
    player:RemoveItem(32569, 2)
    end
    if Chocie==3 then
    player:RemoveItem(32569, 2)
    end
    if Choice==4 then
    player:RemoveItem(32569, 2)
    end
    end
    
    RegisterUnitGossipEvent(191881, 1, "On_GossipMenu")
    RegisterUnitGossipEvent(191881, 2, "On_GossipSelect")

  9. #9
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by josh253 View Post
    Here you go, sorry if there are errors.. I checked through it a couple of times.
    If there is, I can fix them, I'm just tired. I hope 32569 is your coin ID, if not you can change it. I added a 2 coin system, but its riskier and there's a 75% chance of losing. =)


    Code:
    function On_GossipMenu(unit, event, player)
    if (player:IsInCombat() == true) then
    player:SendAreaTriggerMessage("Sorry, you have to leave combat first!")
    else  
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    end
    
    function On_GossipSelect(unit, event, player, id, intid, code)
    
    if (intid == 7) then
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    
    if (intid == 1) then
    if (misc:GetItemCount(32569) < 1) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 50% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 5, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 5) then
    Choice=math.random(1, 2)
    if Choice==1 then
    player:AddItem(32569, 1)
    end
    if Choice==2 then
    player:RemoveItem(32569, 1)
    end
    end
    
    if (intid == 2) then
    if (misc:GetItemCount(32569) < 2) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 25% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 6, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 6) then
    Choice=math.random(1, 4)
    if Choice==1 then
    player:AddItem(32569, 2)
    end
    if Choice==2 then
    player:RemoveItem(32569, 2)
    end
    if Chocie==3 then
    player:RemoveItem(32569, 2)
    end
    if Choice==4 then
    player:RemoveItem(32569, 2)
    end
    end
    
    RegisterUnitGossipEvent(191881, 1, "On_GossipMenu")
    RegisterUnitGossipEvent(191881, 2, "On_GossipSelect")
    Gave me an error :P
    Code:
    script/WOTLK/Custom/_____.lua:70: 'end' expected <to close 'function' at line 12> near '<eof>'
    I was actually going to improve the script myself later when I got the basics working :P I will give it out in the release section when it's finished, and I'll give you some credits
    Last edited by Sandile; 03-13-2009 at 05:54 PM.
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

  10. #10
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking of upgrading and releasing my own version of it. =)
    Last edited by Mircast; 03-13-2009 at 06:50 PM.

  11. #11
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be fixed, I ran it through my server and it loaded. However I dont have the SQL's so I could not test it. But here you go. :wave:

    Code:
    function On_Gossip(unit, event, player)
    if (player:IsInCombat() == true) then
    player:SendAreaTriggerMessage("Sorry, you have to leave combat first!")
    else  
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    end
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    
    if (intid == 7) then
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(5, "[Bet 1 Coin]", 1, 0)
    unit:GossipMenuAddItem(5, "[Bet 2 Coins]", 2, 0) 
    unit:GossipSendMenu(player)
    end
    
    if (intid == 1) then
    if (misc:GetItemCount(32569) < 1) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 50% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 5, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 5) then
    Choice=math.random(1, 2)
    if Choice==1 then
    player:AddItem(32569, 1)
    end
    if Choice==2 then
    player:RemoveItem(32569, 1)
    end
    end
    
    if (intid == 2) then
    if (misc:GetItemCount(32569) < 2) then
    player:SendAreaTriggerMessage("You do not have enough coins to bet!")
    else
    unit:GossipMenuAddItem(5, "[You have a 25% chance of winning, continue?]", 0, 0)
    unit:GossipMenuAddItem(4, "[Yes, make haste]", 6, 0)
    unit:GossipMenuAddItem(4, "[No, take me back]", 7, 0)
    unit:GossipSendMenu(player)
    end
    end
    
    if (intid == 6) then
    Choice=math.random(1, 4)
    if Choice==1 then
    player:AddItem(32569, 2)
    end
    if Choice==2 then
    player:RemoveItem(32569, 2)
    end
    if Chocie==3 then
    player:RemoveItem(32569, 2)
    end
    if Choice==4 then
    player:RemoveItem(32569, 2)
    end
    end
    end
    
    RegisterUnitGossipEvent(191881, 1, "On_Gossip")
    RegisterUnitGossipEvent(191881, 2, "Gossip_Submenus")

  12. #12
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First I got some strange Global error, then I changed
    misc:GetItemCount
    to
    Unit:GetItemCount
    and then I got this error instead,

    scripts\WOTLK\_____\______.lua:23: attempt to compare number with nil

    Its this row
    Code:
    if (unit:GetItemCount(32569) < 1) then
    When I click on [Bet 1 Coin]/[Bet 2 Coins] option in the gossip menu.


    still thinks that Im progressing tho.
    Last edited by Sandile; 03-13-2009 at 09:16 PM.
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

  13. #13
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are you talking about? I ran my script through my repack and it worked fine. O_O

  14. #14
    Sandile's Avatar Member
    Reputation
    32
    Join Date
    Aug 2008
    Posts
    314
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yeah I forgot that. The error occurs when I click on any option available in the Gossip Menu.
    "i downloaded it in "pirates bay", can you tell me how to download it in steam, pls"

  15. #15
    Mircast's Avatar Member
    Reputation
    14
    Join Date
    Sep 2008
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (player:GetItemCount(32569) < 1) then
    Try that

Similar Threads

  1. [Guide] Lua Scripting Guide is here [Updating]
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 93
    Last Post: 11-04-2008, 06:56 PM
  2. [GUIDE] How to activate LUA scripts
    By ~SaiLyn~ in forum WoW EMU Guides & Tutorials
    Replies: 3
    Last Post: 12-25-2007, 11:52 AM
  3. Lua Scripts!
    By danis in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 12-15-2007, 03:16 PM
  4. How To LUA Script
    By Skuxta in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 12-13-2007, 04:24 AM
  5. New LUA Scripts
    By 777devil777 in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 11-26-2007, 05:58 PM
All times are GMT -5. The time now is 09:36 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search