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

[EO] Attaching Problem.


Ertzel
 Share

Recommended Posts

Im trying to setup a loop that warps me to a player if I am not already standing ontop of them.

I tried this
```
Dim PlayerFile As String
Dim n As String
    PlayerFile = App.Path & "\data\Attachlist.ini"
    n = FindPlayer(Buffer.ReadString)

    If n <> Index And n > 0 Then
        If GetPlayerMap(Index) <> GetPlayerMap(n) Or GetPlayerX(Index) <> GetPlayerX(n) Or GetPlayerY(Index) <> GetPlayerY(n) Then
            Do While GetVar(PlayerFile, GetPlayerName(Index), "IsAttached") = YES
                Call PlayerWarp(Index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
            Loop
        End If
    End If
```
But I keep getting run-time error 13: Type missmatch.

This is the first time I've tried making anything on my own with a loop so I have no clue how to fix this.

Without the loop part of it the code works on its own to teleport me to the place once, but I need it to keep looping through so it follows the player if they move.
Link to comment
Share on other sites

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

@Ertzel:

> >! Im trying to setup a loop that warps me to a player if I am not already standing ontop of them.
> >! I tried this
> ```
> Dim PlayerFile As String
> Dim n As String
>     PlayerFile = App.Path & "\data\Attachlist.ini"
>     n = FindPlayer(Buffer.ReadString)
> >!     If n <> Index And n > 0 Then
>         If GetPlayerMap(Index) <> GetPlayerMap(n) Or GetPlayerX(Index) <> GetPlayerX(n) Or GetPlayerY(Index) <> GetPlayerY(n) Then
>             Do While GetVar(PlayerFile, GetPlayerName(Index), "IsAttached") = YES
>                 Call PlayerWarp(Index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
>             Loop
>         End If
>     End If
> ```
> But I keep getting run-time error 13: Type missmatch.
> >! This is the first time I've tried making anything on my own with a loop so I have no clue how to fix this.
> >! Without the loop part of it the code works on its own to teleport me to the place once, but I need it to keep looping through so it follows the player if they move.

I really don't see anything wrong with it…Maybe try this:
```
Dim PlayerFile As String
Dim n As String
    PlayerFile = App.Path & "\data\Attachlist.ini"
    n = FindPlayer(Buffer.ReadString)

    If n <> Index And n > 0 Then
        If GetPlayerMap(Index) <> GetPlayerMap(n) Or GetPlayerX(Index) <> GetPlayerX(n) Or GetPlayerY(Index) <> GetPlayerY(n) Then
            Do While GetVar(PlayerFile, GetPlayerName(Index), "IsAttached") = "YES"
                Call PlayerWarp(Index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
            Loop
        End If
    End If
```and wherever you set "IsAttached" change it to setting it to "YES" with quotes rather than without quotes…

I know, it's probably stupid to even suggest it, but when you get stuck you try the stupid things too, right? xD
~Urame
Link to comment
Share on other sites

@Ertzel:

> The quotes shouldn't make a difference or be the problem. I used the same line using just Yes and it triggered other things right.

EO has YES = 1 and NO = 0 in modConstants.

Anywhere you're using YES without quotes is a variable which means '1'.
Link to comment
Share on other sites

Oh ok that did fix it.

I have another question now though. When I use Playerwarp with the loop my screen keeps flashing like every second because its warping me around. This is gunna get really annoying when im following someone whos hunting and moving around alot.

Is there any way I can follow a player without using Playerwarp?

I tried this but it did nothing
```
                Do While While GetVar(PlayerFile, GetPlayerName(Index), "IsAttached") = "YES"
                    Call SetPlayerY(Index, GetPlayerY(n))
                        Call SetPlayerX(Index, GetPlayerX(n))
                            Call SetPlayerMap(Index, GetPlayerMap(n))
                        Call SendPlayerData(Index)
                    Loop
```
Link to comment
Share on other sites

Try:
```
                Do While While GetVar(PlayerFile, GetPlayerName(Index), "IsAttached") = "YES"
                    Call SetPlayerY(Index, GetPlayerY(n))
                        Call SetPlayerX(Index, GetPlayerX(n))
                            Call SetPlayerMap(Index, GetPlayerMap(n))
                        Call SendPlayerData(Index)
                        Call SendPlayerXY(Index)
                    Loop

```
Link to comment
Share on other sites

Darn…Go back to the playerwarp system, but try changing the Sub PlayerWarp to this:
```
Sub PlayerWarp(ByVal Index As Long, ByVal MapNum As Long, ByVal x As Long, ByVal y As Long)
    Dim shopNum As Long
    Dim OldMap As Long
    Dim I As Long
    Dim Buffer As clsBuffer

    ' Check for subscript out of range
    If IsPlaying(Index) = False Or MapNum <= 0 Or MapNum > MAX_MAPS Then
        Exit Sub
    End If

    ' Check if you are out of bounds
    If x > Map(MapNum).MaxX Then x = Map(MapNum).MaxX
    If y > Map(MapNum).MaxY Then y = Map(MapNum).MaxY
    TempPlayer(Index).Target = 0
    TempPlayer(Index).TargetType = TARGET_TYPE_NONE

    ' Save old map to send erase player data to
    OldMap = GetPlayerMap(Index)

    If OldMap <> MapNum Then
        Call SendLeaveMap(Index, OldMap)
    End If
    If MapNum <> OldMap Then
    Call SetPlayerMap(Index, MapNum)
    End If
    Call SetPlayerX(Index, x)
    Call SetPlayerY(Index, y)

    ' send equipment of all people on new map
    If OldMap <> MapNum Then
    If GetTotalMapPlayers(MapNum) > 0 Then
        For I = 1 To MAX_PLAYERS
            If IsPlaying(I) Then
                If GetPlayerMap(I) = MapNum Then
                    SendMapEquipmentTo I, Index
                End If
            End If
        Next
    End If
    End If

    ' Now we check if there were any players left on the map the player just left, and if not stop processing npcs
    If OldMap <> MapNum Then
    If GetTotalMapPlayers(OldMap) = 0 Then
        PlayersOnMap(OldMap) = NO

        ' Regenerate all NPCs' health
        For I = 1 To MAX_MAP_NPCS

            If MapNpc(OldMap).Npc(I).Num > 0 Then
                MapNpc(OldMap).Npc(I).Vital(Vitals.HP) = GetNpcMaxVital(MapNpc(OldMap).Npc(I).Num, Vitals.HP)
            End If

        Next

    End If
    End If

    ' Sets it so we know to process npcs on the map
    PlayersOnMap(MapNum) = YES
    If OldMap <> MapNum Then
    TempPlayer(Index).GettingMap = YES
    End If
    Set Buffer = New clsBuffer
    Buffer.WriteLong SCheckForMap
    Buffer.WriteLong MapNum
    Buffer.WriteLong Map(MapNum).Revision
    SendDataTo Index, Buffer.ToArray()
    Set Buffer = Nothing
End Sub
```I think that'll stop it from flashing each time you warp.
~Urame
Link to comment
Share on other sites

@Robin:

> Urame, your code is making me cry. xD
>
> Never, ever create a loop to do something like this. EO has centralised game loops which _need_ to be run properly.

I was just trying to help…Which obviously didn't work. Please, do tell me what I did terribly wrong, as I'm curious now xD
~Urame
Link to comment
Share on other sites

@Robin:

> Having a loop stops the entire project from processing. You need to put shit you want looped in the central loops using timer variables.

If that was aimed at me, I didn't code the main system…I was just trying to fix it with the info given xD
Didn't know that though, since I've never tried using a loop.

~Urame
Link to comment
Share on other sites

Oh yeah, just noticed the original code has a loop as well.

That's the problem. It's causing the server to go into a huge loop causing the rest of the systems to stop responding and the packet system being overwhelmed with unprocessed packets.
Link to comment
Share on other sites

@Robin:

> Oh yeah, just noticed the original code has a loop as well.
>
> That's the problem. It's causing the server to go into a huge loop causing the rest of the systems to stop responding and the packet system being overwhelmed with unprocessed packets.

Lol, thats the point of the thread being called Loop problem, because it has a loop…

I need the warping to keep happening until the GM releases the player, not only happen once. How can I do this without using a loop?
Link to comment
Share on other sites

@Robin:

> Having a loop stops the entire project from processing. You need to put shit you want looped in the central loops using timer variables.

Do what Robin said. Look at examples in the game loop, and then try inserting the code. Shouldn't be too hard really, if you run into trouble, just post in here with the problem ^^

~Urame
Link to comment
Share on other sites

@Ertzel:

> Lol, thats the point of the thread being called Loop problem, because it has a loop…
>
> I need the warping to keep happening until the GM releases the player, not only happen once. How can I do this without using a loop?

Look how I handle timers in the ServerLoop in Origins. Although, if you're just wanting the player to be 'locked' to the X & Y of another player, why don't you just remove their moving capabilities and whenever the person they're locked to moves, have them warp to the new position.
Link to comment
Share on other sites

@Robin:

> Although, if you're just wanting the player to be 'locked' to the X & Y of another player, why don't you just remove their moving capabilities and whenever the person they're locked to moves, have them warp to the new position.

Thats pretty much what im trying to do… How do I make it keep following someone whenever they move without using a loop....
Link to comment
Share on other sites

@Mikekan13:

> Are you trying to make a vehicle with passenger positions? I am doing something like that.

No, im trying to make it so GMs can attach to players and it follows them.

@Robin:

> Look how I handle timers in the ServerLoop in Origins.

I tried this
```
            If GetPlayerMap(Index) <> GetPlayerMap(n) Or GetPlayerX(Index) <> GetPlayerX(n) Or GetPlayerY(Index) <> GetPlayerY(n) Then
                Do While ServerOnline
                    Tick = GetTickCount
                        If Tick > tmr500 Then
                            Call PlayerWarp(Index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
                        tmr500 = GetTickCount + 500
                    End If
                Loop
            End If
```
But got an overflow error again.
Link to comment
Share on other sites

@Displaced:

> if you put this into the server loop, it will loop anyways..

Yes I know that, and as I said before putting this into modServerLoop failed badly.

I have tried many different ways of doing this and they all work as long as it does not involve looping anything.

As soon as I try to loop the warping/following aspect is when it errors out. If I only warp once then it works but thats pointless for what I need it to do.
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...