How to load weapons (Using Dini)
#1

I can't figure out how to load weapons. I was looking for tutorial or something what could help me, but nothing.
So in the end I decided to ask for help here.

So here is my current code

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new weapons[13][2], name[MAX_PLAYER_NAME], file[256];
   	GetPlayerName(playerid, name, sizeof(name));
   	format(file, sizeof(file), SERVER_USER_FILE, name);
   	if(gPlayerLogged[playerid] == 1)
   	{
	   	for (new i = 0; i < 13; i++)
	    {
	        GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
	    }
     	dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdmin]);
        dini_IntSet(file, "Cash",GetPlayerMoney(playerid));
        dini_IntSet(file, "Level",GetPlayerScore(playerid));
        dini_IntSet(file, "weaponSlot0", weapons[0][0]);
        dini_IntSet(file, "weaponSlot0Ammo", weapons[0][1]);
	    dini_IntSet(file, "weaponSlot1", weapons[1][0]);
	    dini_IntSet(file, "weaponSlot1Ammo", weapons[1][1]);
	    dini_IntSet(file, "weaponSlot2", weapons[2][0]);
	    dini_IntSet(file, "weaponSlot2Ammo", weapons[2][1]);
	    dini_IntSet(file, "weaponSlot3", weapons[3][0]);
	    dini_IntSet(file, "weaponSlot3Ammo", weapons[3][1]);
	    dini_IntSet(file, "weaponSlot4", weapons[4][0]);
	    dini_IntSet(file, "weaponSlot4Ammo", weapons[4][1]);
	    dini_IntSet(file, "weaponSlot5", weapons[5][0]);
	    dini_IntSet(file, "weaponSlot5Ammo", weapons[5][1]);
	    dini_IntSet(file, "weaponSlot6", weapons[6][0]);
	    dini_IntSet(file, "weaponSlot6Ammo", weapons[6][1]);
	    dini_IntSet(file, "weaponSlot7", weapons[7][0]);
	    dini_IntSet(file, "weaponSlot7Ammo", weapons[7][1]);
	    dini_IntSet(file, "weaponSlot8", weapons[8][0]);
	    dini_IntSet(file, "weaponSlot8Ammo", weapons[8][1]);
	    dini_IntSet(file, "weaponSlot9", weapons[9][0]);
	    dini_IntSet(file, "weaponSlot9Ammo", weapons[9][1]);
	    dini_IntSet(file, "weaponSlot10", weapons[10][0]);
	    dini_IntSet(file, "weaponSlot10Ammo", weapons[10][1]);
	    dini_IntSet(file, "weaponSlot11", weapons[11][0]);
	    dini_IntSet(file, "weaponSlot11Ammo", weapons[11][1]);
	    dini_IntSet(file, "weaponSlot12", weapons[12][0]);
	    dini_IntSet(file, "weaponSlot12Ammo", weapons[12][1]);
   	}
   	gPlayerLogged[playerid] = 0;
	return 1;
}
All right, this code works well, but I can't figure out how to load weapons.

Here will be code of my register and login.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	// |-------|        |---------|     REGISTER / LOGIN      |-----------|       |----------|
    if (dialogid == 100)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, ""COL_WHITE"TEST "COL_RED"ME", "Welcome, your not registered!", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0);
        dini_IntSet(file, "Cash",GetPlayerMoney(playerid));
        dini_IntSet(file, "Level",GetPlayerScore(playerid));
        format(string, 128, ""COL_EASY"You succesfully registered the nickname "COL_WHITE"%s "COL_EASY"with password "COL_WHITE"%s"COL_EASY", you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, -1, string);
        gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 200)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, ""COL_WHITE"TEST "COL_RED"ME", "Welcome back to server!", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, -1, ""COL_RED"[Error] "COL_WHITE"Wrong password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, ""COL_WHITE"TEST "COL_RED"ME", "Welcome back to server!", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
            GivePlayerMoney(playerid, dini_Int(file, "Cash")-GetPlayerMoney(playerid));
            SendClientMessage(playerid, -1, ""COL_EASY"Successfully logged in!");
        }
    }
	return 1;
	// |-----------|         |------------|  END  |-----------|           |------------|
}
Thanks already.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)