SA-MP Forums Archive
Getting coords - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Getting coords (/showthread.php?tid=204621)



Getting coords - Anthonyx3' - 30.12.2010

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


Re: Getting coords - _rAped - 30.12.2010

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()


Re: Getting coords - Anthonyx3' - 30.12.2010

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


Re: Getting coords - _rAped - 30.12.2010

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.


Re: Getting coords - Anthonyx3' - 30.12.2010

Hm...ill try it out and let you know


Re: Getting coords - Anthonyx3' - 30.12.2010

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?


Re: Getting coords - _rAped - 30.12.2010

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
     }
}



Re: Getting coords - Anthonyx3' - 30.12.2010

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


Re: Getting coords - Anthonyx3' - 30.12.2010

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


Re: Getting coords - _rAped - 30.12.2010

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.
     }
}