20-10-2008, 04:14 AM
Ok, so I looked through your code, and as far as I can tell everything looks fine (except one little error I will point out in a minute). I think the problem may be in your Sub HandleKeyPresses. I will post my On Return part of the sub below.
[spoiler][/spoiler]
Now thats out of the way, let me point out something in the Sub btnAdmin_Click().
If you look at it
[spoiler][/spoiler]
You will notice that it checks to see if your access is greater than or equal too 1, in which case it makes the form visible. Imediately after that, it checks to see if your access is GREATER than or equal to ZERO and then set the form visible to false. So you have one if making the form visible, and the next one making it not so visible.
This should work though, if im not mistaken
[spoiler][/spoiler]
If I'm reading this Sub btnAdmin_click wrong, please let me know, although it seems to make sense to me.
Also if you want the btnAdmin to be visible to only admins, just add this in the Sub Form_Load right underneathSure you can still edit the client to show the button, but with proper checks on the server side, it shouldn't matter.
[spoiler][/spoiler]
[spoiler]
Code:
' Handle when the player presses the return key
If KeyAscii = vbKeyReturn Then
' Broadcast message
If Left$(ChatText, 1) = "'" Then
ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)
If Len(ChatText) > 0 Then
Call BroadcastMsg(ChatText)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
' Emote message
If Left$(ChatText, 1) = "-" Then
MyText = Mid$(ChatText, 2, Len(ChatText) - 1)
If Len(ChatText) > 0 Then
Call EmoteMsg(ChatText)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
' Player message
If Left$(ChatText, 1) = "!" Then
ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)
Name = vbNullString
' Get the desired player from the user text
For i = 1 To Len(ChatText)
If Mid$(ChatText, i, 1) " " Then
Name = Name & Mid$(ChatText, i, 1)
Else
Exit For
End If
Next i
' Make sure they are actually sending something
If Len(ChatText) - i > 0 Then
MyText = Mid$(ChatText, i + 1, Len(ChatText) - i)
' Send the message to the player
Call PlayerMsg(ChatText, Name)
Else
Call AddText("Usage: !playername msghere", AlertColor)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
' Global Message
If Left$(ChatText, 1) = vbQuote Then
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)
If Len(ChatText) > 0 Then
Call GlobalMsg(ChatText)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
End If
' Admin Message
If Left$(ChatText, 1) = "=" Then
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)
If Len(ChatText) > 0 Then
Call AdminMsg(MyText)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
End If
If Left$(MyText, 1) = "/" Then
Command = Split(MyText, " ")
Select Case Command(0)
Case "/help"
Call AddText("Social Commands:", HelpColor)
Call AddText("'msghere = Broadcast Message", HelpColor)
Call AddText("-msghere = Emote Message", HelpColor)
Call AddText("!namehere msghere = Player Message", HelpColor)
Call AddText("Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /trade, /party, /join, /leave", HelpColor)
Case "/info"
' Checks to make sure we have more than one string in the array
If UBound(Command) >= 1 Then
Call SendData(CPlayerInfoRequest & SEP_CHAR & Command(1) & END_CHAR)
End If
' Whos Online
Case "/who"
SendWhosOnline
' Checking fps
Case "/fps"
BFPS = Not BFPS
' Show inventory
Case "/inv"
UpdateInventory
frmMirage.picInv.Visible = True
' Request stats
Case "/stats"
SendData CGetStats & END_CHAR
' Show training
Case "/train"
frmTraining.Show vbModal
' Request stats
Case "/trade"
SendData CTrade & END_CHAR
' Party request
Case "/party"
' Make sure they are actually sending something
If UBound(Command) >= 1 Then
Call SendPartyRequest(Command(1))
Else
Call AddText("Usage: /party playernamehere", AlertColor)
End If
' Join party
Case "/join"
SendJoinParty
' Leave party
Case "/leave"
SendLeaveParty
' // Moniter Admin Commands //
' Admin Help
Case "/admin"
If GetPlayerAccess(MyIndex) > 0 Then
Call AddText("Social Commands:", HelpColor)
Call AddText("""msghere = Global Admin Message", HelpColor)
Call AddText("=msghere = Private Admin Message", HelpColor)
Call AddText("Available Commands: /admin, /loc, /mapeditor, /warpmeto, /warptome, /warpto, /setsprite, /mapreport, /kick, /ban, /edititem, /respawn, /editnpc, /motd, /editshop, /editspell", HelpColor)
End If
' Kicking a player
Case "/kick"
If GetPlayerAccess(MyIndex) > 0 Then
If UBound(Command) >= 1 Then
SendKick Command(1)
End If
End If
' // Mapper Admin Commands //
' Location
Case "/loc"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
BLoc = Not BLoc
End If
' Map Editor
Case "/mapeditor"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
SendRequestEditMap
End If
Case "/editmap"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
SendRequestEditMap
End If
' Warping to a player
Case "/warpmeto"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
If UBound(Command) >= 1 Then
WarpMeTo Command(1)
End If
End If
' Warping a player to you
Case "/warptome"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
If UBound(Command) >= 1 Then
WarpToMe Command(1)
End If
End If
' Warping to a map
Case "/warpto"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
If UBound(Command) Then
n = CLng(Command(1))
' Check to make sure its a valid map #
If n > 0 And n = ADMIN_MAPPER Then
SendData CMapReport & END_CHAR
End If
' Respawn request
Case "/respawn"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
SendMapRespawn
End If
' MOTD change
Case "/motd"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
If UBound(Command) >= 1 Then
'If Len(MyText) > 0 Then
SendMOTDChange Command(1)
'End If
End If
End If
' Check the ban list
Case "/banlist"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
SendBanList
End If
' Banning a player
Case "/ban"
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
If UBound(Command) >= 1 Then
SendBan Command(1)
End If
End If
' // Developer Admin Commands //
' Editing item request
Case "/edititem"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditItem
End If
Case "/itemeditor"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditItem
End If
' Editing npc request
Case "/editnpc"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditNpc
End If
Case "/npceditor"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditNpc
End If
' Editing shop request
Case "/editshop"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditShop
End If
Case "/shopeditor"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditShop
End If
' Editing spell request
Case "/editspell"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditSpell
End If
Case "/spelleditor"
If GetPlayerAccess(MyIndex) >= ADMIN_DEVELOPER Then
SendRequestEditSpell
End If
' // Creator Admin Commands //
' Giving another player access
Case "/setaccess"
If GetPlayerAccess(MyIndex) >= ADMIN_CREATOR Then
If UBound(Command) >= 2 Then
SendSetAccess Command(2), CLng(Command(1))
End If
End If
' Ban destroy
Case "/destroybanlist"
If GetPlayerAccess(MyIndex) >= ADMIN_CREATOR Then
SendBanDestroy
End If
Case Else
AddText "Not a valid command!", HelpColor
End Select
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
' Say message
If Len(ChatText) > 0 Then
Call SayMsg(ChatText)
End If
MyText = vbNullString
frmMirage.txtMyChat.Text = vbNullString
Exit Sub
End If
Now thats out of the way, let me point out something in the Sub btnAdmin_Click().
If you look at it
[spoiler]
Code:
Private Sub btnAdmin_Click()
If GetPlayerAccess(MyIndex) >= 1 Then
frmAdmin.Visible = True
Else
If GetPlayerAccess(MyIndex) >= 0 Then
frmAdmin.Visible = False
Call AddText("You cannot open up the admin menu.", BrightRed)
End If
End If
End Sub
You will notice that it checks to see if your access is greater than or equal too 1, in which case it makes the form visible. Imediately after that, it checks to see if your access is GREATER than or equal to ZERO and then set the form visible to false. So you have one if making the form visible, and the next one making it not so visible.
This should work though, if im not mistaken
[spoiler]
Code:
Private Sub btnAdmin_Click()
If GetPlayerAccess(MyIndex) >= 1 Then
frmAdmin.Visible = True
Else
frmAdmin.Visible = False
Call AddText("You cannot open up the admin menu.", BrightRed)
End If
End Sub
If I'm reading this Sub btnAdmin_click wrong, please let me know, although it seems to make sense to me.
Also if you want the btnAdmin to be visible to only admins, just add this in the Sub Form_Load right underneath
Code:
frmMirage.Width = 10080
[spoiler]
Code:
If GetPlayerAccess(MyIndex) >= 1 Then
frmMirage.btnAdmin.Visible = True
Else
frmMirage.btnAdmin.Visible = False