Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Boynaar44

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Everything posted by Boynaar44

  1. So I made this because of an unofficial request from Erwin. It will show you an example of how to loop through all players. In this example we will loop through all players and get the average level. ALL PLAYERS means, online and offline players. It is server side only. This tutorial requires you to add the reference "Microsoft Scripting Runtime" to your server project. Project -> References… -> check the "Microsoft Scripting Runtime" First we need to create a temporarily player type to load the player data we need of each player we loop through. We do that by adding the next code inside the modTypes in your server project. So search for: ' Public data structures And add in the list under it ``` Public TempPlayerUse As PlayerRec ``` After we have done that, we need to create the subs which will actually load the players we loop through into the "TempPlayerUse". We do that by adding the next 2 subs into your project, a good place would be at the bottom of your "modDatabase" ``` Sub LoadTempPlayerUse(ByVal Name As String) Dim filename As String Dim F As Long Call ClearTempPlayerUse filename = App.path & "\data\accounts\" & Trim(Name) F = FreeFile Open filename For Binary As #F Get #F, , TempPlayerUse Close #F End Sub Sub ClearTempPlayerUse() Dim i As Long Call ZeroMemory(ByVal VarPtr(TempPlayerUse), LenB(TempPlayerUse)) TempPlayerUse.Login = vbNullString TempPlayerUse.Password = vbNullString TempPlayerUse.Name = vbNullString TempPlayerUse.Class = 1 End Sub ``` So you see in the code we just added, before it loads a player, it clears the already loaded player. Thats why we need 2 subs, one to load and another to clear. Now we have that, we should make use of it and start looping through the players by reading all the player names inside the charlist.txt. Here we will make use of the "Microsoft Scripting Runtime". Create a new function called "GetAverageLevel", at the bottom of your "modPlayer" would be a good place for it. ``` Public Function GetAverageLevel() ' Here we will create the Microsoft Scripting Runtime object. ' We also need to define the charlist.txt path. Dim averageLevels as Long ' Open the charlist.txt and count how many lines it has. ' Save the player names into an array between 0 and the count of lines in charlist.txt ' Close the charlist.txt ' Loop through the player names array we just created, we load the players and get their levels. GetAverageLevel = averageLevels End Function ``` To count how many lines the charlist.txt has we need this function. Just add it under the unfinished GetAverageLevel function we just created. ``` Private Function getLineCount(ByVal strFilePath As String) As Long Open strFilePath For Binary As #1 Dim strBuff As String: strBuff = Space(LOF(1)) Get #1, , strBuff getLineCount = UBound(Split(strBuff, vbCrLf)) Close #1 End Function ``` Now we have that, we will continue working on the GetAverageLevel function. Inside the GetAverageLevel function do the following. Add under "Here we will create the Microsoft Scripting Runtime object." ``` Dim FSO As New FileSystemObject ' Implement the Microsoft Scripting Runtime to use it Dim charlistFile As TextStream ' Here we will open the charlist.txt and since it is a TextStream we can read the lines. ``` Then add under "We also need to define the charlist.txt path." ``` Dim charlistPath As String ' To store the path of the charlist.txt ``` And then we still need some values to use. Add under "Dim averageLevels as Long" ``` Dim accountNames() As String ' Account names array Dim lineCount As Long ' The count of lines in charlist.txt Dim i As Long ' We need this to make a loop. ``` After that we have created the FileSystemObject and dimmed the values we need. We can now open the charlist.txt so we can load it into the "accountNames()" array later. Add under "Open the charlist.txt and count how many lines it has." ``` charlistPath = App.path & "\data\Accounts\charlist.txt" ' Path lineCount = getLineCount(charlistPath) ' Count the lines Set charlistFile = FSO.OpenTextFile(charlistPath) ' Open the file ReDim accountNames(0 To lineCount) ' Set the array width we are gonna use. ``` Now we have the total lines, we can save the names into the "accountNames()" array. Add under "Save the player names into an array between 0 and the count of lines in charlist.txt" ``` Do While Not charlistFile.AtEndOfStream ' As long as we haven't reached the end, do the following. accountNames(i) = charlistFile.ReadLine ' Add the current line into the current "accountNames" slot. i = i + 1 ' Add 1 to the current slot we are working with. Loop ``` Now we are done with the charlist.txt, we can close it. Add under "Close the charlist.txt" the following code to close the file. ``` charlistFile.Close ' Close the opened file. ``` The accountNames are loaded, now we can read the levels by loading any of them into the TempPlayerUse which we created earlier. We will load them one by one and count the levels and divide at the same time to get the average level. Add under "Loop through the player names array we just created, we load the players and get their levels." the following code. ``` For i = 0 To UBound(accountNames) ' Loop from the first to the last array slot. Call LoadTempPlayerUse(accountNames(i) & ".bin") ' Load the player into the current array slot. If i = 0 Then ' We don't divide the first one averageLevels = TempPlayerUse.Level Else averageLevels = (TempPlayerUse.Level + averageLevels) / 2 ' Calculate the current average. End If Next ``` That's all. Why make the tutorial this way? Because in the past there was a time for me I wanted this kind of tutorials.
  2. Why so serious? Just put the charlist.txt into an array of accountnames…
  3. Isn't the Winsock a user control in the components list, not in the references? ~~I am not sure this will work but you may try the next, 1\. Download the mswinsck.ocx somewhere from. 2\. I don't know if the mswinsck.ocx has a 32bit and 64bit version, if you know it's a 64bit version then place it in SysWOW64, if you don't know then place it in System32. 3\. Open notepad or any text editor and write the following code, DO NOT FORGET to replace the [Location MSWINSCK.OCX] with the location folder the mswinsck.ocx is placed in. ``` cd [Location MSWINSCK.OCX] regsvr32 MSWINSCK.OCX ``` 4\. Save the text file as a ".bat" file somewhere. 5\. Explore to the ".bat" file you created, right-click it and run as admin.~~ Never mind, since you see the icon, you don't have to do this.
  4. I like it how you talk to yourself ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons//tongue.png) However you are a good example for some people, some things can't just be explained, you have to find them out on your own. So well done ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons//smile.png)
  5. That's really nice, well done. [Mode7](http://en.wikipedia.org/wiki/Mode_7) would suit Eclipse a lot more, but what you did looks also good. >! ![](http://img.photobucket.com/albums/v226/ccoa0/mode7.png)
  6. > Any can post in this thread the full tutorial? i don't understand where is the complete code and the work fine code… in this post have 20000 codes (?)... help? I posted it [here](http://www.touchofdeathforums.com/community/index.php?/topic/129156-eoevent-system-3-some-bug-fixes/) a while ago, look the last Quote…
  7. This code is nothing, I guess you saved the suffix to the player type? and coded so it changes the value of "name" in the code you posted to PlayerSuffix + name? All those spaces might be because you didn't use Trim$ by saving the suffix.
  8. > ![](http://ignitethecinder.com/enruin/img/weaponedit1.png) > > It's a bit dodgy, but I ….said nothing.. :S This looks really awesome possum(I didnt type possum -.-), +1 from me
  9. Boynaar44

    C++

    I know the basics of C++, so I go for "I would love to learn" ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons//tongue.png)
  10. @hardcorex9, there is no difference between "player(index).access = [Access here]" and "SetPlayerAccess(Index, Value)". >! Before everything, I was just being sarcasm because you said it's the easiest way. But yeah then you said something wrong. >! So that means… >! "player(index).level = 1" should actually be changed to "SetPlayerLevel(index, 1)", just to prevent a crash from setting a level to a value of "1"? >! No, you forgot something… >! If you know for 100% sure that there can't be any crash of setting a player-level to a value of 1, you can just use "player(index).level = 1" and ignore all the pointless things on the function "SetPlayerLevel"… >! Here we are talking about a small improvement of performance, where it doesn't actually matter what you use since it doesn't really effect the performance of the program, but still you should use any possibility available to increasse the performance of the program without having any possible issue. >! Btw.. Check the source code first before you say: the Sub I suggested to call wraps that call with some checks to prevent crashes. >! There can't go anything wrong by using "player(index).access = 4", in some cases it's even better, but in other cases "SetPlayerAccess" might be better. >! So what crashes are you actually talking about? >! As you see, you can't prove me wrong, because we both are actually talking about the same point. >! And remember, it's nice to be important, but it's more important to be nice ^^
  11. Lol nooo there is a much easier way… You just have to add "player(index).access = [Access here]" somewhere in a sub… I always found that sub by searching for "player(index).level = 1" in the project.. Edit: All ways are super easy, but this way is the easiest.
  12. Hello guys, Some of you may know the game mod DayZ of Arma2:CO, so I thought I would make a topic here. So since 3 days I have set up an unofficial DayZ server to play on with friends. The server is online from 08:00am to 11:00pm in GMT, what is from 08:00 to 23:00 in 24h format. The server is password protected, since I don't want anyone to come on it. I also disabled the BattleEye from the server to allow cheats, but you are not allowed to cheat without asking me first. Your only enemy on the game are the zombies, you are not allowed to kill other players and that's the main reason why I made an unofficial DayZ server. So what I told you up there, I can call "rules" pretty much. I don't like rules, but yeah they can be of good use. For the people who don't know what is an unofficial DayZ server, it's a DayZ server wich is not connected with the hive and wich doesn't have the minimum required configurations decided by the makers of DayZ. Since the unofficial servers are not connected to hive, they don't have shared character data with other servers, it saves the character data on a mysql database on the server. So after a long story, I come near the end. If you would like to join me playing, you should send me a pm and I will think about sending you the server password.
  13. Replace ``` If Item(GetPlayerInvItemNum(Index, invNum)).BindType = 1 Or Item(GetPlayerInvItemNum(Index, invNum)).BindType = 2 Then Exit Sub ``` under ``` If GetPlayerInvItemNum(Index, invNum) < 1 Or GetPlayerInvItemNum(Index, invNum) > MAX_ITEMS Then Exit Sub ``` That will fix it. And please next time use the code function for codes, not the quote function. ![](http://img401.imageshack.us/img401/9445/codefunction.jpg)
  14. There are many ways, since the scrolling with mouse in VB6 doesn't work, my way of coding is more like staying on the same place.
  15. Today I came to check the forum out and looks like my IP is unbanned.. I am not planning to get banned anymore so, I will even only be around on the source section just as a hobby… Btw, I was banned for ignoring warnings and multiaccounting etc...
  16. Oh really? Can you explain please?
  17. Here are some bugs I found and hopefully fixed. > Sometimes in bank you can't withdraw currency items. > > This will fix it. > > This fix is client side only. > > Replace this wich is in frmMain: > > ``` > > Private Sub lblCurrencyOk_Click() > > ' If debug mode, handle error then exit out > > If Options.Debug = 1 Then On Error GoTo errorhandler > > If IsNumeric(txtCurrency.text) Then > > If Val(txtCurrency.text) > GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) Then txtCurrency.text = GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) > > Select Case CurrencyMenu > > Case 1 ' drop item > > SendDropItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 2 ' deposit item > > DepositItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 3 ' withdraw item > > WithdrawItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 4 ' offer trade item > > TradeItem tmpCurrencyItem, Val(txtCurrency.text) > > End Select > > Else > > AddText "Please enter a valid amount.", BrightRed > > Exit Sub > > End If > > picCurrency.Visible = False > > tmpCurrencyItem = 0 > > txtCurrency.text = vbNullString > > CurrencyMenu = 0 ' clear > > ' Error handler > > Exit Sub > > errorhandler: > > HandleError "lblCurrencyOk_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext > > Err.Clear > > Exit Sub > > End Sub > > ``` > > With this: > > ``` > > Private Sub lblCurrencyOk_Click() > > ' If debug mode, handle error then exit out > > If Options.Debug = 1 Then On Error GoTo errorhandler > > If IsNumeric(txtCurrency.text) Then > > Select Case CurrencyMenu > > Case 1 ' drop item > > If Val(txtCurrency.text) > GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) Then > > txtCurrency.text = GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) > > Else > > AddText "Please enter a valid amount.", BrightRed > > Exit Sub > > End If > > SendDropItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 2 ' deposit item > > If Val(txtCurrency.text) > GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) Then > > txtCurrency.text = GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) > > Else > > AddText "Please enter a valid amount.", BrightRed > > Exit Sub > > End If > > DepositItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 3 ' withdraw item > > If Val(txtCurrency.text) > Bank.Item(tmpCurrencyItem).Value Then > > txtCurrency.text = Bank.Item(tmpCurrencyItem).Value > > Else > > AddText "Please enter a valid amount.", BrightRed > > Exit Sub > > End If > > WithdrawItem tmpCurrencyItem, Val(txtCurrency.text) > > Case 4 ' offer trade item > > If Val(txtCurrency.text) > GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) Then > > txtCurrency.text = GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) > > Else > > AddText "Please enter a valid amount.", BrightRed > > Exit Sub > > End If > > TradeItem tmpCurrencyItem, Val(txtCurrency.text) > > End Select > > End If > > picCurrency.Visible = False > > tmpCurrencyItem = 0 > > txtCurrency.text = vbNullString > > CurrencyMenu = 0 ' clear > > ' Error handler > > Exit Sub > > errorhandler: > > HandleError "lblCurrencyOk_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext > > Err.Clear > > Exit Sub > > End Sub > > ``` > I don't remember what this bug did, but it is a bug and needs to be fixed like the others. > > Looks like it's also in the bank. > > And also client side only. > > Replace this line, wich is located in "Private Sub picBank_DblClick()" inside the frmMain: > > ``` > > If GetBankItemNum(bankNum) = ITEM_TYPE_NONE Then Exit Sub > > ``` > > With this: > > ``` > > If Item(GetBankItemNum(bankNum)).Type = ITEM_TYPE_NONE Then Exit Sub > > ``` > Another bank bug, when you move the mouse over a bank item, you don't see the picture. > > This will fix it. > > Also client side only. > > Add: > > ``` > > LastItemDesc = Bank.Item(bankNum).num > > ``` > > Under this, wich is in "Private Sub picBank_MouseMove" in frmMain. > > ``` > > UpdateDescWindow Bank.Item(bankNum).num, x2, y2 > > ``` > This is more an uncoded part than a bug actually, you can't see the attack animation of other players. > > This will fix it. > > It's server side only. > > Search for this, inside your server source project: > > ``` > > ' Send this packet so they can see the person attacking > > ``` > > And add under it, this: > > ``` > > Set Buffer = New clsBuffer > > Buffer.WriteLong SAttack > > Buffer.WriteLong index > > SendDataToMap GetPlayerMap(index), Buffer.ToArray() > > Set Buffer = Nothing > > ``` > > On the same sub("Sub HandleAttack"), search for: > > ``` > > Dim x As Long, y As Long > > ``` > > Add under it: > > ``` > > Dim Buffer As New clsBuffer > > ``` That's all. Feel free to ask me if you need any help, because I like to help. EDIT: Idk why the code looks like this… But I couldnt make it look better.. But you can just copy/paste it.
×
×
  • Create New...