[QUESTION]How to make your weapons save
#1

How can i make the persons gun save when server restarts ,because i ready made it so it saves in OnPlayerDisconnect,but i can't make it save for somer eason when server restarts please tell me how.
Reply
#2

What saving system do you use?
Reply
#3

None just one that came with my gamemode.
pawn Код:
public OnPlayerDisconnect(playerid,reason)
{

/*new mtext[20];
new year, month,day;
getdate(year, month, day);
if(month == 1) { mtext = "January"; }
else if(month == 2) { mtext = "February"; }
else if(month == 3) { mtext = "March"; }
else if(month == 4) { mtext = "April"; }
else if(month == 5) { mtext = "May"; }
else if(month == 6) { mtext = "June"; }
else if(month == 7) { mtext = "July"; }
else if(month == 8) { mtext = "August"; }
else if(month == 9) { mtext = "September"; }
else if(month == 10) { mtext = "October"; }
else if(month == 11) { mtext = "November"; }
else if(month == 12) { mtext = "December"; }
new hour,minuite,second;
gettime(hour,minuite,second);
FixHour(hour);
hour = shifthour;
new string[128];
format(string, sizeof(string), "%d / %s / %d at %d:%d:%d",year,mtext,day,hour,minuite,second)
strmid(PlayerInfo[playerid][pLogOutTime], string, 0, strlen(string), 255);*/


        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new Float:armour;
        KillTimer(BlinkTime[playerid]);
        new Float:health;
        GetPlayerName(playerid, sendername, sizeof(sendername));
    if(gPlayerLogged[playerid] == 1) {
     for(new slot = 0; slot != 12; slot++)
        {
            new wep, ammo;
            GetPlayerWeaponData(playerid, slot, wep, ammo);

            if(wep != 0 && ammo != 0)
            {
                if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
                else if(PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wep; PlayerInfo[playerid][pAmmo2] = ammo; }
                else if(PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wep; PlayerInfo[playerid][pAmmo3] = ammo; }
                else if(PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wep; PlayerInfo[playerid][pAmmo4] = ammo; }
            }
        }
And then so player spawns with weapon i use this.
pawn Код:
public SetPlayerWeapons(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJailed] == 0)
        {
            if (PlayerInfo[playerid][pGun1] > 0)
            {
                  GivePlayerWeaponEx(playerid, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
                PlayerInfo[playerid][pGun1] = 0; PlayerInfo[playerid][pAmmo1] = 0;
            }
            if (PlayerInfo[playerid][pGun2] > 0)
            {
                  GivePlayerWeaponEx(playerid, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
                PlayerInfo[playerid][pGun2] = 0; PlayerInfo[playerid][pAmmo2] = 0;
            }
            if (PlayerInfo[playerid][pGun3] > 0)
            {
                GivePlayerWeaponEx(playerid, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
                PlayerInfo[playerid][pGun3] = 0; PlayerInfo[playerid][pAmmo3] = 0;
            }
            if (PlayerInfo[playerid][pGun4] > 0)
            {
               GivePlayerWeaponEx(playerid, PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pAmmo4]);
                PlayerInfo[playerid][pGun4] = 0; PlayerInfo[playerid][pAmmo4] = 0;
            }
        }
    }
}
Reply
#4

Well you will have to usa a saving system, I recommend djson.
Reply
#5

Ok......
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)