Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Using these in sadscript?


JayT
 Share

Recommended Posts

hey ive added some party stuff into clsCommands in the source and i wanna know if i can use these:
Player(Index)
LeaderIndex
Player(MemberIndex)
MemberIndex

in sadscript. they are in the party subs in the server source and seem to be of good use for those subs so would i be able to use them now ive added all the party info into clsCommands?
Link to comment
Share on other sites

```
Public Sub SetPMember(ByVal LeaderIndex As Long, ByVal MemberIndex As Long)
    Dim I As Integer

    For I = 1 To MAX_PARTY_MEMBERS
        If Player(LeaderIndex).Party.Member(I) = 0 Then
            Player(LeaderIndex).Party.Member(I) = MemberIndex
            Exit For
        End If
    Next I

    Player(MemberIndex).Party.Leader = LeaderIndex

    For I = 1 To MAX_PARTY_MEMBERS
        If Player(LeaderIndex).Party.Member(I) > 0 Then
            Call UpdateParty(Player(LeaderIndex).Party.Member(I))
        End If
    Next I
End Sub
```
thats one of the subs thats now available. hence were i got leaderindex from and its in another 1 aswell
Link to comment
Share on other sites

@Snoop:

> bump ;)

No need for bumping. The topic's barely even 6 hours old.

No, Leaderindex and Memberindex won't work in Sadscript. Those are parameters, not global variables. They are two entirely different things. Also, Player() will not work in Sadscript, because Player is not a function; it is a Type. You'd have to implement the Type in Sadscript, which is VBScript. In effect, you'd have to rewrite the Sadscript parsing code to handle bridging Types to Objects.

So no, none of these will work in Sadscript.
Link to comment
Share on other sites

i kinda get what the sub is doing in this one but how do i call it?
```
Call SetPMember(LeaderIndex, MemberIndex)
```like that? and yes they do work as i can get a reaction out of the GetPMember function when i call it in sadscript but i dont get what its setting each member as in the party. is the leader gonna be LeaderIndex? and the member MemberIndex? so will the leader be 1 and the member be 2,3,4? because when i have 2 players in a party and i call this function from the server source in clsCommands:
```
Function GetPLeader(ByVal Index As Long) As Long
    GetPLeader = Player(Index).Party.Leader
End Function
```like this in sadscript:
```
If GetPLeader(Index) = 1 Then
Call PlayerMsg(Index, "THIS WORKS!!", WHITE)
End If
```and that works for both players. but when i add this aswell:
```
If GetPLeader(Index) = 2 Then
Call PlayerMsg(Index, "THIS WORKS!!", WHITE)
End If
```that works aswell! but because i only have 2 players in the party = 0, 3 or 4 doesnt work. so i dont get how it seperates the leader from the members in the party, the reason im trying to get this work is because im trying to make the party system interact with sadscript for a game that has boss fights, so when the boss is killed it i can give a item/exp or send a msg e.t.c to the party leader and the rest of the party. lol wow sorry for rambling on ;)
Link to comment
Share on other sites

The problem is a lack of fundamental understanding behind scripting. The parameter name is LeaderIndex. Just because a function has that parameter does not mean that that value is a global variable. It's just a name that stands in for the value in that sub ONLY. LeaderIndex is replaced by whatever value you specify.

For instance, when you call "SetPMember(1, 2)", you are making Player 2 a member of Player 1's party. Notice the lack of LeaderIndex or MemberIndex when calling this. 1 stands in for LeaderIndex, and 2 stands in for MemberIndex. When the function runs through the server, only then does it use the actual parameter name, but the value of that parameter is what you set when you called the sub.

Now, to explain the party system. The functions will return the Index number of another player. "GetPLeader" returns the index of the player leading the group. You generally DON'T want to compare this to numeric values, as you do not know who has what index number at any given time. "GetPMember" will return the values of each of the party members' indices. In this way, you can find the index numbers of all the party members, which you can use however you feel. Here's an example:

```
Sub ShowParty(index)

MaxP = CInt(GetVar("data.ini", "MAX", "MAX_PARTY_MEMBERS"))

for i = 1 to MaxP
    If GetPMember(index, i) <> 0 Then
        Call PlayerMsg(index, Cstr(i) & ": " & GetPlayerName(GetPMember(index, i)), BRIGHTGREEN)
    End If
next

Call PlayerMsg(index, "Leader: " & GetPlayerName(GetPLeader(index)), BRIGHTGREEN)

End Sub
```
Take a look at some of the syntax there and try to see what I've done.
Link to comment
Share on other sites

would that code work that you posted? i was looking at making a new function like so:
```
Function GetPartyLeader(ByVal Index As Long)
Player(Index).Party.Leader = Index
End Function
```but im failing like hell lol. im a persistant guy though so i will not let this go until i figure the party system out plus im still kinda new to vb :) so sorry for being a noob. so with that function in clsCommands i tried:
```
Case "/123"
If GetPartyLeader(Index) Then
Call PlayerMsg(Index, "THIS WORKS!!", WHITE)
Else
Call PlayerMsg(Index, "WRONG!", WHITE)
End If
Exit Sub
```but still got wrong. i appreciate all the help your giving me and the time your taking to explain. but if i can seperate the leader from the members i will be happy for now :) lol
Link to comment
Share on other sites

```
Case "/123"
If GetPLeader(Index) = index Then
Call PlayerMsg(Index, "THIS WORKS!!", WHITE)
Else
Call PlayerMsg(Index, "WRONG!", WHITE)
End If
Exit Sub
```
Notice these changes. I compared the leader index from GetPLeader to Index. Index is the current player, almost always, unless you manually change it. Now, what this says is if the party leader is you (index), then show "THIS WORKS!!", else, show "WRONG!".
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...