Mirage Source
http://www.miragesource.net/forums/

My Code Not Working...
http://www.miragesource.net/forums/viewtopic.php?f=201&t=3125
Page 1 of 11

Author:  Daemonblade777 [ Thu Dec 06, 2007 7:26 am ]
Post subject:  My Code Not Working...

The code I made tonight isn't working. When I try to compile the Server.exe with the code I made, it gives me errors. I tried fixing them but I just don't understand how to. I would really appreciate if some one could help me fix this code up...I put the code in the ModServerTCP if you needed to know that.

Code:
Function DeletePlayer(ByVal PlayerAccess As Long, index As Long, DeleteCharacter As Long, SaveCharacter As Long, SaveAccount As Long, AlertMsg As String, Player As Long)
    If "/delete(PlayerName)" Then
    If PlayerAccess <= 4 Then
        Call DeleteCharacter(index)
        Call SaveCharacter(index)
        Call SaveAccount(index)
        Call AlertMsg(Player, "You have been deleted.")
    End If
End Function

Author:  Beres [ Thu Dec 06, 2007 8:55 am ]
Post subject:  Re: My Code Not Working...

First off, add that code into your client. Preferably in the Sub HandleKeypresses(ByVal KeyAscii As Integer).

Ok now change:
Code:
If "/delete(PlayerName)" Then
    If PlayerAccess <= 4 Then
        Call DeleteCharacter(index)
        Call SaveCharacter(index)
        Call SaveAccount(index)
        Call AlertMsg(Player, "You have been deleted.")
    End If
End If

To
Code:
If LCase(Mid(MyText, 1, 7)) = "/delete" Then
    If Len(MyText) > 7 Then
        MyText = Mid(MyText, 9, Len(MyText) - 7)
        Call SendDeleteChar(MyText)
        Call SendSaveChar(MyText)
        Call SendSaveAcc(MyText)
    End If

    MyText = ""
    Exit Sub
End If

Then of course the Call Send stuff is what you need to code in. They will obviously send a packet to the server with the players name and then have the server delete the player. I just came out with that code on the top my head, so let me know whats up.

Author:  Rezeyu [ Thu Dec 06, 2007 8:59 am ]
Post subject:  Re: My Code Not Working...

Well... that's alot of extra work.

None of the chat is sent through handle keypresses, so I'm not sure why he'd do that either.
and Mirage doesn't have SaveAcc.

He just needs to add it into the chat commands, and when the packet is received server side, call sub DelChar.

Author:  Beres [ Thu Dec 06, 2007 9:02 am ]
Post subject:  Re: My Code Not Working...

Yeah i know saveacc isnt there, i just made it up to give him an idea. And I just wrote that because in that sub I showed has all the chat commands (in MSE 1). So I thought I would add it there.

Author:  Rezeyu [ Thu Dec 06, 2007 9:05 am ]
Post subject:  Re: My Code Not Working...

Just Call Menu_State_Delchar.

There's already a packet in place and everything.
Just change the server side part to stop checking if they aren't playing.


I thought you wrote Keydown, that's why I was confused, sice that's only used for attack/running.

Author:  Beres [ Thu Dec 06, 2007 9:12 am ]
Post subject:  Re: My Code Not Working...

Quote:
Just Call Menu_State_Delchar.

I totally forgot about that lol >.> But yeah. Anyway from what I seen what he wrote, you dont even need a function for that. AND thats not even how you use a function lol. But I think he got our point. Do what Rezeyu said and delete the char with that menu state. :)

Author:  Lea [ Thu Dec 06, 2007 1:10 pm ]
Post subject:  Re: My Code Not Working...

But if you do it with the menustate, dont you only delete your character?

Author:  Rezeyu [ Thu Dec 06, 2007 1:37 pm ]
Post subject:  Re: My Code Not Working...

Well since he was going by playername, isn't that what he wanted?

:|

Author:  Daemonblade777 [ Thu Dec 06, 2007 7:49 pm ]
Post subject:  Re: My Code Not Working...

I want the code to delete whatever player the Admin wants to delete, then pop up a message to the player that was deleted saying "You have been deleted.".

Example:

I want to delete a player name Zain.
/delete Zain
The server deletes the player named Zain.
The player that was deleted receives a pop up message saying "You have been deleted.".

Also, I added the code you gave me Beres and it keeps saying "Sub or Function Not Defined" on the "Call SendDeleteChar" part of the code. I tried to define it but it didn't work.

Author:  Beres [ Thu Dec 06, 2007 9:02 pm ]
Post subject:  Re: My Code Not Working...

Dude thats not the right call function, I was giving you an example of how to do the /delete code. lol

Author:  Lea [ Thu Dec 06, 2007 9:04 pm ]
Post subject:  Re: My Code Not Working...

His code was incomplete, you can implement that function if you wish.

However, can I comment that I wouldn't add this feature. If there is something in the game that would cause a player to be deleted, have the computer and only the computer do it. When you get into letting people control who suffers, there becomes this "power" issue.

Author:  Beres [ Thu Dec 06, 2007 9:05 pm ]
Post subject:  Re: My Code Not Working...

True.. And also, if you want to delete him, just kick him and then delete his name from the server. But, if you want the command, I could whip it up for you.

Author:  Daemonblade777 [ Thu Dec 06, 2007 9:27 pm ]
Post subject:  Re: My Code Not Working...

If you don't mind Beres please do. I could probably learn something from the code you make. Also, I will be the only one with the power to delete. And I am only putting this in the game so then I don't have to go through the hassle of deleting his character from the files.

Also I made another code based on the one you showed me. Would this work? Sorry for the hassle of this.

Code:
' Jail command
If LCase(Mid(MyText, 1, 7)) = "/jail" Then
    If Len(MyText) > 7 Then
    MyText = Mid(MyText, 9, Len(MyText) - 7)
    Call SetPlayerMap(Index, 100)
    Call SetPlayerX(Index, 10)
    Call SetPlayerY(Index, 12)
    Call Msg(Index, "You have been put into Jail.", 1)
    Call GlobalMsg(Index, "(PlayerName) has been sent to jail.")
  End If
 
  MyText = ""
  Exit Sub
End If

Author:  Beres [ Thu Dec 06, 2007 10:15 pm ]
Post subject:  Re: My Code Not Working...

lol..
Code:
If LCase(Mid(MyText, 1, 7)) = "/jail" Then

Count the amount of characters of /jail. Its 5.. So change it to
Code:
If LCase(Mid(MyText, 1, 5)) = "/jail" Then

Anyway, I will write you the code for this in a few, when I get back..

Author:  Daemonblade777 [ Thu Dec 06, 2007 10:16 pm ]
Post subject:  Re: My Code Not Working...

Oops, lol. And thank you very much.

Author:  Lea [ Thu Dec 06, 2007 10:44 pm ]
Post subject:  Re: My Code Not Working...

This code is client side, so you can't really do anything to other players. You need to send a packet to the server, and have the server determine if A) You can move them to jail, and B) They can be moved to jail then do it if appropriate.

Author:  Daemonblade777 [ Thu Dec 06, 2007 10:47 pm ]
Post subject:  Re: My Code Not Working...

So then would this work? If not, mind explaining why?

Code:
' Jail command
If LCase(Mid(MyText, 1, 7)) = "/jail" Then
    If Len(MyText) > 7 Then
    MyText = Mid(MyText, 9, Len(MyText) - 7)
    Call SendPlayerMap(Index, 100)
    Call SendPlayerX(Index, 10)
    Call SendPlayerY(Index, 12)
    Call Msg(Index, "You have been put into Jail.", 1)
    Call GlobalMsg(Index, "(PlayerName) has been sent to jail.")
  End If
 
  MyText = ""
  Exit Sub
End If

Author:  Lea [ Thu Dec 06, 2007 10:53 pm ]
Post subject:  Re: My Code Not Working...

No, it wouldn't work.

SetPlayerX and SetPlayerY are client side functions, and they do exist so it was good that you thought those would do what you want them to do.

However, those are used client side, when other players move. If you were to call that, the player would move ONLY to you, and they themselves wouldnt move, nor would they move for anyone else.

To get things to happen to players, you need to send the command to the server. You can see this happening in what's called a Packet. Mirage uses string packets, and you can probably determine how to write and send a packet if you just search the word "Packet"

Similarily, server side, you need to receive the packet, this is done in modHandleData, in sub HandleData. You should be able to figure this out, too, if you think about it.

So your jail command should construct a packet containing the necessary information (in this case, it would need a name and the index number of the player you want to jail) and send it.

The server would then receive the packet, check that you have the authority to jail someone, check that the person you're jailing is indeed online, and then it would move the player to the jail, and if you want it would say a global message, or a private message to the jailed player saying they were jailed.

get it?

Author:  Daemonblade777 [ Thu Dec 06, 2007 11:10 pm ]
Post subject:  Re: My Code Not Working...

That makes sense thanks. I'll look "Packet" up.

Author:  Daemonblade777 [ Thu Dec 06, 2007 11:29 pm ]
Post subject:  Re: My Code Not Working...

Sorry for the double post...But I tried making a packet and I think I have it all screwed up. lol And thank you all for your help.

Code:
'     :::::::::::::::::
'     :: Jail Packet ::
'     :::::::::::::::::
    If (LCase(Parse(0)) = "/jail") Then
        Player = Val(Parse(1))
    If GetPlayerAccess <= 4 Then
        Player = Map(Index, 100)
        Player = MapX(Index, 10)
        Player = MapY(Index, 10)
    End If
End Sub

Author:  Beres [ Thu Dec 06, 2007 11:42 pm ]
Post subject:  Re: My Code Not Working...

Good lord lol!! Its ok though, because you still learning. Now I got to run to school in a few, but I would change the operator you got there..
Code:
If GetPlayerAccess <= 4 Then

First off, that means anyone with an access of 4 and below can use it. So if I was access 0, I could jail someone. Make it >=. Well, I will help you with more in a few, do you have msn or yahoo?

Author:  Daemonblade777 [ Thu Dec 06, 2007 11:52 pm ]
Post subject:  Re: My Code Not Working...

Yes, my MSN is zainisdemonic666@hotmail.com . And I'll change that right now. lol

Author:  Beres [ Fri Dec 07, 2007 3:13 am ]
Post subject:  Re: My Code Not Working...

i at school right now.. i add u when i get home

Author:  Lea [ Fri Dec 07, 2007 4:03 am ]
Post subject:  Re: My Code Not Working...

Use the playerwarp function server side.

Author:  Daemonblade777 [ Fri Dec 07, 2007 7:17 am ]
Post subject:  Re: My Code Not Working...

Beres I don't actually need you to make the code now. Rezeyu helped me allot and now I have the /save and /delete codes working. I have a basic understanding of Packets now as well.

Page 1 of 11 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/