[Guide] Weather-Function 4 VB
No. This is no dream.
With this small function, you can control the weather on your server:
Add this to your modGameServer.bas
Code:
Public Function SetWeather(Weather As Integer, Intensity As String)
fData = "de3b"
fData = fData & "0000"
fData = fData & "0" & Weather '1 = Normal, 2 = Rain, 3 = snow
fData = fData & Intensity 'From 00(nothing) to FF(ultra^^)
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
End Function
Now 2 examples:
Code:
Public Sub YourButton_Click()
SetWeather 2, "22" 'This will cause a light rainshower
End Sub
Code:
Public Sub YourButton_Click()
SetWeather 3, "FF" 'This will cause biggest snowstorm you've ever seen ;-)
End Sub
If you want to "access" the weather via ChatLine, add this to the HandleChat-Function
Code:
Case ".weather"
If UBound(sCommands) = 2 Then
If IsNumeric(CInt(sCommands(1))) = True Then 'protects server from a crash
SetWeather CInt(sCommands(1)), sCommands(2)
End If
End If
Now you can enter ".weather 1 1" for normal weather in the ChatLine (now will ".weather 3 FF cause your snowstorm ).