100% working and tested!
If it doesnt work thats your fault for messing something up.
[spoiler]Open up frmMirage and add a command button called
btnAdmin
double click and a code window will pop up, Put this inbetween Private Sub btnAdmin_Click() and End Sub right under it.
Code: If GetPlayerAccess(MyIndex) >= ADMIN_MONITER 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
[/spoiler]
You can add a F1 Or a button if you want..If you want to follow what I put above click the spoiler...(I tested it but most people might want something else)
Then download frmAdmin and add it to the src Folder.
RAPIDSHARE - http://rapidshare.com/files/155030086/frmAdmin.frm.html
MEGAUPLOAD - http://www.megaupload.com/?d=1QE92IQ1
Then you done! Thanks Credits to
10% Me
70% Doomteam1
20% For my lungs letting me breath to give oxygen to my brain.
Why do you make a btnAdmin, and that button is viewable to everyone who is or is not a admin, so go into frmMirage and in form_load add
Code: If GetPlayerAccess(MyIndex) >= ADMIN_MONITER Then
btnAdmin.Visible = True
Else
If GetPlayerAccess(MyIndex) >= 0 Then
btnAdmin.Visible = False
Call AddText("You do NOT have access to that selection.", BrightRed)
End If
End If
then make btnAdmin's visibilty false through it's own properties
(I think that will work, do not qoute me on it though)
and add the f1 key to form key up the way it was done in the old tuts
I thought ADMIN_MONITER had been changed already?
Thanks dark X and Hikaru I didnt change my moniter =\
check that code before you use it, and whats diffrent between this one and the other one? didn't care to check 'cause I don't use MS4
thanks for giving me credit
and nice
Now Open frmMirage and in sub Form_KeyUp()
Right under:
Code: Call CheckInput(0, KeyCode, Shift)
Add:
Code: If KeyCode = vbKeyF1 Then
If Player(MyIndex).Access > 0 Then
frmAdmin.Visible = False
frmAdmin.Visible = True
End If
End If
there is the code for you Night, makes it so when you push f1 the admin panel appears.
you forgot Else.. You put a space instead...(I think.)
If KeyCode = vbKeyF1 Then
If Player(MyIndex).Access > 0 Then
frmAdmin.Visible = False
Else
frmAdmin.Visible = True
End If
End If
I just c&p'd from the old forums, so just change it as needed, why not add the posts I made into yours then put your button codes in there so that people who are new will know what your talking about.
I think ill just remake this whole thing sence i COMPLETELY Changed my admin panel lol. also
Please help..I changed something in my frmMirage and now when i hit enter to send a message on chat it doesnt send and it makes a DING sound...Like a low dong like...You know what i mean... here is my frm mirage code..
[code]Option Explicit
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
' ******************************************
' ** Mirage Source 4 **
' ******************************************
Private Sub Form_Load()
frmMirage.Width = 10080
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call DestroyGame
End Sub
' Winsock event
Private Sub Socket_DataArrival(ByVal bytesTotal As Long)
If IsConnected Then
Call IncomingData(bytesTotal)
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call CheckInput(1, KeyCode, Shift)
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Call CheckInput(0, KeyCode, Shift)
End Sub
Private Sub picScreen_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If InEditor Then
Call MapEditorMouseDown(Button, Shift, X, Y)
Else
Call PlayerSearch
End If
Call SetFocusOnChat
End Sub
Private Sub picScreen_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
CurX = X \ PIC_X
CurY = Y \ PIC_Y
If InEditor Then
shpLoc.Visible = False
If Button = vbLeftButton Or Button = vbRightButton Then
Call MapEditorMouseDown(Button, Shift, X, Y)
End If
End If
End Sub
Private Sub txtMyChat_Change()
MyText = txtMyChat
End Sub
Private Sub txtChat_GotFocus()
SetFocusOnChat
End Sub
Private Sub picInventory_Click()
Call UpdateInventory
picInv.Visible = True
End Sub
Private Sub lblUseItem_Click()
Call SendUseItem(frmMirage.lstInv.ListIndex + 1)
End Sub
Private Sub lblDropItem_Click()
Dim Value As Long
Dim InvNum As Long
InvNum = frmMirage.lstInv.ListIndex + 1
If GetPlayerInvItemNum(MyIndex, InvNum) > 0 Then
If GetPlayerInvItemNum(MyIndex, InvNum)
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] 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
[/spoiler]
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
[/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] 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
[/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 underneath Code: frmMirage.Width = 10080
Sure you can still edit the client to show the button, but with proper checks on the server side, it shouldn't matter.
[spoiler] Code: If GetPlayerAccess(MyIndex) >= 1 Then
frmMirage.btnAdmin.Visible = True
Else
frmMirage.btnAdmin.Visible = False
[/spoiler]
Where is the Sub HandleKeyPresses? frmMirage? if it is then i must have deleted it by accident
Should be in a module somewhere. Probably game logic.
Yeah, it is in modGameLogic. If you are having trouble finding it, just ctrl + F Sub HandleKeypresses and it should pop up.
I replaced mine with no errors and still the same thing..I hit enter and nothing happens
Take the last couple of things you have added in, and comment them out one at a time. Once it starts letting you send the error message, uncomment everything except the last thing you commented out, also one at a time. This will narrow it down to what lines are causing the error. You might also me able to use this to find which line in the sub/mod/etc. is causing the error, but that would take a little more though. If you find the line thats causing the error, and still can't figure it out, then put the code here, and I'll look over it for you.
How am I suppost to find it when there isnt an error. =\
>.< I dont know what to search in lol.
Quote:Open up frmMirage and add a command button called
btnAdmin
Sorry
thank you rian, but im still getting a variable not defined compile error
leading me to ADMIN_MONITER
I believe admin_moniter has been corrected to admin_monitor. Change that in the code, should work.
lol well that fixed that problem death. lol
but then i got introduced to another crap load of other problems..
oh well :\
thanks guys for helping me.
|