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

[Help]Money req for guild.


Domino_
 Share

Recommended Posts

I have problem that my player have 500 gold but when I try to make guild there is message who says that I dont have the 500 gold… how to fix? :D3
My code:
```
GuildCostItem = HasItem(Index, 1)
If GuildCostItem >= 500 Then
* whole guild creating code *
Call TakeInvItem(Index, 1, 500)
else
* You dont have 500 gold... *
end if

```Same only bit smaller:
```
If HasItem(Index, 1) >= 500 Then
* whole guild creating code *
Call TakeInvItem(Index, 1, 500)
else
* You dont have 500 gold... *
end if

```
There is problem that he counts the item as none or not currency or smtn?

I'm trying to get check does player have gold more than 500 and if have then make guild and take 500 gold.

–--------------------------------
Also how to referesh player equipment in server side?
Im using this tut: http://www.touchofdeathforums.com/smf/index.php/topic,76362.msg819075.html#msg819075
But afther droping item icon stays in eq if character window is open when die...
Link to comment
Share on other sites

I don't see anything wrong with the code, apart from the small thing of the parameters passed to the TakeInvItem function.

```
Call TakeInvItem(Index, 1, 500)

```
The '1' is probably the item slot. So check if your currency(gold) item is in the first slot of your inventory.
Link to comment
Share on other sites

@Zesh:

> I don't see anything wrong with the code, apart from the small thing of the parameters passed to the TakeInvItem function.
>
> ```
> Call TakeInvItem(Index, 1, 500)
>
> ```
> The '1' is probably the item slot. So check if your currency(gold) item is in the first slot of your inventory.

No. Actually 1 is specifically the item number, the game then loops though the items and checks if that is the correct item.

Have you tried seeing what HasItem returns? If it returns 1, it means that it considers the item not to be a currency. 0 means it thinks you don't have the currency. Also, make sure that the gold item number is 1.

As for the other question:
```
Call SendInventoryUpdate(index, i)

```
To send an inventory update to slot i for player index.
Link to comment
Share on other sites

Okey… in server side I have this code and I have item 1 as currency and 500 of it...
Doenst work, says that I dont have the currency.... CODE:
```
Public Sub MakeGuild(Founder_Index As Long, Name As String)
    Dim tmpGuild As GuildRec
    Dim GuildSlot As Long
    Dim GuildFileId As Long
    Dim i As Integer
    Dim b As Integer

    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

    If HasItem(Index, 1) >= 500 Then

    GuildData(GuildSlot).Guild_Name = 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).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

    '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).GuildFileId = GuildFileId
    Player(Founder_Index).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
    Call TakeInvItem(Index, 1, 500)

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

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

    Else
    PlayerMsg Founder_Index, "You can't make guild without 500 gold!", BrightRed
    Call TakeInvItem(Index, 1, 500)
    End If

End Sub
```
lol I changed
```
If HasItem(Index, 1) >= 500 Then
```to
```
If HasItem(Index, 1) >= 0 Then
```and works but doesnt take currency…
```
Call TakeInvItem(Index, 1, 500)
```I'm right (index (player index), 1(item nummber), 500(value of item) ?

Ill try on default version of eo…. o.O :D
Link to comment
Share on other sites

You should really nest your code but I noticed something wrong with the If statement. The TakeInvItem function is under Else meaning that 500 gold will be taken if you don't have 500 gold :P Just change the last bit of that Subroutine to:

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

    ' Take gold
    Call TakeInvItem(Index, 1, 500)

    Else
    PlayerMsg Founder_Index, "You can't make guild without 500 gold!", BrightRed
    End If

```
That should work :cheesy:
Link to comment
Share on other sites

@Zesh:

> You should really nest your code but I noticed something wrong with the If statement. The TakeInvItem function is under Else meaning that 500 gold will be taken if you don't have 500 gold :P Just change the last bit of that Subroutine to:
>
> ```
>     'Update user for guild name display
>     Call SendPlayerData(Founder_Index)
>
>     ' Take gold
>     Call TakeInvItem(Index, 1, 500)
>
>     Else
>     PlayerMsg Founder_Index, "You can't make guild without 500 gold!", BrightRed
>     End If
>
> ```
> That should work :cheesy:

Take item is before else too I was just testing :D But, dunno ill check with default eo version.
Link to comment
Share on other sites

```
If HasItem(Index, 1) >= 0 Then

```
Of course it works. HasItem **always** returns a positive integer (0, 1, 2, … 32767). The question is if HasItem is working right.

Now please stop giving me half the code. I appreciate your efforts to reduce the amount I have to read but ultimately you should always give the sub with the parameters as a minimum.

The problem is you use Index in HasItem, but you pass Founder_Index to the sub. HasItem then exits because Index was undefined (is zero). I'm assuming you didn't use Option Explicit at the beginning of the module, because if you did the compiler would yell at you.

* * *

To fix the item check and taking:

Change:
```
If HasItem(Index, 1) >= 500 Then

```
to:
```
If HasItem(Founder_Index, 1) >= 500 Then

```
and also change:
```
Call TakeInvItem(Index, 1, 500)

```
to:
```
Call TakeInvItem(Founder_Index, 1, 500)

```
To fix the player message:

Change:
```
PlayerMsg Index, "You can talk in guild chat with:  ;Message ", BrightRed

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

```
and to prevent future errors, add the following at the top of any modules you make:
```
Option Explicit

```

* * *

Now tell me if that helps.
Link to comment
Share on other sites

Big thanks, Soul, now it works. :)
Option Explicit is checking if everything ir right yes?
Also When I added this in guild module he told that
```
    PlayerMsg Index, "You can talk in guild chat with:  ;Message ", BrightRed
```PlayerMsg **Index** isnt there so I added Dim Index As Long afther    Dim b As Integer , I did it right? :D or just needed to change PlayerMsg Index to PlayerMsg Founder_Index ?
Link to comment
Share on other sites

@Domino_:

> Big thanks, Soul, now it works. :)
> Option Explicit is checking if everything ir right yes?
> Also When I added this in guild module he told that
> ```
>     PlayerMsg Index, "You can talk in guild chat with:  ;Message ", BrightRed
> ```PlayerMsg **Index** isnt there so I added Dim Index As Long afther    Dim b As Integer , I did it right? :D or just needed to change PlayerMsg Index to PlayerMsg Founder_Index ?

@Soul:

> To fix the player message:
>
> Change:
> ```
> PlayerMsg Index, "You can talk in guild chat with:  ;Message ", BrightRed
>
> ```
> to:
> ```
> PlayerMsg Founder_Index, "You can talk in guild chat with:  ;Message ", BrightRed
>
> ```

Already said it. ;)

Also, VB6 is a weird language in the sense that it lets you use variables without having declared them (and it implicitly declares them as a variant type, which by the way, is a huge waste of memory). In the case of using it as a number, it says it is 0\. Option Explicit says don't implicitly declare variables, instead raise an error. (Explicit is the opposite of implicit.)
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...