Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How Could I...
#1
I'm trying to make a code that checks a player's inventory, and if they have a certain item in their inventory and they type something, then it activates. I hope that makes sense...But I don't know how to check a player's inventory and check the items they have's names.

Can anyone tell me how to do that?
Reply
#2
Never used HasItem before...So would this work? I'm use MS4, and I have this in modHandleData

I'm still learning VB6, so please excuse my mistakes. Up till now, I've just edited other people's code to fit what I need. This is my first code that I've started from scratch...
Reply
#3
So then this should work, correct? Thanks for your help. And it'll check if they have the item that is number 200 right?

(this is in modGameLogic in the Client)
Code:
' AIDA command
        If Mid$(MyText, 1, 5) = "/aida" Then
            MyText = Mid$(MyText, 5, Len(MyText) - 4)
            Call SendData(CAida & END_CHAR)
        End If
            MyText = ""
        Exit Sub
    End If

(this is in modHandleData in the server)
Code:
' :::::::::::::::::
        ' :: AIDA Packet ::
        ' :::::::::::::::::
        Case CAida
        If HasItem(Index, 200) Then
            Call Aida(Index)
        Exit Sub
Reply
#4
Alrighty...Thanks allot.

Now, when I try to compile the code. It's giving me an error on this...It was working fine before I added the AIDA code, I added the AIDA code above the CKillPlayer code, if that matters. It's highlighting "Case CKillPlayer" and giving me this error "Case Without Select Case". What do I do to fix it? It was working fine before...

Code:
' ::::::::::::::::::::::::
        ' :: Kill Player Packet ::
        ' ::::::::::::::::::::::::
Case CKillPlayer
' Prevent hacking
If GetPlayerAccess(Index) < ADMIN_CREATOR Then
Call HackingAttempt(Index, "Admin Cloning")
Exit Sub
End If

n = FindPlayer(Parse(1))

If n  Index Then
If n > 0 Then
'Sends messages out
Call PlayerMsg(n, "You have been killed by an admin.", BrightRed)
Call GlobalMsg(GetPlayerName(n) & " has been killed by an admin.", BrightRed)
'Warp to starting map
Call PlayerWarp(n, START_MAP, START_X, START_Y)
Call SetPlayerPK(Index, NO)
Else
Call PlayerMsg(Index, "Player is not online.", White)
End If
Else
Call PlayerMsg(Index, "You cannot kill yourself!", White)
End If

Exit Sub
Reply
#5
Thank you once again, that fixed it...But now I have a new problem when I compile it. lol

I'm getting an error in this part of my code.
Code:
Public Sub Aida()
    SetPlayerVital(Index, HP) = GetPlayerMaxVital(Index, HP) + 5000
End Sub

It's highlighting "SetPlayerVital(Index, HP) =" and saying "Argument not optional". I've never gotten that error before, so I have no clue what it means. =/
Reply
#6
DarkC Wrote:Thank you once again, that fixed it...But now I have a new problem when I compile it. lol

I'm getting an error in this part of my code.
Code:
Public Sub Aida()
    SetPlayerVital(Index, HP) = GetPlayerMaxVital(Index, HP) + 5000
End Sub

It's highlighting "SetPlayerVital(Index, HP) =" and saying "Argument not optional". I've never gotten that error before, so I have no clue what it means. =/

Try putting MyIndex, instead of index.
Reply
#7
I put MyIndex, and it's giving me the same error.
Reply
#8
What am I doing wrong? I looked and I don't get it...How can I tell what the correct way of using it is?
Reply
#9
Argument not optional - Check what you need to pass to that function
Reply
#10
Then like this? Sorry about all the trouble. Sad

Code:
Public Sub Aida()
    SetPlayerVital(Index, HP, GetPlayerMaxVital) = 5000
End Sub
Reply
#11
Well when I don't have a = in there somewhere, it makes the text read and says it exspects a = .
Reply
#12
Ok...I added call to it, and now it's highlighting GetPlayerMaxVital and giving the same error. :oops:
Reply
#13
Then do the same thing to fix it.
Reply
#14
But how can I have it be Called when it's in the parentheses? Because doesn't it have to be there? Because that's where the Value is supposed to be in the SetPlayerVital...
Reply
#15
Functions don't need a call. You can just do

GetPlayerMaxVital(index, whatever, whatever)
Reply
#16
Does your code still look like this?
Code:
Public Sub Aida()
    SetPlayerVital(Index, HP, GetPlayerMaxVital) = 5000
End Sub

If so, look at the SetPlayerVital sub.

Code:
Sub SetPlayerVital(ByVal Index As Long, ByVal Vital As Vitals, ByVal Value As Long)

Just that part is all that really matters.

You are setting it to the Index (which would be your player number), which vital do you want to set, then the value you want to set it to. Make sense?

So if you want to set your vital hp to 5000 then your code should look like this.

Code:
Public Sub Aida()
    Call SetPlayerVital(Index, Vitals.HP, 5000)
End Sub

I am not exactly sure what you are trying to do?
Reply
#17
Never mind! Thank you, Anthony. That helped me perfectly.

Thank you all for your help.
Reply
#18
Ok...I was able to compile it without any errors, but it's not working. I'm typing "/aida" and it doesn't do anything. It's not even getting rid of the text after I type it and press enter.

Here is my code so far...

Code:
' AIDA command
        If Mid$(MyText, 1, 5) = "/aida" Then
            MyText = Mid$(MyText, 5, Len(MyText) - 4)
            Call SendData(CAida & END_CHAR)
        End If
            MyText = ""
        Exit Sub

Code:
' :::::::::::::::::
        ' :: AIDA Packet ::
        ' :::::::::::::::::
        Case CAida
        If HasItem(Index, 200) Then
            Call Aida
        End If
    Exit Sub

Code:
Public Sub Aida()
    Call SetPlayerVital(Index, HP, GetPlayerMaxVital(Index, Vitals.HP, 5000))
End Sub

What have I done wrong? Sorry for all the trouble...
Reply
#19
On the aida packet, try putting the exit sub, before the end if.
Reply
#20
Just tried that, didn't change anything. It's doing the exact same thing...
Reply
#21
Ok...Well if you could figure out why it isn't working, that would be wonderful. Thank you so much.

Also, I changed this...

Code:
' AIDA command
        If Mid$(MyText, 1, 5) = "/aida" Then
            MyText = Mid$(MyText, 5, Len(MyText) - 4)
            Call SendData(CAida & END_CHAR)
            MyText = vbNullString
            frmMirage.txtMyChat.Text = vbNullString
        Exit Sub
    End If

And now when I type "/aida" it gets rid of the text after I press enter. But it doesn't do anything else.
Reply
#22
I still don't see what you are trying to set your HP value to?

Code:
Function GetPlayerMaxVital(ByVal Index As Long, ByVal Vital As Vitals) As Long

There are only an Index and a Vital as Vitals in the function. Yours is looking to select something else as well. If you want to set your players hit points to whatever your max hit points are plus 5000 it should be like this.

Code:
Call SetPlayerVital(Index, Vitals.HP, GetPlayerMaxVital(Index, Vitals.HP) + 5000)

Do you understand how that works? You cannot change the MaxHP value in a default MS because it is calculated from your players stats and it's classes stats.
Reply
#23
Anthony Wrote:I still don't see what you are trying to set your HP value to?

Code:
Function GetPlayerMaxVital(ByVal Index As Long, ByVal Vital As Vitals) As Long

There are only an Index and a Vital as Vitals in the function. Yours is looking to select something else as well. If you want to set your players hit points to whatever your max hit points are plus 5000 it should be like this.

Code:
Call SetPlayerVital(Index, Vitals.HP, GetPlayerMaxVital(Index, Vitals.HP) + 5000)

Do you understand how that works? You cannot change the MaxHP value in a default MS because it is calculated from your players stats and it's classes stats.

That's exactly what I'm trying to do. I want to set the player's max HP + 5000. And I think I get how that works...So the code you just showed me, is correct? I'll have to try it later when I get back home from school.
Reply
#24
DarkC Wrote:That's exactly what I'm trying to do. I want to set the player's max HP + 5000. And I think I get how that works...So the code you just showed me, is correct? I'll have to try it later when I get back home from school.

Anthony Wrote:You cannot change the MaxHP value in a default MS because it is calculated from your players stats and it's classes stats.
Reply
#25
How could I increase their MaxHP then?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)