Weaponsystem don't load
#1

Heey guys.

I got a question I have made a weapon system and everything works.
When you relog it loads your guns.
When you are death it load your guns.
I have put the loadweapons on the login dialog AND at onplayerspawn.

BUT when you do a restart the weapons doesn't load.

I have put the loadweapons on the acount system.

What do you need to help me or does someone know something?
Reply
#2

Yah, reload the script in OnGamemodeInit
Reply
#3

Think you don't get it.

I have put everything IN the gamemode not in a filterscript.
@ onplayerspawn
pawn Код:
LoadWeapons(playerid);
@ onplayerlogin @ the login dialog
pawn Код:
LoadWeapons(playerid);
The loadweapons stock
pawn Код:
stock LoadWeapons(playerid)
{
    if(IsPlayerNPC(playerid))return 1;
    GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME);//In the hope the account bug gets fixed

    format(PlayerFile, sizeof(PlayerFile), "/accounts/%s.sav", PlayerName[playerid]);
    if (dini_Exists(PlayerFile))
    {
        PlayerInfo[playerid][pWeapon0] = dini_Int(PlayerFile, "Weapon0");
        PlayerInfo[playerid][pWeapon1] = dini_Int(PlayerFile, "Weapon1");
        PlayerInfo[playerid][pWeapon2] = dini_Int(PlayerFile, "Weapon2");
        PlayerInfo[playerid][pWeapon3] = dini_Int(PlayerFile, "Weapon3");
        PlayerInfo[playerid][pWeapon4] = dini_Int(PlayerFile, "Weapon4");
        PlayerInfo[playerid][pWeapon5] = dini_Int(PlayerFile, "Weapon5");
        PlayerInfo[playerid][pWeapon6] = dini_Int(PlayerFile, "Weapon6");
        PlayerInfo[playerid][pWeapon7] = dini_Int(PlayerFile, "Weapon7");
        PlayerInfo[playerid][pWeapon8] = dini_Int(PlayerFile, "Weapon8");
        PlayerInfo[playerid][pWeapon9] = dini_Int(PlayerFile, "Weapon9");
        PlayerInfo[playerid][pWeapon10] = dini_Int(PlayerFile, "Weapon10");
        PlayerInfo[playerid][pWeapon11] = dini_Int(PlayerFile, "Weapon11");
        PlayerInfo[playerid][pWeapon12] = dini_Int(PlayerFile, "Weapon12");
        PlayerInfo[playerid][pAmmo0] = dini_Int(PlayerFile, "Ammo0");
        PlayerInfo[playerid][pAmmo1] = dini_Int(PlayerFile, "Ammo1");
        PlayerInfo[playerid][pAmmo2] = dini_Int(PlayerFile, "Ammo2");
        PlayerInfo[playerid][pAmmo3] = dini_Int(PlayerFile, "Ammo3");
        PlayerInfo[playerid][pAmmo4] = dini_Int(PlayerFile, "Ammo4");
        PlayerInfo[playerid][pAmmo5] = dini_Int(PlayerFile, "Ammo5");
        PlayerInfo[playerid][pAmmo6] = dini_Int(PlayerFile, "Ammo6");
        PlayerInfo[playerid][pAmmo7] = dini_Int(PlayerFile, "Ammo7");
        PlayerInfo[playerid][pAmmo8] = dini_Int(PlayerFile, "Ammo8");
        PlayerInfo[playerid][pAmmo9] = dini_Int(PlayerFile, "Ammo9");
        PlayerInfo[playerid][pAmmo10] = dini_Int(PlayerFile, "Ammo10");
        PlayerInfo[playerid][pAmmo11] = dini_Int(PlayerFile, "Ammo11");
        PlayerInfo[playerid][pAmmo12] = dini_Int(PlayerFile, "Ammo12");
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon0],PlayerInfo[playerid][pAmmo0]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon1],PlayerInfo[playerid][pAmmo1]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2],PlayerInfo[playerid][pAmmo2]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3],PlayerInfo[playerid][pAmmo3]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4],PlayerInfo[playerid][pAmmo4]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5],PlayerInfo[playerid][pAmmo5]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6],PlayerInfo[playerid][pAmmo6]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7],PlayerInfo[playerid][pAmmo7]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8],PlayerInfo[playerid][pAmmo8]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9],PlayerInfo[playerid][pAmmo9]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10],PlayerInfo[playerid][pAmmo10]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11],PlayerInfo[playerid][pAmmo11]);
        GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12],PlayerInfo[playerid][pAmmo12]);
    }
    return 1;
}
Reply
#4

Then I do not know because I never use the GMX command but just re-open the server window.
Reply
#5

Hmm oke thanks anyway.

It is for server who is open so it should use the gmx command.

Someone else?
Reply
#6

You don't have to gmx actually. If you just reopen the server window all player automatically re-enter...
Reply
#7

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
You don't have to gmx actually. If you just reopen the server window all player automatically re-enter...
Thrue but I need it because my server every night restart and it is growing this server so maybe some admin need to restart when there is a bugg.
I just need the GMx command.

How to fix this?
Reply
#8

Save the weapons at GMX.
Reply
#9

Quote:
Originally Posted by Hashski
Посмотреть сообщение
Save the weapons at GMX.
Saving works but the loading of the weapons doesn't work that is so weird, everything works good.
Now I made this:
Very simpel and everything works accept after /rcon gmx.

What is this problem that it would'nt load @ /rcon gmx.

pawn Код:
public OnPlayerConnect(playerid)
{
    AlreadyGiveWeapons[playerid] = false;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SaveWeaponsToFile(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if (!AlreadyGiveWeapons[playerid]) SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    AlreadyGiveWeapons[playerid] = false;
    SaveWeaponsToFile(playerid);
    return 1;
}
SaveWeaponsToFile(playerid)
{
    new i, path[50], 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);
    }
}

forward LoadWeaponsToFile(playerid);
public LoadWeaponsToFile(playerid)
{
    new i, path[50], weaponid, ammo;
    path = GetPlayerFormattedName(playerid);
    ResetPlayerWeapons(playerid);
    for (i=0; i<13; i++)
    {
        format(string,sizeof(string),"Weapon - %d",i);
        weaponid = dini_Int(path,string);
        format(string,sizeof(string),"AmmoID - %d",i);
        ammo = dini_Int(path,string);
        GivePlayerWeapon(playerid,weaponid,ammo);
    }
    AlreadyGiveWeapons[playerid] = true;
}
#define PATH "Weapons"  //  Folder where players data saved
new bool:AlreadyGiveWeapons[MAX_PLAYERS];
Reply
#10

When you GMX it doesn't disconnect the person, So OnPlayerDisconnect will have no use, You have to Save it when it Restarts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)