How would this be done?
#1

Okay, so I was woundering how I would script in where when people log/crash they would save their position and when the log back in they would spawn where they logged out.
Reply
#2

use the dini include
and use this code
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  if(reason == 0)
  {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);    
    dini_FloatSet(thefile, "CrashX", X);
    dini_FloatSet(thefile, "CrashY", Y);
    dini_FloatSet(thefile, "CrashZ", Z);
    return 1;
  }
  return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    new Float:X, Float:Y, Float:Z;
    X = dini_Float(thefile, "CrashX");
    Y = dini_Float(thefile, "CrashY");
    Z = dini_Float(thefile, "CrashZ");
    SetPlayerPos(playerid, X, Y, Z);
    return 1;
}
Reply
#3

That will save only if player will timeout (crash), it wouldn't be bad if you use it for other reasons, too.
Reply
#4

Quote:
Originally Posted by James_Alex
use the dini include
and use this code
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  if(reason == 0)
  {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);    
    dini_FloatSet(thefile, "CrashX", X);
    dini_FloatSet(thefile, "CrashY", Y);
    dini_FloatSet(thefile, "CrashZ", Z);
    return 1;
  }
  return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    new Float:X, Float:Y, Float:Z;
    X = dini_Float(thefile, "CrashX");
    Y = dini_Float(thefile, "CrashY");
    Z = dini_Float(thefile, "CrashZ");
    SetPlayerPos(playerid, X, Y, Z);
    return 1;
}
What is "thefile' from lines "X = dini_Float(thefile, "CrashX");
Y = dini_Float(thefile, "CrashY");
Z = dini_Float(thefile, "CrashZ");" ? ?
Reply
#5

Quote:
Originally Posted by NiGhTWoLFy
Quote:
Originally Posted by James_Alex
use the dini include
and use this code
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  if(reason == 0)
  {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);    
    dini_FloatSet(thefile, "CrashX", X);
    dini_FloatSet(thefile, "CrashY", Y);
    dini_FloatSet(thefile, "CrashZ", Z);
    return 1;
  }
  return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    new Float:X, Float:Y, Float:Z;
    X = dini_Float(thefile, "CrashX");
    Y = dini_Float(thefile, "CrashY");
    Z = dini_Float(thefile, "CrashZ");
    SetPlayerPos(playerid, X, Y, Z);
    return 1;
}
What is "thefile' from lines "X = dini_Float(thefile, "CrashX");
Y = dini_Float(thefile, "CrashY");
Z = dini_Float(thefile, "CrashZ");" ? ?
Probably the file you want the coordinates to be saved in
Reply
#6

You should save it into the player's account file.
Reply
#7

What do I put for
"CrashX"
"CrashY"
"CrashZ"
Reply
#8

Nothing. Its just there to symbolize "When someone crashes, it will temporarily replace CrashX, Y and Z with the coords."
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)