SA-MP Forums Archive
How to save? - 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)
+--- Thread: How to save? (/showthread.php?tid=503645)



How to save? - Lajko1 - 30.03.2014

How to save weapons slot number 2 to veriable?


Re: How to save? - RenovanZ - 30.03.2014

pawn Код:
#define MAX_WEAPONS 12
new WeaponInfo[MAX_PLAYERS][MAX_WEAPONS];

WeaponInfo[playerid][2] = weaponid;



Re: How to save? - Lajko1 - 30.03.2014

And ammo from that slot ?


Re: How to save? - RenovanZ - 30.03.2014

pawn Код:
#define MAX_WEAPONS 12
new WeaponInfo[MAX_PLAYERS][MAX_WEAPONS];
new WeaponAmmo[MAX_PLAYERS][MAX_WEAPONS];

WeaponInfo[playerid][2] = weaponid;
WeaponAmmo[playerid][2] = ammo;



Re: How to save? - AmazonSK - 30.03.2014

Check this: https://sampwiki.blast.hk/wiki/GetPlayerWeaponData

It's nice loop to save all player weapon data.

Код:
new weapons[13][2];
 
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
Then I am saving these information to a User File


Re: How to save? - Lajko1 - 30.03.2014

pawn Код:
if(strcmp(cmdtext, "/tazer", true) == 0)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
    if(IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid, COLOR_RED, "You are currently in a vehicle!");
        return 1;
    }
   
    if(strfind(name, "[PD]", true) == -1)
    {
              SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
              return 1;
    }
    new gunID = GetPlayerWeapon(playerid);
    new Amm = GetPlayerAmmo(playerid);
   
    WeaponInfo[playerid][2] = gunID;
    WeaponAmmo[playerid][2] = Amm;
    new weapons[13][2];
        for (new i = 0; i < 13; i++)
        {
            GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
        }
        if(weapons[2][0] == 23) { WEAPON = 23; }
        if(HasTazer[playerid] == 0)
        {
            GiveTazer(playerid);
            GivePlayerWeapon(playerid, WEAPON, 50);
            return 1;
        }
        if(HasTazer[playerid] == 1)
        {
            GivePlayerWeapon(playerid, gunID, Amm);
            TakeTazer(playerid);
            return 1;
        }
        return 1;
    }
    return 0;
}
Okay this won't give weapon back to player after he removes his tazer..


Re: How to save? - Lajko1 - 30.03.2014

Anyone