dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 For some reason this isn't working, can any of you help me with this? Since calling a function would be easier then typing out the same code over and over I would like to try to make this work. Yes, I am aware that there are codes for this already out there but that's not gonna help me learn as if I can't write a simple function then I wont be able to write a complex one when the time comes.All help is appreciated. Here is my script:> '\\\\\\\\\\\\\\\\\ GET FREE SLOT SCRIPT ////////////////////////> Function GetFreeItemSlot(Index)> slot = 1> Do While int(slot) < 25> If GetPlayerInvItemNum(Index, Int(slot)) = 0 Then> slot = 25> GetFreeItemSlot(Index) = 1> End If> Loop> End Function> '//////////////// END FREE SLOT SCRIPT \\\\\\\\\\\\\\\\\\\\\\\\\And here is the Case:> Case 5> If GetFreeItemSlot(Index) = 1 Then> Call PlayerMsg(Index, "Win", 14)> Else> Call PlayerMsg(Index, "Fail", 14)> End If> Exit SubThanks Link to comment Share on other sites More sharing options...
AdrianC Posted December 27, 2008 Share Posted December 27, 2008 Function GetFreeItemSlot(Index) GetFreeItemSlot=0 slot = 1 Do While int(slot) < 25 If GetPlayerInvItemNum(Index, Int(slot)) = 0 Then slot = 25 GetFreeItemSlot = 1 End If LoopEnd FunctionWould probably work. Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 Nope, isn't returning anything still.Oh yeah, before I forget it does tell me that the script is taking longer then normal to execute. Not sure why that is or if it effects it at all. Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 still not working and I still get the taking too long thing.What does dim do anyway? Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 Yeah, I just got it working before I looked on here and it seems we found the same mistake, haha.Could you tell me what Dim does though? Everything works without it so I haven't found what its useful for unless its a whole memory saving thing. Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 What kind of problems? Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 rofl, okay you wont have to keep posting then ;)If anyone does happen across any bugs in my scripts I'll just add the dim and it should become bug free if I'm understanding this right. Thanks for the help AdrianC! Link to comment Share on other sites More sharing options...
dg1423 Posted December 27, 2008 Share Posted December 27, 2008 fff, can't believe no one noticed these. There are a couple problems with your function:1) INFINITE LOOPS DETECTED (you're not incementing the vlue so it's staying at 1 the whole time)2) It desn't reurn 0 i there aren't any slots.and so:Function GetFreeItemSlot(Index) GetFreeItemSlot=0 slot = 1 Do While int(slot) < 25 If GetPlayerInvItemNum(Index, Int(slot)) = 0 Then slot = 25 GetFreeItemSlot = 1 exit function End If slot = slot + 1 Loop GetFreeItemSlot = 0End Function Link to comment Share on other sites More sharing options...
AdrianC Posted December 27, 2008 Share Posted December 27, 2008 Lol, stop making me remove my posts.Just random bugs. You need to declare a variable before using it, its just the way programming languages work.EDITMods, he's not quadruple posting btw, I just removed my posts. No warning required.That was my last post.Already found the error, I just keep removing my posts because I'm saving 1337 for something.Anyway, I'm off to bed. Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 Yeah, we figured it out, he was just deleting his posts as he mentioned so it doesn't look like so. Thanks though.BTW, you don't need a second GetFreeItemSlot = 0 after the loop. It works fine without it as the initial value was never changed so it remains at 0. Link to comment Share on other sites More sharing options...
dg1423 Posted December 27, 2008 Share Posted December 27, 2008 didn't see it at the beginning. xD Link to comment Share on other sites More sharing options...
dragonlord52 Posted December 27, 2008 Author Share Posted December 27, 2008 Hehe, gotta love when ya overlook things…especially when you haven't posted it on the forums :p Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now