Szerző Téma: Fegyvermentés  (Megtekintve 1190 alkalommal)

Nem elérhető Tomee

  • 385
    • Profil megtekintése
Fegyvermentés
« Dátum: 2011. Augusztus 14. - 13:24:30 »
0 Show voters
Hello!
Szükségem lenne egy scriptre ami, kilépésnél elmenti a játékos összes fegyverét, majd amikor visszalép akkor megkapja õket.

Fegyvermentés
« Válasz #1 Dátum: 2011. Augusztus 14. - 13:30:04 »
0 Show voters
dudbal:[pawn]#include <a_samp>
#include <dudb>
public OnGameModeInit() SendRconCommand(\"exit\");
public OnPlayerSpawn(playerid) LoadWeapons(playerid);
public OnFilterScriptInit() printf(\"Weaponsave FS loaded!\");
public OnPlayerDisconnect(playerid, reason) SaveWeapons(playerid);
stock LoadWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, \"\");
    for(new wep[8], amm[6], i; i < 13; i++)
    {
        format(amm, sizeof amm, \"Ammo%d\", i);
        format(wep, sizeof wep, \"Weapon%d\", i);
        GivePlayerWeapon(playerid, dUserINT(pname).(wep), dUserINT(pname).(amm));
    }
    return true;
}
stock SaveWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, \"\");
    for(new wep[8], amm[6], i, cwep, camm; i < 13; i++)
    {
        format(amm, sizeof amm, \"Ammo%d\", i);
        format(wep, sizeof wep, \"Weapon%d\", i);
        GetPlayerWeaponData(playerid, i, cwep, camm);
        dUserSetINT(pname).(amm, camm);
        dUserSetINT(pname).(wep, cwep);
    }
    return true;
}[/pawn]
« Utoljára szerkesztve: 2011. Augusztus 14. - 14:03:14 írta kadaradam »

Nem elérhető Tomee

  • 385
    • Profil megtekintése
Fegyvermentés
« Válasz #2 Dátum: 2011. Augusztus 14. - 13:42:35 »
0 Show voters
Lehet én csinálok mindig valamit rosszul, de ez már a 3. amivel próbálkozok és nem megy.
Amikor kilépek nem menti el az adatokat.
És mellette, hogy oldhatnám meg, hogy egy Fegyverek, nevû mappába mentse?
« Utoljára szerkesztve: 2011. Augusztus 14. - 13:55:54 írta Tomee »

Fegyvermentés
« Válasz #3 Dátum: 2011. Augusztus 14. - 14:12:05 »
+1 Show voters
Meg kell adni hogy hova mentse,és honnan töltse be(udb_Create(pname, \"\");),de ha nem jó,itt van egy dinis:
[pawn]#include <a_samp>
#include <dini>
new PlayerWeapons[12][MAX_PLAYERS];
new PlayerAmmo[12][MAX_PLAYERS];
new file[40];
public OnPlayerConnect(playerid)
{
     for(new w=0;w<13;w++)
     {
         PlayerWeapons[w][playerid]=0;
         PlayerAmmo[w][playerid]=0;
     }
format(file,sizeof(file),\"%s.Weapons.txt\",oGetPlayerName(playerid));
if(!dini_Exists(file))
{
   printf(\"no such file \'%s\'? created...\", file);
   dini_Create(file);
}
return 1;
}
public OnPlayerDisconnect(playerid)
{
    for(new weap=0;weap<13;weap++)
    {
        GetPlayerWeaponData(playerid,weap,PlayerWeapons[weap][playerid],PlayerAmmo[weap][playerid]);
        format(file,sizeof(file),\"%s.Weapons.txt\",oGetPlayerName(playerid));
        new slotname[20];
        format(slotname,sizeof(slotname),\"Slot%d\",weap);
   dini_IntSet(file,slotname,PlayerWeapons[weap][playerid]);
        new slotammo[20];
        format(slotammo,sizeof(slotammo),\"AmmoSlot%d\",weap);
   dini_IntSet(file,slotammo,PlayerAmmo[weap][playerid]);
    }
return 1;
}
public OnPlayerSpawn(playerid)
{
    for(new weap=0;weap<13;weap++)
    {
        format(file,sizeof(file),\"%s.Weapons.txt\",oGetPlayerName(playerid));
        new slotname[20];
        format(slotname,sizeof(slotname),\"Slot%d\",weap);
        new slotammo[20];
        format(slotammo,sizeof(slotammo),\"AmmoSlot%d\",weap);
        PlayerWeapons[weap][playerid] = strval(dini_Get(file, slotname));
        PlayerAmmo[weap][playerid] = strval(dini_Get(file, slotammo));
   GivePlayerWeapon(playerid, PlayerWeapons[weap][playerid], PlayerAmmo[weap][playerid]);
    }
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    for(new i=0;i<13;i++)
    {
        GetPlayerWeaponData(playerid,i,PlayerWeapons[playerid],PlayerAmmo[playerid]);

        format(file,sizeof(file),\"%s.Weapons.txt\",oGetPlayerName(playerid));


        new slotname[20];


        format(slotname,sizeof(slotname),\"Slot%d\",i);


   dini_IntSet(file,slotname,PlayerWeapons
[playerid]);

        new slotammo[20];


        format(slotammo,sizeof(slotammo),\"AmmoSlot%d\",i);


   dini_IntSet(file,slotammo,PlayerAmmo
[playerid]);

    }


return 1;


}


stock oGetPlayerName(playerid)


{


new name[MAX_PLAYER_NAME];


GetPlayerName(playerid,name,sizeof(name));


return name;


}[/pawn]

Nem elérhető Tomee

  • 385
    • Profil megtekintése
Fegyvermentés
« Válasz #4 Dátum: 2011. Augusztus 16. - 21:23:56 »
0 Show voters
Megoldottam azzal, hogy másodpercenként menti a játékosnál lévõ fegyvereket.
Csak még azt kellene megoldani, hogy  Fegyverek nevû mappába mentse.
Én így csináltam
 
if(!udb_Exists(pname)) udb_Create(pname, \"Fegyverek/\");

 
csak éppen nem jó.

Nem elérhető Tomee

  • 385
    • Profil megtekintése
Fegyvermentés
« Válasz #5 Dátum: 2011. Augusztus 16. - 22:38:37 »
0 Show voters
Köszönöm.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal