Ertzel Posted August 24, 2010 Author Share Posted August 24, 2010 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 StringDim 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 More sharing options...
DarkSpine Posted August 27, 2010 Share Posted August 27, 2010 @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 StringDim 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 More sharing options...
Ertzel Posted August 27, 2010 Author Share Posted August 27, 2010 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. Link to comment Share on other sites More sharing options...
Robin Posted August 27, 2010 Share Posted August 27, 2010 @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 More sharing options...
Ertzel Posted August 27, 2010 Author Share Posted August 27, 2010 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 More sharing options...
DarkSpine Posted August 28, 2010 Share Posted August 28, 2010 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 More sharing options...
Ertzel Posted August 28, 2010 Author Share Posted August 28, 2010 I got a overflow error and it d/ced the person I was attaching to :P Link to comment Share on other sites More sharing options...
DarkSpine Posted August 28, 2010 Share Posted August 28, 2010 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 = NothingEnd Sub```I think that'll stop it from flashing each time you warp.~Urame Link to comment Share on other sites More sharing options...
Ertzel Posted August 28, 2010 Author Share Posted August 28, 2010 I tried that and then warped to someone, my client froze and got the overflow error again. Link to comment Share on other sites More sharing options...
Robin Posted August 29, 2010 Share Posted August 29, 2010 Urame, your code is making me cry. xDNever, ever create a loop to do something like this. EO has centralised game loops which _need_ to be run properly. Link to comment Share on other sites More sharing options...
DarkSpine Posted August 29, 2010 Share Posted August 29, 2010 @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 More sharing options...
Robin Posted August 29, 2010 Share Posted August 29, 2010 Having a loop stops the entire project from processing. You need to put shit you want looped in the central loops using timer variables. Link to comment Share on other sites More sharing options...
DarkSpine Posted August 29, 2010 Share Posted August 29, 2010 @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 xDDidn't know that though, since I've never tried using a loop.~Urame Link to comment Share on other sites More sharing options...
Robin Posted August 29, 2010 Share Posted August 29, 2010 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 More sharing options...
Ertzel Posted August 29, 2010 Author Share Posted August 29, 2010 @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 More sharing options...
DarkSpine Posted August 29, 2010 Share Posted August 29, 2010 @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 More sharing options...
Robin Posted August 29, 2010 Share Posted August 29, 2010 @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 More sharing options...
Ertzel Posted August 29, 2010 Author Share Posted August 29, 2010 @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 More sharing options...
Mikekan13 Posted August 29, 2010 Share Posted August 29, 2010 make a new sub that forces the player to follow the same movement key presses as the person it is following. Are you trying to make a vehicle with passenger positions? I am doing something like that. Link to comment Share on other sites More sharing options...
Ertzel Posted August 29, 2010 Author Share Posted August 29, 2010 @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 More sharing options...
Displaced Posted August 30, 2010 Share Posted August 30, 2010 Do you know what you're doing?You Put the Server into a endless Loop.While (SERVER ONLINE)blahhhLoopIt never ends until server stops -> stack overflow Link to comment Share on other sites More sharing options...
Ertzel Posted August 30, 2010 Author Share Posted August 30, 2010 I tried putting the looping part in mobServerLoop and that failed badly and causes my server to error out after like 3 seconds of running. Link to comment Share on other sites More sharing options...
Displaced Posted August 30, 2010 Share Posted August 30, 2010 just take the while loop out and try without..if you put this into the server loop, it will loop anyways.. Link to comment Share on other sites More sharing options...
Ertzel Posted August 30, 2010 Author Share Posted August 30, 2010 @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 More sharing options...
Robin Posted August 31, 2010 Share Posted August 31, 2010 As I said before, you don't want to loop it. You just need to make it so whenever the GM moves, any locked players are warped to the new position. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now