Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Genusis beginner guide.
#5
--------SERVER SIDE-----------
--------ModConstants-----------
same as clients modconstants just with a few special constants in there for

the server like the log constants. sample.

Code:
Public Const GAME_WEBSITE = "Http://www/miragesource.com"

Public Const ADMIN_LOG = "admin.log"
Public Const PLAYER_LOG = "player.log"

' Version constants
Public Const CLIENT_MAJOR = 0
Public Const CLIENT_MINOR = 0
Public Const CLIENT_REVISION = 1
Public Const Quote = """"

Public Const MAX_LINES = 500

---------ModDatabase-----------The servers database is a bit different it is something that is used to save and

load everything, from the people to the map tiles and so on. It also give new

special functions like getvar and putvar. sample codes.

Code:
Public Function GetVar(File As String, Header As String, Var As String) As

String
Dim sSpaces As String   ' Max string length
Dim szReturn As String  ' Return default value if not found
  
    szReturn = ""
  
    sSpaces = Space(5000)
  
    Call GetPrivateProfileString(Header, Var, szReturn, sSpaces, Len(sSpaces),

File)
  
    GetVar = RTrim(sSpaces)
    GetVar = Left(GetVar, Len(GetVar) - 1)
End Function

Public Sub PutVar(File As String, Header As String, Var As String, Value As

String)
    Call WritePrivateProfileString(Header, Var, Value, File)
End Sub

Sub SavePlayer(ByVal Index As Long)
Dim FileName As String
Dim f As Long

    FileName = App.Path & "\accounts\" & Trim$(Player(Index).Login) & ".bin"
        
    f = FreeFile
    Open FileName For Binary As #f
        Put #f, , Player(Index)
    Close #f
End Sub

Sub LoadPlayer(ByVal Index As Long, ByVal Name As String)
Dim FileName As String
Dim f As Long

    Call ClearPlayer(Index)
    
    FileName = App.Path & "\accounts\" & Trim(Name) & ".bin"

    f = FreeFile
    Open FileName For Binary As #f
        Get #f, , Player(Index)
    Close #f
End Sub

----------ModDeclares-----------
This is a small part of the server even thou its has three or more functions

that the server has to use. sample code

Code:
' Text API
Declare Function WritePrivateProfileString Lib "kernel32" Alias

"WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal

lpKeyname As Any, ByVal lpString As String, ByVal lpfilename As String) As

Long
Declare Function GetPrivateProfileString Lib "kernel32" Alias

"GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal

lpKeyname As Any, ByVal lpdefault As String, ByVal lpreturnedstring As

String, ByVal nsize As Long, ByVal lpfilename As String) As Long


Public Declare Function GetTickCount Lib "kernel32" () As Long

-------ModGameLogic--------exact opposite of what client gamelogic does. instead of sending and

receiving data it is used to promote and controlled variable objects in the

game, to get them and to find them as well. sample codes.

[code]Function FindOpenPlayerSlot() As Long
Dim i As Long

FindOpenPlayerSlot = 0

For i = 1 To MAX_PLAYERS
If Not IsConnected(i) Then
FindOpenPlayerSlot = i
Exit Function
End If
Next i
End Function

Function GetPlayerDamage(ByVal Index As Long) As Long
Dim WeaponSlot As Long

GetPlayerDamage = 0

' Check for subscript out of range
If IsPlaying(Index) = False Or Index MAX_PLAYERS Then
Exit Function
End If

GetPlayerDamage = Int(GetPlayerSTR(Index) / 2)

If GetPlayerDamage 0 Then
WeaponSlot = GetPlayerWeaponSlot(Index)

GetPlayerDamage = GetPlayerDamage +

Item(GetPlayerInvItemNum(Index, WeaponSlot)).Data2

Call SetPlayerInvItemDur(Index, WeaponSlot,

GetPlayerInvItemDur(Index, WeaponSlot) - 1)

If GetPlayerInvItemDur(Index, WeaponSlot)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)