Mirage Source
Programming an Admin panel - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Programming an Admin panel (/showthread.php?tid=2086)



Programming an Admin panel - Nean - 14-09-2008

[Image: AdminEditor.png]

So what I want to know how to do is be able to type the characters name into the text, and then press a button, and have it happen to the character. So if I typed in: Nean, in the text, and typed kick. It would kick myself. Second of all, I just want to know how to send a request for the other buttons such as: Case CRequesteditmap. If I can get an example for one button for each frame. I can take it from there. Thanks.


Re: Programming an Admin panel - Rian - 14-09-2008

Just working on converting a lot of the admin's text commands into buttons and what not myself Smile

Here's some things I've got in my source. Shoudn't be too hard for you to figure out what to do.

Search for "/ban" in modGameLogic (I think) to see what the text command does. Then compare it to the code below, which is for banning a player with a text box, and a button.

Code:
Private Sub cmdBanPlayer_Click()
    If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
        Call SendBan(Trim(txtBanPlayer.Text))
    End If
End Sub

And now find the "/mapeditor" command, and compare it to this button's code:

Code:
Private Sub cmdEdit_Click()
    Call SendRequestEditMap
End Sub

Private Sub cmdEdit_Click() comes from my Mapreport Upgrage tutorial.


Re: Programming an Admin panel - Nean - 14-09-2008

Sonire Wrote:Just working on converting a lot of the admin's text commands into buttons and what not myself Smile

Here's some things I've got in my source. Shoudn't be too hard for you to figure out what to do.

Search for "/ban" in modGameLogic (I think) to see what the text command does. Then compare it to the code below, which is for banning a player with a text box, and a button.

Code:
Private Sub cmdBanPlayer_Click()
    If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
        Call SendBan(Trim(txtBanPlayer.Text))
    End If
End Sub

And now find the "/mapeditor" command, and compare it to this button's code:

Code:
Private Sub cmdEdit_Click()
    Call SendRequestEditMap
End Sub

Private Sub cmdEdit_Click() comes from my Mapreport Upgrage tutorial.

Dude you kick so much ass! Thanks a lot. I had the right idea for the edit buttons, I just didn't put call beforehand, and I had to make it chance the width for the mapeditor. I also got the ban and kick button done, but not the mute yet, because I haven't programmed that in. Any suggestions on how to go about programming a mute command?


Re: Programming an Admin panel - Doomy - 14-09-2008

lol ya i had trouble for this too
i got like 15 buttons now


Re: Programming an Admin panel - Rian - 14-09-2008

For the mute command, I would add a variable to the PlayerRec: Mute As Byte

Then you'll neet to create a packet (like the ones your admin panel buttons send)

Server side, where you receive the packet, you'll need to check

Code:
If GetPlayerMute(Index) = 0 Then
    SetPlayerMute(Index, 1) ' Mute Them
Else
    SetPlayerMute(Index, 0) ' Unmute Them
End If


And this somewhere

Code:
Function GetPlayerMute(ByVal Index As Long) As Long
    GetPlayerMute = Player(Index).Char(Player(Index).CharNum).Mute
End Function

Sub SetPlayerMute(ByVal Index As Long, ByVal Mute As Byte)
    Player(Index).Char(Player(Index).CharNum).Mute = Mute
End Sub

Then, for which ever msg type you wanna mute, you just add a check

Code:
If GetPlayerMute(Index) = 1 then
    Don't Global Message
Else
    Do Global Message
End If

That should get you on the right path. If you have trouble with packets, I'll explain more.


Re: Programming an Admin panel - Nean - 14-09-2008

I think I understand everything but
Code:
If GetPlayerMute(Index) = 0 Then
    SetPlayerMute(Index, 1) ' Mute Them
Else
    SetPlayerMute(Index, 0) ' Unmute Them
End If



Re: Programming an Admin panel - Doomy - 14-09-2008

i nvr even thought of muting someone lol


Re: Programming an Admin panel - Nean - 16-09-2008

I decided to take another go at this, but I'm uber failing. So far for the packet, I've just been editing the kickplayer packet, like a n00b, and it doesn't go so well..

[code]Case CMutePlayer
' Prevent hacking
If GetPlayerAccess(Index)


Re: Programming an Admin panel - Rian - 16-09-2008

[code]If GetPlayerAccess(n)


Re: Programming an Admin panel - Nean - 17-09-2008

Crap. So I would go into playerrec, and add
Code:
Mute As Boolean
. Then I would go, and add CMutePlayer, to everything, and then just like in the kick packet, I would go
Code:
SendPlayerMute
, and then have a check to see if Boolean = Yes, before global chat, then to exit sub.... Correct?


Re: Programming an Admin panel - Egon - 17-09-2008

Or you could just use this and just mess around with the Return part in HandleKey:

Mute = 0 ' Not Muted
Mute = 1 ' Player Mute
Mute = 2 ' Global Mute


Re: Programming an Admin panel - Rian - 17-09-2008

Doing like Egon suggested would be better. More options than just true or false, and using a byte will keep your account files just that much smaller