Jump to content
  • 0

Salvare Arme!


prigat10

Question

Salut!Am facut asta dar n use salveaza...creaza fisierul User.txt dar nu salveaza si armele...

[pawn]

#define PATH "Weapons"

SaveWeaponsToFile(playerid)

{

new i, path[50], string[128], weaponid, ammo;

    path = GetPlayerFormattedName(playerid);

    if (!dini_Exists(path)) dini_Create(path);

for (i=0; i<13; i++)

{

    GetPlayerWeaponData(playerid,i,weaponid,ammo);

    format(string,sizeof(string),"Weapon - %d",i);

    dini_IntSet(path,string,weaponid);

    format(string,sizeof(string),"AmmoID - %d",i);

    dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);

}

}[/pawn]

Multumesc!

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

Incearca asta , pune-o sub forma de FS

[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]

tumblr_mawvpkU5L61rdlfnuo1_500.gif

Link to comment
Share on other sites

[pawn]

#include <a_samp>

#include <dini>

#include <dudb>

#include <dutils>

#include <Colors>

#define XFile "WeapnsX/%s.ini"

public OnFilterScriptInit()

{

  return 1;

}

public OnFilterScriptExit()

{

  return 1;

}

public OnPlayerConnect(playerid)

{

  new str[256];

  format(str,sizeof(str),XFile,pName(playerid));

    if(!dini_Exists(str)

      {

            dini_Create(str);

            dini_IntSet(str,"WeaponSlot1",0);

      {

}

public OnPlayerDiscconnect(playerid,reason)

{

        new str[256];

  format(str,sizeof(str),XFile,pName(playerid));

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

        dini_IntSet(str,"WeaponSlot1",GetPlayerWeaponData(playerid, i, cwep, camm));

    }

}

public OnPlayerSpawn(playerid)

{

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

    }

}

stock pName(playerid)

{

new name[MAX_PLAYER_NAME];

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

return name;

}

[/pawn]

sau alta metoda:....

adauga

LoadWeapon(playerid); la OnPlayerSpawn(playerid)

si SaveWeapons(playerid); la comanda aia a ta...

pentru ca scriptu meu l-am facut in cateva minute si nu l-am verificat de coduri..

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.