SA-MP Forums Archive
Last Position Save Help. - 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: Last Position Save Help. (/showthread.php?tid=262812)



Last Position Save Help.[NOT SOLVED] - ricardo178 - 19.06.2011

Hello guys..... I've been 4 hours around this, and i can't...
I tried many things, but nothing worked.

How do i make a LastPosition saved script?
I am using dini....


Just make it like if it is to you, or take it from your script, and i will change it.
I really can't make this.

Thank you very much.


Re: Last Position Save Help. - Wesley221 - 19.06.2011

pawn Код:
public OnPlayerDisconnect(playerid)
{
    new Float:lastx, Float:lasty, Float:lastz, file[128], name[MAX_PLAYER_NAME];
    GetPlayerPos(playerid, lastx, lasty, lastz);
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), file location thingies, name);
    dini_Create(file);
    dini_IntSet(file, "Last X", lastx);
    dini_IntSet(file, "Last Y", lasty);
    dini_IntSet(file, "Last Z", lastz);
    return 1;
}
Dont know if this is gonna work, but worth a try


Re: Last Position Save Help. - Stigg - 19.06.2011

Under OnPlayerSpawn
pawn Код:
SetPlayerPosition(playerid, dini_Int(file, "PositionX"));
    SetPlayerPosition(playerid, dini_Int(file, "PositionY"));
    SetPlayerPosition(playerid, dini_Int(file, "PositionZ"));
Under OnPlayerDisconnect
pawn Код:
new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    dini_FloatSet(file, "PositionX", x);
    dini_FloatSet(file, "PositionY", y);
    dini_FloatSet(file, "PositionZ", z);
Try something like that.


Re: Last Position Save Help. - ricardo178 - 19.06.2011

It doesn't work...
The codes that i have are:

pInfo Enum:
pawn Код:
enum pInfo
{
    AdminLevel,
    Cash,
    Score,
    Color,
    Job,
    Vw,
    Int,
    Warns,
    Fleader,
    Fmember,
    Bank,
    Prods,
    Skin,
    RepairOffer,
    Credit,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Register Dialog:
pawn Код:
if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "RicAdmin/users/%s.ini", name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
        dini_IntSet(file, "Cash",PlayerInfo[playerid][Cash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][Score] = 0);
        dini_IntSet(file, "Job",PlayerInfo[playerid][Job] = 0);
        dini_IntSet(file, "Color",PlayerInfo[playerid][Color] = 0);
        dini_IntSet(file, "Vw",PlayerInfo[playerid][Vw] = 0);
        dini_IntSet(file, "Int",PlayerInfo[playerid][Int] = 0);
        dini_IntSet(file, "Warns",PlayerInfo[playerid][Warns] = 0);
        dini_IntSet(file, "Fleader",PlayerInfo[playerid][Fleader] = 0);
        dini_IntSet(file, "Fmember",PlayerInfo[playerid][Fmember] = 0);
        dini_IntSet(file, "Bank",PlayerInfo[playerid][Bank] = 0);
        dini_IntSet(file, "Prods",PlayerInfo[playerid][Prods] = 0);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][Skin] = 0);
        dini_IntSet(file, "RepairOffer",PlayerInfo[playerid][RepairOffer] = 0);
        dini_IntSet(file, "Credit",PlayerInfo[playerid][Credit] = 0);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, 0xFF00CC, string);
        IsLogged[playerid] = 1;
    }
Login Dialog:
pawn Код:
if (dialogid == 2)
    {
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, sizeof(name));
      format(file, sizeof(file), "RicAdmin/users/%s.ini", name);
      if(!response) return Kick(playerid);
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, please login.", "Login", "Leave");
      new tmp;
      tmp = dini_Int(file, "Password");
      if(udb_hash(inputtext) != tmp) {
      SendClientMessage(playerid, 0xFF00CC, "Wrong PW sir.");
      ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, put the password below.", "Login", "Leave");
      }
      else
      {
        IsLogged[playerid] = 1;
        SetPlayerMoney(playerid, dini_Int(file, "Cash"));
        SetPlayerScore(playerid, dini_Int(file, "Score"));
        SetPlayerColor(playerid, dini_Int(file, "Color"));
        SetPlayerVirtualWorld(playerid, dini_Int(file, "Vw"));
        SetPlayerInterior(playerid, dini_Int(file, "Int"));
        PlayerInfo[playerid][Job] = dini_Int(file, "Job");
        PlayerInfo[playerid][Warns] = dini_Int(file, "Warns");
        PlayerInfo[playerid][Fleader] = dini_Int(file, "Fleader");
        PlayerInfo[playerid][Fmember] = dini_Int(file, "Fmember");
        PlayerInfo[playerid][Bank] = dini_Int(file, "Bank");
        PlayerInfo[playerid][Prods] = dini_Int(file, "Prods");
        PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
        PlayerInfo[playerid][RepairOffer] = dini_Int(file, "RepairOffer");
        PlayerInfo[playerid][Credit] = dini_Int(file, "Credit");
        SetPlayerSkin(playerid, dini_Int(file, "Skin"));
        SendClientMessage(playerid,0xFF00CC, "[SYSTEM]: Successfully logged in!");
    }
    }
return 1;
}
My OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerMapIcon(playerid, 4, 1461.215209, -1012.771972, 26.843750, 52, COLOR_YELLOW);  // Bank
    SetPlayerMapIcon(playerid, 8, 2468.4919,-2092.9902,13.5469, 51, COLOR_YELLOW)// Truck Place
    SetPlayerMapIcon(playerid, 10, 1235.013916, 360.252166, 19.554687, 27, COLOR_YELLOW);   // Mechanic Place
    SetPlayerMapIcon(playerid, 13, -1421.7410,-287.9273,14.1484, 5, COLOR_YELLOW); // SF Airport
    SetPlayerMapIcon(playerid, 14, 1675.3717,1447.8632,10.7876, 5, COLOR_YELLOW); // LV Airport
    SetPlayerMapIcon(playerid, 15, 1685.9310,-2239.2971,-2.7028, 5, COLOR_YELLOW); // LS Airport
    SetPlayerMapIcon(playerid, 28, 1555.3328,-1610.7543,12.4250, 11, COLOR_YELLOW); // Helipad LSPD
    SetPlayerMapIcon(playerid, 29, 2789.7092,-2531.5193,12.6450, 11, COLOR_YELLOW); // Helipad Army
    SetPlayerMapIcon(playerid, 3, 1227.623535, 181.653335, 20.409919, 30, COLOR_YELLOW); //Police Station
    SetPlayerMapIcon(playerid, 4, 1310.981689, 329.641571, 19.914062, 52, COLOR_YELLOW);  // Ammu
    SetPlayerMapIcon(playerid, 4, 1256.442871, 275.010467, 19.554687, 52, COLOR_YELLOW);  // 24/7
    SetPlayerMapIcon(playerid, 8, 1200.335937, 248.921127, 19.281734, 51, COLOR_YELLOW);    // Truck Place Country
    SetPlayerMapIcon( playerid, 1, 1315.4899, -900.8430, 39.5781, 17, 0 ); // 24/7 Vinewood
    SetPlayerMapIcon( playerid, 2, 1352.3300, -1755.7100, 13.3530, 17, 0 ); // 24/7 Perishing
    SetPlayerMapIcon( playerid, 3, 2045.9812,-1907.9951,13.5469, 55, 0 ); // DMV
    SetPlayerMapIcon( playerid, 4, 1565.5342, 23.0955, 24.1641, 18, 0 ); // Arms Dealer Registration
    SetPlayerMapIcon( playerid, 5, -2170.3726,-232.9594,36.5156, 18, 0 ); // Arms Dealer Pick Up
    SetPlayerMapIcon( playerid, 6, -489.3573,611.6118,1.7739, 18, 0 ); // Arms Dealer Drop Off
    SetPlayerMapIcon( playerid, 7, 1831.7091, -1682.1526, 13.5456, 49, 0 ); // Alhambra
    SetPlayerMapIcon( playerid, 8, 2851.5830, -1532.2117, 11.0938, 49, 0 ); // Emerald Club
    SetPlayerMapIcon( playerid, 9, 2421.5200, -1221.7500, 25.3998, 49, 0 ); // Pig Pen
    SetPlayerMapIcon( playerid, 10, 1003.7123, -935.3038, 41.7400, 56, 0 ); // Vinewood Gas Station
    SetPlayerMapIcon( playerid, 11, 1942.9373, -1772.9230, 13.3906, 56, 0 ); // Downtown Gas Station
    SetPlayerMapIcon( playerid, 12, 1553.3510, -1675.4082, 16.1953, 30, 0 ); // LSPD
    SetPlayerMapIcon( playerid, 13, 2421.2256,-1222.2745, 25.3670, 12, 0 ); // Whore Job
    SetPlayerMapIcon( playerid, 14, 1830.6687, -1075.4744, 23.8479, 25, 0 ); // Drug Dealer Crack House
    SetPlayerMapIcon( playerid, 15, 1109.3318, -1796.3042, 16.5938, 51, 0 ); // Car Jacker Join
    SetPlayerMapIcon( playerid, 16, 214.7574, -230.5657, 1.7786, 51, 0); // Car Jacker Drop Off
    SetPlayerMapIcon( playerid, 17, -2185.7229, 2415.9033, 5.1728, 19, 0); // Arms Smuggler Join
    SetPlayerMapIcon( playerid, 18, -1694.9041, 1330.4119, 7.1814, 19, 0); // Drugs Smuggler Join
    SetPlayerMapIcon( playerid, 19, -2419.1257, 2313.8582, 2.3012, 38, 0); // Smuggler Boat
    SetPlayerMapIcon( playerid, 20, 593.0324,-1241.1177,17.9662, 52, 0 ); // Bank Icon
    SetPlayerMapIcon( playerid, 21, 1833.4976, -1842.4099, 13.5781, 17, 0 ); // 24/7 Unity Icon
    SetPlayerMapIcon( playerid, 22, -1465.6941, 1086.6008, 1.5894, 24, 0 ); // Drug Smuggler Pickup
    SetPlayerMapIcon( playerid, 23, 1766.8953, -2286.1663, 26.9665, 56, 0 ); // Drug Smuggler Pickup
    SetPlayerMapIcon( playerid, 24, 417.8507, -1729.2375, 9.3467, 49, 0 ); // Emerald Club
    SetPlayerMapIcon( playerid, 25, 2166.3772,-1675.3829,15.0859, 24, 0 ); // Drug Dealer Join
    SetPlayerMapIcon( playerid, 26, 417.8507, -1729.2375, 9.3467, 49, 0 ); // 187 Club
    SetPlayerMapIcon( playerid, 27, 1761.3638,-1894.3767,13.5609, 11, 0 ); // Taxi Co.
    SetPlayerMapIcon( playerid, 28, 2306.5583,-2322.2639,13.3828, 27, 0 ); // Streetsweeper and Mechanic Jobs
    SetPlayerMapIcon( playerid, 29, 1008.0930,-929.5586,42.3281, 52, 0 ); // ATM 1
    SetPlayerMapIcon( playerid, 30, 1601.1042,-1539.5621,13.6062, 55, 0 ); //Mod Shop
    CreatePickup(1274, 1, 1461.215209, -1012.771972, 26.843750, -1); //BankLS
    CreatePickup(1240, 1, 1359.573974, 205.404083, 19.755516, -1); //HospitalCountry
    CreatePickup(1247, 1, 1555.333007, -1675.624511, 16.195312, -1); //LSPD
    CreatePickup(1239, 1, 1235.013916, 360.252166, 19.554687, -1); //MechanicCountry
    CreatePickup(1239, 1, 1227.402709, 312.508087, 19.757813, -1); //TaxiCountry
    CreatePickup(1239, 1, 1256.442871, 275.010467, 19.554687, -1); //24/7
    CreatePickup(1239, 1, 1200.335937, 248.921127, 19.281734, -1); //Trucker
    CreatePickup(1239, 1, 2464.828125, -2109.241943, 13.546875, -1); //TruckerLS
    CreatePickup(1239, 1, 1368.896972, -1279.801391, 13.546875, -1); //AmmuNation
    CreatePickup(1239, 1, 1162.419067, -1761.851440, 13.661267, -1); //BusLS
    CreatePickup(1239, 1, 1192.036132,  -1814.132812, 13.581386, -1); //TaxiLS
    CreatePlayer3DTextLabel(playerid,"Use /becometaxi to become a taxi driver!",0x008080FF,1192.036132,  -1814.132812, 13.581386,40.0);
    CreatePlayer3DTextLabel(playerid,"Use /becomebus to become a bus driver!",0x008080FF,1162.419067, -1761.851440, 13.661267,40.0);
    CreatePlayer3DTextLabel(playerid,"Use /becometrucker to become a trucker!",0x008080FF,2464.828125, -2109.241943, 13.546875,40.0);
    CreatePlayer3DTextLabel(playerid,"Use /goin to enter!",0x008080FF,1461.215209, -1012.771972, 26.843750,40.0);
    CreatePlayer3DTextLabel(playerid,"Use /goin to enter!",0x008080FF,1368.896972, -1279.801391, 13.546875,40.0);

    SetPlayerPos(playerid,1186.534301, -1830.901367, 13.297243);
    SetPlayerSkin(playerid, 7);
    SetPlayerHealth(playerid, 100);
    GivePlayerWeapon(playerid, 24, 30);
    return 1;
}
My OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(file,sizeof(file),"RicAdmin/users/%s.ini",name);
    if(dini_Exists(file))
    {
        dini_IntSet(file,"Cash",GetPlayerMoney(playerid));
        dini_IntSet(file,"Score",GetPlayerScore(playerid));
        dini_IntSet(file,"Color",GetPlayerColor(playerid));
        dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
        dini_IntSet(file,"Job",PlayerInfo[playerid][Job]);
        dini_IntSet(file,"Vw",GetPlayerVirtualWorld(playerid));
        dini_IntSet(file,"Int",GetPlayerInterior(playerid));
        dini_IntSet(file,"Warns",PlayerInfo[playerid][Warns]);
        dini_IntSet(file,"Fleader",PlayerInfo[playerid][Fleader]);
        dini_IntSet(file,"Fmember",PlayerInfo[playerid][Fmember]);
        dini_IntSet(file,"Bank",PlayerInfo[playerid][Bank]);
        dini_IntSet(file,"Prods",PlayerInfo[playerid][Prods]);
        dini_IntSet(file,"Skin",GetPlayerSkin(playerid));
        dini_IntSet(file,"RepairOffer",PlayerInfo[playerid][RepairOffer]);
        dini_IntSet(file,"Credit",PlayerInfo[playerid][Credit]);
        IsLogged[playerid] = 0;
        return 1;
    }
    return 1;
}
What codes, do i need to put, and where? Please help me with this... I always help people when i am able to...
Thank you.