Getting coords
#1

Hey guys, for some reason my login stopped working, and i dont have backups so cant go back to backup for code. When a player logged in, he would be spawned at his last coords, but now players goes to 0.0 which is annoying, i cant find out my problem. Heres my code:


pawn Код:
PlayerInfo[playerid][X1] = dini_Float(file, "Posx");

            PlayerInfo[playerid][Y1] = dini_Float(file, "Posy");

            PlayerInfo[playerid][Z1] = dini_Float(file, "Posz");

            SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1]);

            SetSpawnInfo(playerid, PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][X1], PlayerInfo[playerid][Y1], PlayerInfo[playerid][Z1], 1.0, -1, -1, -1, -1, -1, -1);

            SpawnPlayer(playerid);
I have a feeling i did something wrong, i would appreciate anyones help, thanks
Reply
#2

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
Hey guys, for some reason my login stopped working, and i dont have backups so cant go back to backup for code. When a player logged in, he would be spawned at his last coords, but now players goes to 0.0 which is annoying, i cant find out my problem. Heres my code:


pawn Код:
PlayerInfo[playerid][X1] = dini_Float(file, "Posx");

            PlayerInfo[playerid][Y1] = dini_Float(file, "Posy");

            PlayerInfo[playerid][Z1] = dini_Float(file, "Posz");

            SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1]);

            SetSpawnInfo(playerid, PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][X1], PlayerInfo[playerid][Y1], PlayerInfo[playerid][Z1], 1.0, -1, -1, -1, -1, -1, -1);

            SpawnPlayer(playerid);
I have a feeling i did something wrong, i would appreciate anyones help, thanks
You don't need
pawn Код:
SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1])
as you are already defining the SpawnInfo

If it doesn't work without it, place it underneath OnPlayerSpawn()
Reply
#3

I'm bypassing the whole << >> spawn thing, i tried without setplayerpos, still same problems.
Reply
#4

I'm using some of the same system and I have made a callback that logs in the player. Underneath that callback I set the SpawnInfo, but I also SetPlayerPos() underneath OnPlayerSpawn(), works great for my case.
Reply
#5

Hm...ill try it out and let you know
Reply
#6

Alright i tried the whole setting off position onplayerspawn, but since player doesnt have coords saved to his file after registration, it sends em to 0.0. Give me an example on what you have done? Or should i just set the regi x,y,z to spawn spot?
Reply
#7

Quote:
Originally Posted by Anthonyx3'
Посмотреть сообщение
Alright i tried the whole setting off position onplayerspawn, but since player doesnt have coords saved to his file after registration, it sends em to 0.0. Give me an example on what you have done? Or should i just set the regi x,y,z to spawn spot?
Make a global variable like SpawnType[MAX_PLAYERS];

Then you can set it to 0 underneath OnPlayerDeath() 1 on login and 2 on register. Then under OnPlayerSpawn()
pawn Код:
switch(SpawnType[playerid])
{
     case 0:
     {
          // When the player dies
     }
     case 1:
     {
          // When the player login
     }
     case 2:
     {
          // When the player registers
     }
}
Reply
#8

Hm...i think i understand what your saying, ill try it out, or try to lol, Thanks.
Reply
#9

Alright, i think its my tiredness but i just cant this spawning shit -.-
pawn Код:
public OnPlayerSpawn(playerid)
{
    new SpawnType[MAX_PLAYERS];
    switch(SpawnType[playerid])
{
     case 0:
     {
          // When the player dies
     }
     case 1:
     {
        if(PlayerInfo[playerid][Logged] == 1)
        PlayerInfo[playerid][Spawned] = 1;
        SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1]);
     }
     case 2:
     {
        if(PlayerInfo[playerid][Logged] == 1)
        PlayerInfo[playerid][Spawned] = 1;
        SetPlayerPos(playerid, -2658.7156,633.3684,14.4531);
     }
}
    //SetSpawnInfo(playerid, PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][X1], PlayerInfo[playerid][Y1], PlayerInfo[playerid][Z1], 1.0, -1, -1, -1, -1, -1, -1);
    //if(PlayerInfo[playerid][Logged] == 1)
        //PlayerInfo[playerid][Spawned] = 1;
        //SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1]);

    return 1;
}
Im trying to think of an easier way to fix the login but nothing coming to mind
Reply
#10

Couldn't be easier.
pawn Код:
switch(SpawnType[playerid])
{
     case 0:
     {
          // When the player dies
     }
     case 1:
     {
          // Should probably add interior and virtual world here too.
          SetPlayerPos(playerid, PlayerInfo[playerid][X1],PlayerInfo[playerid][Y1],PlayerInfo[playerid][Z1]);
     }
     case 2:
     {
          SetPlayerPos(playerid, x, y, z); // Change this to the newbiespawn.
     }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)