Need help with saving position system
#1

I made this one using dudb2.4 but i dont know how it works.help me
Код:
#include <a_samp>
#include <dutils>
#include <dudb>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOR_SYSTEM 0xEFEFF7AA

new PLAYERLIST_authed[MAX_PLAYERS];
forward PutAtPos(playerid);

stock SystemMsg(playerid,msg[]) {
  if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
    SendClientMessage(playerid,COLOR_SYSTEM,msg);
  }
  return 1;
}

public OnPlayerCommandText(playerid,cmdtext[]) {
 return false;
}

public OnPlayerConnect(playerid) {
 return false;
}

stock PlayerName(playerid) {
 new name[255];
 GetPlayerName(playerid, name, 255);
 return name;
}
public PutAtPos(playerid) {
 if (dUserINT(PlayerName(playerid)).("x")!=0) {
   SystemMsg(playerid,"Setting you to your last position. Welcome back!");
   SetPlayerPos(playerid,
          float(dUserINT(PlayerName(playerid)).("x")),
          float(dUserINT(PlayerName(playerid)).("y")),
          float(dUserINT(PlayerName(playerid)).("z")));
 }
}

public OnPlayerSpawn(playerid) {
 if (PLAYERLIST_authed[playerid])
  { // Nice, this guy is logged in, lets set him!
   SetTimer("PutAtPos",2000,0);
  }
}

public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
   // Was loggedin, so save the data!
   dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
   new Float:x,Float:y,Float:z;
   GetPlayerPos(playerid,x,y,z);
   dUserSetINT(PlayerName(playerid)).("x",floatround(x));
   dUserSetINT(PlayerName(playerid)).("y",floatround(y));
   dUserSetINT(PlayerName(playerid)).("z",floatround(z));
 }
 return false;
}
Reply
#2

I've tried this script before and there's some bugs with it.

If you're ID 0 and somebody ELSE dies you respawn at the spot you disconnected in, if you die, you spawn where you disconnected in, not where you're job spawns.

So there's no point of using it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)