![]() |
Server Loop Help - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51) +----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44) +----- Thread: Server Loop Help (/showthread.php?tid=2291) |
Server Loop Help - deathknight - 24-10-2008 Ok, I'm not quite sure how to do this. I know what I WANT to do, I just haven't figured out how. So I'm trying to make a code in the server loop that every 10 seconds looks at all the players online, and updates a stat I created for them. I'm working on a fishing system, and I'm coding it up one piece at a time, to get all the error straight before hand. [spoiler]So I found this in the ServerLoop Code: If Tick > LastUpdatePlayerVitals Then And added under it Code: If Tick > LastUpdatePlayerFishing Then This, code, Like the updateplayervitals, runs every so often. After that I added a sub down near the bottom Code: Private Sub UpdatePlayerFishing() I got an run time error 9, subscript out of range, upon hitting that 10 second mark on the code Code: Public Function GetPlayerStat(ByVal index As Long, ByVal Stat As Stats) As Long I'm figuring this has something to do with the specific player index, but I can't think of a way to make this work. Can anyone help out? Thank you.[/spoiler] Re: Server Loop Help - Jacob - 24-10-2008 First thing i see is Code: fishness As Byte Why is that a byte when GetPlayerStat returns a long? Code: fishness = Int(GetPlayerStat(index, Stats.canfish)) Code: Call SetPlayerStat(index, Stats.canfish, GetPlayerStat(index, Stats.canfish) - fishness) Re: Server Loop Help - deathknight - 24-10-2008 I'm not sure about the index, I was trying to find a way to do it, and as far as I can tell, the code throughout the server side always pops up similar to Code: Int(GetPlayerStat(Index, Stats.defense) I tried removing the index (forget the error code I got for that), and i tried putting in I instead of index (not sure why I tried that, some stupid part of my mind slipped out when I tried that one I guess). I figured the error involved the index. I got the second part of the code Code: Call SetPlayerStat(index, Stats.canfish, GetPlayerStat(index, Stats.canfish) - fishness) Edit*** I got it working. It may have been a problem with dimming it as a byte (I'm not sure) but the final working code was Code: Private Sub UpdatePlayerFishing() Thanks for your help Dugor. |