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

Make Guild error


DarkDino
 Share

Recommended Posts

Hello Eclipse,  have one problem whit Guild System (With Multiple Characters) When i MAKE A GUILD. In the Public Sub MakeGuild(Founder_Index As Long, Name As String, Tag As String) when i use .Char(TempPlayer(index).CurChar) Error "**Subscript out of range**". The problem is in Founder_Index value is 1 and the CurChar value is 2 D:!. How to fix this?  :(?

All Code in Sub MakeGuild

```
Public Sub MakeGuild(Founder_Index As Long, Name As String, Tag As String)
Dim tmpGuild As GuildRec
Dim GuildSlot As Long
Dim GuildFileId As Long
Dim I As Integer
Dim b As Integer
Dim itemAmount As Long

If Player(Founder_Index).GuildFileId > 0 Then
PlayerMsg Founder_Index, "You must leave your current guild before you make this one!", BrightRed
Exit Sub
End If

GuildFileId = Find_Guild_Save
GuildSlot = FindOpenGuildSlot

If Not isPlaying(Founder_Index) Then Exit Sub

'We are unable for an unknown reason
If GuildSlot = 0 Or GuildFileId = 0 Then
PlayerMsg Founder_Index, "Unable to make guild, sorry!", BrightRed
Exit Sub
End If

If Name = "" Then
PlayerMsg Founder_Index, "Your guild needs a name!", BrightRed
Exit Sub
End If

' Check level
If GetPlayerLevel(Founder_Index) < Options.Buy_Lvl Then
PlayerMsg Founder_Index, "You need to be level " & Options.Buy_Lvl & " to make a guild!", BrightRed
Exit Sub
End If

' Check if item is required
If Not Options.Buy_Item = 0 Then
'Get item amount
itemAmount = HasItem(Founder_Index, Options.Buy_Item)

' Item Req
If itemAmount = 0 Or itemAmount < Options.Buy_Cost Then
PlayerMsg Founder_Index, "You need " & Options.Buy_Cost & " " & Item(Options.Buy_Item).Name & " to join a guild!", BrightRed
Exit Sub
End If

'Take Item
TakeInvItem Founder_Index, Options.Buy_Item, Options.Buy_Cost
End If

GuildData(GuildSlot).Guild_Name = Name
GuildData(GuildSlot).Guild_Tag = Tag
GuildData(GuildSlot).Guild_Color = 4
GuildData(GuildSlot).Guild_MOTD = "Welcome to the " & Name & "!"
GuildData(GuildSlot).In_Use = True
GuildData(GuildSlot).Guild_Fileid = GuildFileId
GuildData(GuildSlot).Guild_Members(1).Founder = True
GuildData(GuildSlot).Guild_Members(1).User_Login = Player(Founder_Index).Login
GuildData(GuildSlot).Guild_Members(1).User_Name = Player(Founder_Index).Char(TempPlayer(index).CurChar).Name
GuildData(GuildSlot).Guild_Members(1).Rank = MAX_GUILD_RANKS
GuildData(GuildSlot).Guild_Members(1).Comment = "Guild Founder"
GuildData(GuildSlot).Guild_Members(1).Used = True
GuildData(GuildSlot).Guild_Members(1).Online = True
GuildData(GuildSlot).Guild_Logo = rand(1, MAX_GUILD_LOGO)

'Set up Admin Rank with all permission which is just the max rank
GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).Name = "Leader"
GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).Used = True

For b = 1 To MAX_GUILD_RANKS_PERMISSION
GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).RankPermission(b) = 1
Next b

'Set up rest of the ranks with default permission
For I = 1 To MAX_GUILD_RANKS - 1
GuildData(GuildSlot).Guild_Ranks(I).Name = "Rank " & I
GuildData(GuildSlot).Guild_Ranks(I).Used = True

For b = 1 To MAX_GUILD_RANKS_PERMISSION
GuildData(GuildSlot).Guild_Ranks(I).RankPermission(b) = Default_Ranks(b)
Next b

Next I

Player(Founder_Index).Char(TempPlayer(index).CurChar).GuildFileId = GuildFileId
Player(Founder_Index).Char(TempPlayer(index).CurChar).GuildMemberId = 1
TempPlayer(Founder_Index).tmpGuildSlot = GuildSlot

'Save
Call SaveGuild(GuildSlot)
Call SavePlayer(Founder_Index)

'Send to player
Call SendGuild(False, Founder_Index, GuildSlot)

'Inform users
PlayerMsg Founder_Index, "Guild Successfully Created!", BrightGreen
PlayerMsg Founder_Index, "Welcome to " & GuildData(GuildSlot).Guild_Name & ".", BrightGreen
PlayerMsg Founder_Index, "Your Guild Logo Randomly [" & GuildData(GuildSlot).Guild_Logo & "].", BrightGreen

PlayerMsg Founder_Index, "You can talk in guild chat with: ;Message ", BrightRed

'Update user for guild name display
Call SendPlayerData(Founder_Index)

End Sub
Public Function CheckGuildPermission(index As Long, Permission As Integer) As Boolean
Dim GuildSlot As Long

'Get slot
GuildSlot = TempPlayer(index).tmpGuildSlot

'Make sure we are talking about the same person
If Not GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).User_Login = Player(index).Login Then
'Something went wrong and they are not allowed to do anything
CheckGuildPermission = False
Exit Function
End If

'If founder, true in every case
If GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Founder = True Then
CheckGuildPermission = True
Exit Function
End If

'Make sure this slot is being used aka they are still a member
If GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Used = False Then
'Something went wrong and they are not allowed to do anything
CheckGuildPermission = False
Exit Function
End If

'Check if they are able to
If GuildData(GuildSlot).Guild_Ranks(GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Rank).RankPermission(Permission) = 1 Then
CheckGuildPermission = True
Else
CheckGuildPermission = False
End If

End Function

```
Link to comment
Share on other sites

When i put (Founder_Index) have other error in SubCheckSkills

```
Sub CheckSkills(ByVal index As Long, Optional ByVal SaveIfNeeded As Boolean = True)
Dim I As Integer
Dim Save As Boolean

If index < 1 Or index > MAX_PLAYERS Then Exit Sub
Save = False
For I = 1 To MAX_SKILLS
If Player(index).Char(TempPlayer(index).CurChar).Skills(I).Level = 0 Then
Player(index).Char(TempPlayer(index).CurChar).Skills(I).Level = 1
Save = True
End If

If Player(index).Char(TempPlayer(index).CurChar).Skills(I).EXP_Needed = 0 Then
Player(index).Char(TempPlayer(index).CurChar).Skills(I).EXP_Needed = GetPlayerNextSkillLevel(index, I)
Save = True
End If
Next I
If Save And SaveIfNeeded Then Call SavePlayer(index)
End Sub

```
Zeno help me to fix the error in SubCheckSkills. You sure (Founder_Index) fix it? Thanks!.
Link to comment
Share on other sites

```
Private Type PlayerRec
' Account
Login As String * ACCOUNT_LENGTH
Password As String * NAME_LENGTH

' Access
Access As Byte

' Characters
Char(1 To MAX_PLAYER_CHARACTERS) As CharRec
End Type
```

```
Private Type CharRec
' General
Name As String * ACCOUNT_LENGTH
Sex As Byte
Class As Long
Sprite As Long
Level As Byte
EXP As Long
Access As Byte
PK As Byte

' Guilds
GuildFileId As Long
GuildMemberId As Long

' Admins
Visible As Long

' Vitals
Vital(1 To Vitals.Vital_Count - 1) As Long

' Stats
stat(1 To Stats.Stat_Count - 1) As Long
POINTS As Long

' Worn equipment
Equipment(1 To Equipment.Equipment_Count - 1) As Long

' Inventory
Inv(1 To MAX_INV) As PlayerInvRec
Spell(1 To MAX_PLAYER_SPELLS) As Long

' Hotbar
Hotbar(1 To MAX_HOTBAR) As HotbarRec

' Position
Map As Long
x As Byte
y As Byte
Dir As Byte

Switches(0 To MAX_SWITCHES) As Byte
Variables(0 To MAX_VARIABLES) As Long
PlayerQuest(1 To MAX_QUESTS) As PlayerQuestRec

Spawn As PlayerSpawnRec
' Combat
Combat(1 To MAX_COMBAT) As CombatRec

' K/D
MyKills As Long
MyDeaths As Long

'Walkthrough
WalkThrough As Byte

'Kill Event
TopKills As Long

'Follow feature
Follower As Long

'Skills
Skills(1 To MAX_SKILLS) As SkillRec

'Friends
Friends As FriendRec

'Hairs
Hair As Long
HairTint As Long

'Daily
DailyValue As Long

End Type

```
PlayerRec and CharRec
Link to comment
Share on other sites

```
Private Type SkillRec
Level As Long
EXP As Long
EXP_Needed As Long
End Type

```
```
Public Type TempPlayerRec
' Non saved local vars
buffer As clsBuffer
InGame As Boolean
AttackTimer As Long
DataTimer As Long
DataBytes As Long
DataPackets As Long
targetType As Byte
target As Long
GettingMap As Byte
SpellCD(1 To MAX_PLAYER_SPELLS) As Long
InShop As Long
StunTimer As Long
StunDuration As Long
InBank As Boolean
' trade
TradeRequest As Long
InTrade As Long
TradeOffer(1 To MAX_INV) As PlayerInvRec
AcceptTrade As Boolean
' dot/hot
DoT(1 To MAX_DOTS) As DoTRec
HoT(1 To MAX_DOTS) As DoTRec
' spell buffer
spellBuffer As SpellBufferRec
' regen
stopRegen As Boolean
stopRegenTimer As Long
' party
inParty As Long
partyInvite As Long
' guild
tmpGuildSlot As Long
tmpGuildInviteSlot As Long
tmpGuildInviteTimer As Long
tmpGuildInviteId As Long

EventMap As EventMapRec
EventProcessingCount As Long
EventProcessing() As EventProcessingRec
Buffs(1 To 10) As Long
BuffTimer(1 To 10) As Long
BuffValue(1 To 10) As Long
CurChar As Byte
End Type

```
Link to comment
Share on other sites

> Hello Eclipse,  have one problem whit Guild System (With Multiple Characters) When i MAKE A GUILD. In the Public Sub MakeGuild(Founder_Index As Long, Name As String, Tag As String) when i use .Char(TempPlayer(index).CurChar) Error "**Subscript out of range**". The problem is in Founder_Index value is 1 and the CurChar value is 2 D:!. How to fix this?  :(?
>
> All Code in Sub MakeGuild
>
> ```
> Public Sub MakeGuild(Founder_Index As Long, Name As String, Tag As String)
> Dim tmpGuild As GuildRec
> Dim GuildSlot As Long
> Dim GuildFileId As Long
> Dim I As Integer
> Dim b As Integer
> Dim itemAmount As Long
>
> If Player(Founder_Index).GuildFileId > 0 Then
> PlayerMsg Founder_Index, "You must leave your current guild before you make this one!", BrightRed
> Exit Sub
> End If
>
> GuildFileId = Find_Guild_Save
> GuildSlot = FindOpenGuildSlot
>
> If Not isPlaying(Founder_Index) Then Exit Sub
>
> 'We are unable for an unknown reason
> If GuildSlot = 0 Or GuildFileId = 0 Then
> PlayerMsg Founder_Index, "Unable to make guild, sorry!", BrightRed
> Exit Sub
> End If
>
> If Name = "" Then
> PlayerMsg Founder_Index, "Your guild needs a name!", BrightRed
> Exit Sub
> End If
>
> ' Check level
> If GetPlayerLevel(Founder_Index) < Options.Buy_Lvl Then
> PlayerMsg Founder_Index, "You need to be level " & Options.Buy_Lvl & " to make a guild!", BrightRed
> Exit Sub
> End If
>
> ' Check if item is required
> If Not Options.Buy_Item = 0 Then
> 'Get item amount
> itemAmount = HasItem(Founder_Index, Options.Buy_Item)
>
> ' Item Req
> If itemAmount = 0 Or itemAmount < Options.Buy_Cost Then
> PlayerMsg Founder_Index, "You need " & Options.Buy_Cost & " " & Item(Options.Buy_Item).Name & " to join a guild!", BrightRed
> Exit Sub
> End If
>
> 'Take Item
> TakeInvItem Founder_Index, Options.Buy_Item, Options.Buy_Cost
> End If
>
> GuildData(GuildSlot).Guild_Name = Name
> GuildData(GuildSlot).Guild_Tag = Tag
> GuildData(GuildSlot).Guild_Color = 4
> GuildData(GuildSlot).Guild_MOTD = "Welcome to the " & Name & "!"
> GuildData(GuildSlot).In_Use = True
> GuildData(GuildSlot).Guild_Fileid = GuildFileId
> GuildData(GuildSlot).Guild_Members(1).Founder = True
> GuildData(GuildSlot).Guild_Members(1).User_Login = Player(Founder_Index).Login
> GuildData(GuildSlot).Guild_Members(1).User_Name = Player(Founder_Index).Char(TempPlayer(index).CurChar).Name
> GuildData(GuildSlot).Guild_Members(1).Rank = MAX_GUILD_RANKS
> GuildData(GuildSlot).Guild_Members(1).Comment = "Guild Founder"
> GuildData(GuildSlot).Guild_Members(1).Used = True
> GuildData(GuildSlot).Guild_Members(1).Online = True
> GuildData(GuildSlot).Guild_Logo = rand(1, MAX_GUILD_LOGO)
>
>
> 'Set up Admin Rank with all permission which is just the max rank
> GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).Name = "Leader"
> GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).Used = True
>
> For b = 1 To MAX_GUILD_RANKS_PERMISSION
> GuildData(GuildSlot).Guild_Ranks(MAX_GUILD_RANKS).RankPermission(
> ```B) = 1 Next b 'Set up rest of the ranks with default permission For I = 1 To MAX_GUILD_RANKS - 1 GuildData(GuildSlot).Guild_Ranks(I).Name = "Rank " & I GuildData(GuildSlot).Guild_Ranks(I).Used = True For b = 1 To MAX_GUILD_RANKS_PERMISSION GuildData(GuildSlot).Guild_Ranks(I).RankPermission( B) = Default_Ranks( B) Next b Next I Player(Founder_Index).Char(TempPlayer(index).CurChar).GuildFileId = GuildFileId Player(Founder_Index).Char(TempPlayer(index).CurChar).GuildMemberId = 1 TempPlayer(Founder_Index).tmpGuildSlot = GuildSlot 'Save Call SaveGuild(GuildSlot) Call SavePlayer(Founder_Index) 'Send to player Call SendGuild(False, Founder_Index, GuildSlot) 'Inform users PlayerMsg Founder_Index, "Guild Successfully Created!", BrightGreen PlayerMsg Founder_Index, "Welcome to " & GuildData(GuildSlot).Guild_Name & ".", BrightGreen PlayerMsg Founder_Index, "Your Guild Logo Randomly [" & GuildData(GuildSlot).Guild_Logo & "].", BrightGreen PlayerMsg Founder_Index, "You can talk in guild chat with: ;Message ", BrightRed 'Update user for guild name display Call SendPlayerData(Founder_Index) End Sub Public Function CheckGuildPermission(index As Long, Permission As Integer) As Boolean Dim GuildSlot As Long 'Get slot GuildSlot = TempPlayer(index).tmpGuildSlot 'Make sure we are talking about the same person If Not GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).User_Login = Player(index).Login Then 'Something went wrong and they are not allowed to do anything CheckGuildPermission = False Exit Function End If 'If founder, true in every case If GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Founder = True Then CheckGuildPermission = True Exit Function End If 'Make sure this slot is being used aka they are still a member If GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Used = False Then 'Something went wrong and they are not allowed to do anything CheckGuildPermission = False Exit Function End If 'Check if they are able to If GuildData(GuildSlot).Guild_Ranks(GuildData(GuildSlot).Guild_Members(Player(index).GuildMemberId).Rank).RankPermission(Permission) = 1 Then CheckGuildPermission = True Else CheckGuildPermission = False End If End Function
Link to comment
Share on other sites

```
Case 6
'accept
If TempPlayer(index).tmpGuildInviteSlot > 0 Then
If GuildData(TempPlayer(index).tmpGuildInviteSlot).In_Use = True And GuildData(TempPlayer(index).tmpGuildInviteSlot).Guild_Fileid = TempPlayer(index).tmpGuildInviteId Then
Call Join_Guild(index, TempPlayer(index).tmpGuildInviteSlot)
TempPlayer(index).tmpGuildInviteSlot = 0
TempPlayer(index).tmpGuildInviteTimer = 0
TempPlayer(index).tmpGuildInviteId = 0
Else
PlayerMsg index, "No one from this guild is online any more, please ask for a new invite.", BrightRed
Call Join_Guild(index, TempPlayer(index).tmpGuildInviteSlot)
TempPlayer(index).tmpGuildInviteSlot = 0
TempPlayer(index).tmpGuildInviteTimer = 0
TempPlayer(index).tmpGuildInviteId = 0
End If
Else
PlayerMsg index, "You must get a guild invite to use this command.", BrightRed
End If

```
I put this, and work :)!. This Fix!. THANKS ALL!.
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...