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

Serverside: SetPlayerStr Problem ! important!


Kirby4tw
 Share

Recommended Posts

Hey Eclipser.
I have a big problem and i dont know how to fix  :lipsrsealed:

I want to add strength to the Player(Index).
So this is my code (its 100% correct):

```
Call SetPlayerSTR(Index, GetPlayerSTR(Index) +10)
```
All know this code sets the Player strenght + 10 but theres a big  error:
I try to explain:

If the Player has no equipped equipment so this code is working fine. BUT!:

granted that the player has a basic value of strenght of 15 and a equipped weapon with +5 STR so the basic value increased to 20 (logic).

But if i want to use now my code above to increase 10 STR to my actual basic value (20), its unexpected add the weapon Strengh(5) + my Code-Strenght (10) to my basic value. Result 20 + 10 + 5 = 35\. Thats wrong. But Theres should be: 20+10 =30.

My Question:
Why the server add the EquipStr + My 10 to my STR Value if a equipped something?

I think thats a fatal mistake in the Eclipse Engine.
So please help me =)

Heres the GetPlayerSTR function:
```
Function GetPlayerSTR(ByVal Index As Long) As Long
    Dim Add As Long
    Add = 0
    If GetPlayerWeaponSlot(Index) > 0 Then
        Add = Item(GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))).AddStr
    End If
    If GetPlayerArmorSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerArmorSlot(Index))).AddStr
    End If
    If GetPlayerShieldSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerShieldSlot(Index))).AddStr
    End If
    If GetPlayerHelmetSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerHelmetSlot(Index))).AddStr
    End If
    If GetPlayerLegsSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerLegsSlot(Index))).AddStr
    End If
    If GetPlayerRingSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerRingSlot(Index))).AddStr
    End If
    If GetPlayerNecklaceSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerNecklaceSlot(Index))).AddStr
    End If
    GetPlayerSTR = Player(Index).Char(Player(Index).CharNum).STR + Add
End Function

```
And Here the SetPlayerSTR:
```
Sub SetPlayerSTR(ByVal Index As Long, ByVal STR As Long)
    Player(Index).Char(Player(Index).CharNum).STR = STR
End Sub

```
(Sorry for my bad english)
<(Kirby4tw)>
Link to comment
Share on other sites

Punika, meinst du echt es is ne tolle idee die stärke übern server zu verändern? Ich brauch das in verbindung mit nem Buffscript. Das Funktioniert soweit. Aber wenn ich was angelegt habe addiert er die falschen werte siehe mein Problem oben im schlechten Englisch >_>
Aber danke das du es dir wenigstens angeschaut hast. Ich hoffe einer der ECLIPSE_FREAKS xD kann das lösen.

Thank you Punika.
I hope anybody can help me with this :/

@ The Soul Numb:
no clsCommand fpr SadScript is the same as the Server-Side One.
Because the clsCommand use the same GetPlayerSTR Function. === PROBLEM
Link to comment
Share on other sites

@Kirby4tw:

> @ The Soul Numb:
> no clsCommand fpr SadScript is the same as the Server-Side One.
> Because the clsCommand use the same GetPlayerSTR Function. === PROBLEM

Yes, you fix it, just take away the part where it gets the what the player is wearing, and change it to a new command like GetPlayerBaseStr.
Link to comment
Share on other sites

I dont understand what you mean o.o sry

Heres the GetPlayerSTR function:
```
Function GetPlayerSTR(ByVal Index As Long) As Long
    Dim Add As Long
    Add = 0
    If GetPlayerWeaponSlot(Index) > 0 Then
        Add = Item(GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))).AddStr
    End If
    If GetPlayerArmorSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerArmorSlot(Index))).AddStr
    End If
    If GetPlayerShieldSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerShieldSlot(Index))).AddStr
    End If
    If GetPlayerHelmetSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerHelmetSlot(Index))).AddStr
    End If
    If GetPlayerLegsSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerLegsSlot(Index))).AddStr
    End If
    If GetPlayerRingSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerRingSlot(Index))).AddStr
    End If
    If GetPlayerNecklaceSlot(Index) > 0 Then
        Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerNecklaceSlot(Index))).AddStr
    End If
    GetPlayerSTR = Player(Index).Char(Player(Index).CharNum).STR + Add
End Function

```
And Here the SetPlayerSTR:
```
Sub SetPlayerSTR(ByVal Index As Long, ByVal STR As Long)
    Player(Index).Char(Player(Index).CharNum).STR = STR
End Sub

```
But, damnit, wheres is the bug come from? o.O
Link to comment
Share on other sites

the SetPlayerSTR finds the STR that is saved for that player

the GetPlayerSTR finds what that player is AND adds all the armor/weapons to it.

If you want to add to the base and NOT what it is after your code should be this:

```
Call SetPlayerSTR(Index, Player(Index).Char(Player(Index).CharNum).STR +10)

```
I think. ^_^
Link to comment
Share on other sites

varinyc's code will probably solve the problem. The main problem is that the source only contains one strength function. It should also have something like a **GetPlayerMaxStr(Index)** function to prevent this from happening. I'll try to explain what was happening before:

First, you were getting the strength bonus from equipping the weapon, giving you 20 strength. When you used the **GetPlayerStr(Index)** function, it went through the equipment part, found a +5, and added it to your existing strength (20), leaving you with 25\. Then, you added a 10 to whatever the **GetPlayerStr(Index)** was, which is 25, thus leaving you with 35 strength. Basically, it added the +5 twice in a different way.
Link to comment
Share on other sites

This is really simple actually xD

```
Function GetPlayerStr(ByVal Index As Long) As Long
    ...
End Function

Function GetPlayerBaseStr(ByVal Index As Long) As Long
    'GetPlayerSTR = Player(Index).Char(Player(Index).CharNum).STR + Add      is the original getplayerstr.
    'the + Add is ruining your thing, so we just make it:
    GetPlayerSTR = Player(Index).Char(Player(Index).CharNum).STR
End Function

```
Btw, I don't like it how you called the coders in eclipse ECLIPSE_FREAKS (I know you said: I hope the eclipse freaks can solve this, but still)
@Kirby4tw:

> Punika, meinst du echt es is ne tolle idee die stärke übern server zu verändern? Ich brauch das in verbindung mit nem Buffscript. Das Funktioniert soweit. Aber wenn ich was angelegt habe addiert er die falschen werte siehe mein Problem oben im schlechten Englisch >_>
> Aber danke das du es dir wenigstens angeschaut hast. Ich hoffe einer der ECLIPSE_FREAKS xD kann das lösen.

Have a nice day.
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...