How to..
#1

Hello,

Im wondering how i would get all the weapons that the player has in all there slots,
And save them to PlayerInfo[playerid][Weapons]
And how would i load them from that and give it to the player?
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
[FS] Dmteleport
Reply
#3

Dosent really tell me much,
Ive looked at it,
What i dont know is how to save it to PlayerInfo[playerid][Weapons]
And give player the weapons that are in [u]PlayerInfo[playerid][Weapons][u]
Reply
#4

Quote:
Originally Posted by Joe Torran C
Dosent really tell me much,
Ive looked at it,
What i dont know is how to save it to PlayerInfo[playerid][Weapons]
And give player the weapons that are in [u]PlayerInfo[playerid][Weapons][u]
Check the example from GetPlayerWeaponData...
then you know how to save all weapons from a player
reading would be vice versa
Reply
#5

And to give the player the weapons saved?
Reply
#6

pawn Код:
new Weapon_Data[MAX_PLAYERS][26];
//Saving
for (new i = 0; i < 13; i++)
{
  GetPlayerWeaponData(playerid, i, Weapon_Data[playerid][i], Weapon_Data[playerid][i + 13]);
}
//Reading
for (new i = 0; i < 13; i++)
{
  GivePlayerWeapon(playerid, Weapon_Data[playerid][i], Weapon_Data[i + 13]);
}
I dont think that this was hard...

*Slot 12 could be removed from saving because slot 12 only contains the detonator
Reply
#7

Im still not sure using PlayerInfo[playerid][Weapons]
Reply
#8

You cannot save every weapon into PlayerInfo[playerid][Weapons], that's obvious, you need to create a separate slot for everyweapon, like PlayerInfo[playerid][Assaultrifle], PlayerInfo[playerid][Assaultammo], PlayerInfo[playerid][Pistol], PlayerInfo[playerid][Pistolammo].
Reply
#9

Quote:
Originally Posted by Joe Torran C
Im still not sure using PlayerInfo[playerid][Weapons]
Quote:
Originally Posted by LowCo.
You cannot save every weapon into PlayerInfo[playerid][Weapons], that's obvious, you need to create a separate slot for everyweapon, like PlayerInfo[playerid][Assaultrifle], PlayerInfo[playerid][Assaultammo], PlayerInfo[playerid][Pistol], PlayerInfo[playerid][Pistolammo].
lol

Try this:
pawn Код:
#include <a_samp>

#define FILTERSCRIPT
#include <zcmd>

enum blabla
{
    Weapons[12],
    ammo[12],
}

new PlayerInfo[MAX_PLAYERS][blabla];

COMMAND:saveweap(playerid, params[])
{
    for(new i; i < 12; i++)
    {
        GetPlayerWeaponData(playerid, i+1, PlayerInfo[playerid][Weapons][i], PlayerInfo[playerid][ammo][i]);
    }
    ResetPlayerWeapons(playerid);
    SendClientMessage(playerid, 0xFF0000FF, "Saved weapons ammo and ResetPlayerWeapons.");
    return 1;
}

COMMAND:addweap(playerid, params[])
{
    for(new i; i < 12; i++)
    {
        GivePlayerWeapon(playerid, PlayerInfo[playerid][Weapons][i], PlayerInfo[playerid][ammo][i]);
    }
    SendClientMessage(playerid, 0xFF0000FF, "Add weapons. It's cool.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)