Mirage Source http://miragesource.net/forums/ |
|
Message loop http://miragesource.net/forums/viewtopic.php?f=201&t=851 |
Page 1 of 2 |
Author: | Matt [ Sat Dec 16, 2006 12:58 am ] |
Post subject: | Message loop |
I need to make a message display after it checks the inventory for a certain item. But I only want it to display once, currently, if it can't find that item, then it will display the message once for each inventory slot. Any idea how to fix this? |
Author: | Obsidian [ Sat Dec 16, 2006 1:14 am ] |
Post subject: | |
Edit... can't delete this. Kite said almost the exact thing that i did... |
Author: | Robin [ Sat Dec 16, 2006 1:14 am ] |
Post subject: | |
Put it after the loop instead of during? Code: If loop = false + no item = gay then
sendmessage("Fag, no item!") else sendmessage("You hand him the gay") end if |
Author: | Matt [ Sat Dec 16, 2006 1:19 am ] |
Post subject: | |
This is the sub I need it for: Code: Sub PlayerCreateGuild(ByVal Index As Long)
Dim Packet As String Dim d As Integer For d = 1 To MAX_INV If GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) >= 500000 Then Packet = "GUILDNPC" & END_CHAR Call SendDataTo(Index, Packet) ElseIf GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) < 500000 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) ElseIf GetPlayerInvItemNum(Index, d) <> 1 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) End If Next d End Sub |
Author: | Obsidian [ Sat Dec 16, 2006 1:21 am ] |
Post subject: | |
Code: If Item(GetPlayerInvItemnum(Index, d)).Type = ITEM_TYPE_CURRENCY and Trim$(Item(GetPlayerInvItemNum(Index, d)).Name) = "Gold" then
And get with me soon... i have an entire guild system setup that's exactly like what you're attempting to do... i'll let you have a look at it. ![]() |
Author: | Matt [ Sat Dec 16, 2006 1:22 am ] |
Post subject: | |
I've tried that, it still loops through the inventory, displaying the message for each slot. I think someone once told me to use an exit for somewhere in there and that would fix it. I don't remember. |
Author: | Obsidian [ Sat Dec 16, 2006 1:23 am ] |
Post subject: | |
After it finds the item... just do a Code: exit for
|
Author: | Matt [ Sat Dec 16, 2006 1:24 am ] |
Post subject: | |
That's what I thought. I added it in, if I don't have any money, it displays once, but if I have some, but not enough, it displays it twice. Going to try something real quick. I will let you know if it works. |
Author: | halla [ Sat Dec 16, 2006 1:26 am ] |
Post subject: | |
Probably a crappy way to do it but couldnt you just... if they have enough stuff then you set a variable such as.... ENOUGHGOLD = 1 Then right before the exit sub you have something like... if ENOUGHGOLD <> 1 Then msg "You do not have enough money!" something along those lines? |
Author: | Matt [ Sat Dec 16, 2006 1:28 am ] |
Post subject: | |
I just added another exit for and it's fine. Sub is like this now: Code: Sub PlayerCreateGuild(ByVal Index As Long)
Dim Packet As String Dim d As Integer For d = 1 To MAX_INV If GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) >= 500000 Then Packet = "GUILDNPC" & END_CHAR Call SendDataTo(Index, Packet) ElseIf GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) < 500000 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) Exit For ElseIf GetPlayerInvItemNum(Index, d) <> 1 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) Exit For End If Next d End Sub |
Author: | Obsidian [ Sat Dec 16, 2006 1:40 am ] |
Post subject: | |
You should add a for after the initial if line as well... if you don't it's going to go through the loop again that many more times... and continue looking for it... even though it's already found it... |
Author: | Matt [ Sat Dec 16, 2006 2:23 am ] |
Post subject: | |
Huh? Lol. Can you show me what you mean? |
Author: | Lea [ Sat Dec 16, 2006 3:26 am ] |
Post subject: | |
Code: Sub PlayerCreateGuild(ByVal Index As Long)
Dim Packet As String Dim d As Integer For d = 1 To MAX_INV If GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) >= 500000 Then Packet = "GUILDNPC" & END_CHAR Call SendDataTo(Index, Packet) Exit For ElseIf GetPlayerInvItemNum(Index, d) = 1 And GetPlayerInvItemValue(Index, d) < 500000 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) Exit For ElseIf GetPlayerInvItemNum(Index, d) <> 1 Then Call PlayerMsg(Index, "You need 500,000 gold to register a guild.", BrightRed) Exit For End If Next d End Sub |
Author: | Matt [ Sat Dec 16, 2006 3:30 am ] |
Post subject: | |
Oh okay. Good point. Didn't notice that. Thanks alot guys. ^_^ |
Page 1 of 2 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |