Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EliteMsg...lol
#1
So yeah, for shits and giggles, I tried liquidating the AdminMsg into EliteMsg, so that only level 100's can send and see the messages. But it won't work. I don't get kicked for bad packets, or anything, but it doesn't show the EliteMsg, like it should, instead it shows *Message (* is the trigger)

I was just going to leave it, because it was only to see if I could make it, but then I realized that I'll never get any better, if I don't learn what to look for when something doesn't work. I literally spent hours on this. I'd really appreciate any help.


Here's the code.
[spoiler]Server Side
Code:
Sub EliteMsg(ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
Dim i As Long

    Packet = SEliteMsg & SEP_CHAR & Msg & SEP_CHAR & Color & END_CHAR
    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) And GetPlayerLevel(i) = "100" Then
            Call SendDataTo(i, Packet)
        End If
    Next i
End Sub

Code:
CEliteMsg

Code:
SEliteMsg

Code:
Case CEliteMsg
            HandleEliteMsg Index, Parse

Code:
Sub HandleEliteMsg(ByVal Index As Long, ByRef Parse() As String)
Dim Msg As String
Dim i As Long

    Msg = Parse(1)
    
    ' Prevent hacking
    For i = 1 To Len(Msg)
        If AscW(Mid$(Msg, i, 1)) < 32 Or AscW(Mid$(Msg, i, 1)) > 126 Then
            Call HackingAttempt(Index, "Admin Text Modification")
            Exit Sub
        End If
    Next i
    
    If GetPlayerLevel(Index) = "100" Then
        Call AddLog("(Elite " & GetPlayerName(Index) & ") " & Msg, ADMIN_LOG)
        Call EliteMsg("(Elite " & GetPlayerName(Index) & ") " & Msg, AdminColor)
    End If
End Sub

Client Side

Code:
Sub EliteMsg(ByVal Text As String)
Dim Packet As String

    Packet = CEliteMsg & SEP_CHAR & Text & END_CHAR
    Call SendData(Packet)
End Sub

Code:
CEliteMsg

Code:
SEliteMsg

Code:
Case SEliteMsg
            HandleEliteMsg Parse

Code:
Sub HandleEliteMsg(ByRef Parse() As String)
     Call AddText(Parse(1), CInt(Parse(2)))
End Sub
[/spoiler]
Reply
#2
GetPlayerLevel(i) = "100" ?
Reply
#3
I might not be thinking, but isn't that whats supposed to check if the user is level 100, and then send the message?
Reply
#4
Literally all you needed was to replace the access check with a level > x check... xD

... which (after looking at your code) is what you have nearly done ^__^
Reply
#5
Nearly? DAMNIT. What did I miss? What am I doing wrong? I've looked over this code so much, It must be really obvious too.
Reply
#6
GetPlayerLevel(Index) = "100"

You're checking if their level is equal to the word "100". Replace all those GetPlayerLevel checks with > 100.
Reply
#7
If the level cap is level 100, than how could it be greater? And I wanted it to be availiable for those who are level 100's only, so wouldn't:

If getplayerlevel(index) = 100, be what I'm looking for? *sigh*. I guess I'll try, GetPlayerLevel >= 100, and see if that works. :|
Reply
#8
There's a difference between If GetPlayerLevel(index) = "100" and If GetPlayerLevel(index) = 100

The latter should work. The function GetPlayerLevel returns a numeral. "100" is a string.
Reply
#9
Ohhh, I see. I changed them all to 100 without, the quotes, and yes, I am level 100.

Didn't work.

hehef orgot to add that.
Reply
#10
Honestly though, I can't see anything I've done wrong. I found every instance of AdminMsg, and below it I made the EliteMsg, I can't find any reason why this doesn't work.
Reply
#11
Try removing your GetPlayerLevel checks to see if it actually works then you know what's wrong.
Reply
#12
GIAKEN Wrote:Try removing your GetPlayerLevel checks to see if it actually works then you know what's wrong.

You're a fucking genius. Yeah, it works without the levelchecks. Now I know where to go about fixing this, if possible.
Reply
#13
Code:
If GetPlayerLevel(Index) >= 100 Then

That's what you should use.
Reply
#14
Didn't work. I slowly unnulled stuff out, until I isolated it to this:

Code:
If Left$(ChatText, 1) = "*" Then
            If GetPlayerLevel(MyIndex) > 99 Then
                ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)
                If Len(ChatText) > 0 Then
                    Call EliteMsg(ChatText)
                End If
                MyText = vbNullString
                frmMirage.txtMyChat.Text = vbNullString
                Exit Sub
            End If
        End If
I tried placing the level check everywhere above
Code:
Call EliteMsg(ChatText)
, but it doesn't seem to work.

EDIT: Nevermind, I took out the level check from there, and it works fine. I tried sending it w/ my level 100, and my level 1 didn't pick it up. I set my level one to, level one-hundred, and I could send messages back and forth to my peeps. This is safe, right?
Reply
#15
Uhhh maybe...you should do some more testing.

I had this kind of idea for my game Surviving the Systems Big Grin Except it was like a shout-out type thing. Since I got that on-screen message display I thought it would be cool to do that Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)