Save weapon when killed
#1

UPDATED: I have this script but i get errors.


Код:
#include <a_samp>

#define DIALOGID 1337


public OnPlayerConnect(playerid)
{
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "weapons/%s.ini", name);
    if (!dini_Exists(file))
    {
                dini_Create(file);
                dini_IntSet(file, "Weapon1",WeaponInfo[playerid][Weapon1] = 0);
                dini_IntSet(file, "Weapon1a",WeaponInfo[playerid][Weapon1a] = 0);
                dini_IntSet(file, "Weapon2",WeaponInfo[playerid][Weapon2] = 0);
                dini_IntSet(file, "Weapon2a",WeaponInfo[playerid][Weapon2a] = 0);
                dini_IntSet(file, "Weapon3",WeaponInfo[playerid][Weapon3] = 0);
                dini_IntSet(file, "Weapon3a",WeaponInfo[playerid][Weapon3a] = 0);
                dini_IntSet(file, "Weapon4",WeaponInfo[playerid][Weapon4] = 0);
                dini_IntSet(file, "Weapon4a",WeaponInfo[playerid][Weapon4a] = 0);
                dini_IntSet(file, "Weapon5",WeaponInfo[playerid][Weapon5] = 0);
                dini_IntSet(file, "Weapon5a",WeaponInfo[playerid][Weapon5a] = 0);
                dini_IntSet(file, "Weapon6",WeaponInfo[playerid][Weapon6] = 0);
                dini_IntSet(file, "Weapon6a",WeaponInfo[playerid][Weapon6a] = 0);
                dini_IntSet(file, "Weapon7",WeaponInfo[playerid][Weapon7] = 0);
                dini_IntSet(file, "Weapon7a",WeaponInfo[playerid][Weapon7a] = 0);
                dini_IntSet(file, "Weapon8",WeaponInfo[playerid][Weapon8] = 0);
                dini_IntSet(file, "Weapon8a",WeaponInfo[playerid][Weapon8a] = 0);
                dini_IntSet(file, "Weapon9",WeaponInfo[playerid][Weapon9] = 0);
                dini_IntSet(file, "Weapon9a",WeaponInfo[playerid][Weapon9a] = 0);
                dini_IntSet(file, "Weapon10",WeaponInfo[playerid][Weapon10] = 0);
                dini_IntSet(file, "Weapon10a",WeaponInfo[playerid][Weapon10a] = 0);
                dini_IntSet(file, "Weapon11",WeaponInfo[playerid][Weapon11] = 0);
                dini_IntSet(file, "Weapon11a",WeaponInfo[playerid][Weapon11a] = 0);
                dini_IntSet(file, "Weapon12",WeaponInfo[playerid][Weapon12] = 0);
                dini_IntSet(file, "Weapon12a",WeaponInfo[playerid][Weapon12a] = 0);
        }
        else
        {
                WeaponInfo[playerid][Weapon1] = dini_Int(file, "Weapon1");
                WeaponInfo[playerid][Weapon1a] = dini_Int(file, "Weapon1a");
                WeaponInfo[playerid][Weapon2] = dini_Int(file, "Weapon2");
                WeaponInfo[playerid][Weapon2a] = dini_Int(file, "Weapon2a");
                WeaponInfo[playerid][Weapon3] = dini_Int(file, "Weapon3");
                WeaponInfo[playerid][Weapon3a] = dini_Int(file, "Weapon3a");
                WeaponInfo[playerid][Weapon4] = dini_Int(file, "Weapon4");
                WeaponInfo[playerid][Weapon4a] = dini_Int(file, "Weapon4a");
                WeaponInfo[playerid][Weapon5] = dini_Int(file, "Weapon5");
                WeaponInfo[playerid][Weapon5a] = dini_Int(file, "Weapon5a");
                WeaponInfo[playerid][Weapon6] = dini_Int(file, "Weapon6");
                WeaponInfo[playerid][Weapon6a] = dini_Int(file, "Weapon6a");
                WeaponInfo[playerid][Weapon7] = dini_Int(file, "Weapon7");
                WeaponInfo[playerid][Weapon7a] = dini_Int(file, "Weapon7a");
                WeaponInfo[playerid][Weapon8] = dini_Int(file, "Weapon8");
                WeaponInfo[playerid][Weapon8a] = dini_Int(file, "Weapon8a");
                WeaponInfo[playerid][Weapon9] = dini_Int(file, "Weapon9");
                WeaponInfo[playerid][Weapon9a] = dini_Int(file, "Weapon9a");
                WeaponInfo[playerid][Weapon10] = dini_Int(file, "Weapon10");
                WeaponInfo[playerid][Weapon10a] = dini_Int(file, "Weapon10a");
                WeaponInfo[playerid][Weapon11] = dini_Int(file, "Weapon11");
                WeaponInfo[playerid][Weapon11a] = dini_Int(file, "Weapon11a");
                WeaponInfo[playerid][Weapon12] = dini_Int(file, "Weapon12");
                WeaponInfo[playerid][Weapon12a] = dini_Int(file, "Weapon12a");
        }
        return 1;
}


public OnPlayerSpawn(playerid)
{
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Weapon1a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Weapon2a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Weapon3a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Weapon4a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Weapon5a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Weapon6a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Weapon7a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Weapon8a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Weapon9a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Weapon10a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Weapon11a]);
        GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Weapon12a]);
        SetTimerEx("save", 2000, true, "i", playerid);
        return 1;
}

public OnPlayerDisconnect(playerid)
{
                    new name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                format(file, sizeof(file), "weapons/%s.ini", name);
                GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Weapon1a]);
                GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Weapon2a]);
                GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Weapon3a]);
                GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Weapon4a]);
                GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Weapon5a]);
                GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Weapon6a]);
                GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Weapon7a]);
                GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Weapon8a]);
                GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Weapon9a]);
                GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Weapon10a]);
                GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Weapon11a]);
                GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Weapon12a]);
                dini_IntSet(file, "Weapon1",WeaponInfo[playerid][Weapon1]);
        dini_IntSet(file, "Weapon1a",WeaponInfo[playerid][Weapon1a]);
        dini_IntSet(file, "Weapon2",WeaponInfo[playerid][Weapon2]);
        dini_IntSet(file, "Weapon2a",WeaponInfo[playerid][Weapon2a]);
        dini_IntSet(file, "Weapon3",WeaponInfo[playerid][Weapon3]);
        dini_IntSet(file, "Weapon3a",WeaponInfo[playerid][Weapon3a]);
        dini_IntSet(file, "Weapon4",WeaponInfo[playerid][Weapon4]);
        dini_IntSet(file, "Weapon4a",WeaponInfo[playerid][Weapon4a]);
            dini_IntSet(file, "Weapon5",WeaponInfo[playerid][Weapon5]);
            dini_IntSet(file, "Weapon5a",WeaponInfo[playerid][Weapon5a]);
            dini_IntSet(file, "Weapon6",WeaponInfo[playerid][Weapon6]);
                dini_IntSet(file, "Weapon6a",WeaponInfo[playerid][Weapon6a]);
        dini_IntSet(file, "Weapon7",WeaponInfo[playerid][Weapon7]);
        dini_IntSet(file, "Weapon7a",WeaponInfo[playerid][Weapon7a]);
            dini_IntSet(file, "Weapon8",WeaponInfo[playerid][Weapon8]);
        dini_IntSet(file, "Weapon8a",WeaponInfo[playerid][Weapon8a]);
        dini_IntSet(file, "Weapon9",WeaponInfo[playerid][Weapon9]);
        dini_IntSet(file, "Weapon9a",WeaponInfo[playerid][Weapon9a]);
        dini_IntSet(file, "Weapon10",WeaponInfo[playerid][Weapon10]);
        dini_IntSet(file, "Weapon10a",WeaponInfo[playerid][Weapon10a]);
        dini_IntSet(file, "Weapon11",WeaponInfo[playerid][Weapon11]);
        dini_IntSet(file, "Weapon11a",WeaponInfo[playerid][Weapon11a]);
        dini_IntSet(file, "Weapon12",WeaponInfo[playerid][Weapon12]);
        dini_IntSet(file, "Weapon12a",WeaponInfo[playerid][Weapon12a]);
        return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/w", cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "Weapon Lists", "Melee\nPistols\nSub-Machine Guns\nRifle's\nAssault\nShotgun's\nMisc", "Select", "Cancel");
		return 1;
	}
	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOGID)
	{
		if(response)
		{
			if(listitem == 0) // Meele
			{
				ShowPlayerDialog(playerid, DIALOGID+1, DIALOG_STYLE_LIST, "Select a Weapon", "Knuckle Dusters\nGolf Club\nNite Stick\nBat\nShovel\nPool Cue\nKatana\nDildo\nSpray Can\nCane", "Select", "Cancel");
			}
			if(listitem == 1) // Pistols
			{
				ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Select a Weapon", "9mm\nSilenced 9mm\nDesert Eagle", "Select", "Cancel");
			}
			if(listitem == 2) // Sub-Machine Guns
			{
				ShowPlayerDialog(playerid, DIALOGID+3, DIALOG_STYLE_LIST, "Select a Weapon", "Uzi\nSMG\nTec9", "Select", "Cancel");
			}
			if(listitem == 3) // Rifles
			{
				ShowPlayerDialog(playerid, DIALOGID+4, DIALOG_STYLE_LIST, "Select a Weapon", "Country Rifle\nSniper Rifle", "Select", "Cancel");
			}
			if(listitem == 4) // Assault
			{
				ShowPlayerDialog(playerid, DIALOGID+5, DIALOG_STYLE_LIST, "Select a Weapon", "AK-47\nM4", "Select", "Cancel");
			}
			if(listitem == 5) // Shotguns
			{
				ShowPlayerDialog(playerid, DIALOGID+6, DIALOG_STYLE_LIST, "Select a Weapon", "Standard Shotgun\nSawnoff Shotgun\nCombat Shotgun", "Select", "Cancel");
			}
            if(listitem == 6) // Misc
			{
				ShowPlayerDialog(playerid, DIALOGID+7, DIALOG_STYLE_LIST, "Select a Weapon", "Fire Extinguisher\nParachute\nNightvision Goggles\nFlowers", "Select", "Cancel");
			}
		}
		return 1;
	}

	if(dialogid == DIALOGID+1) // Meele 
	{
		if(response)
		{
			if(listitem == 0) 
			{
				GivePlayerWeapon(playerid, 1, 1);
			}
			if(listitem == 1) 
			{
				GivePlayerWeapon(playerid, 2, 1);
			}
			if(listitem == 2)
			{
				GivePlayerWeapon(playerid, 3, 1);
			}
			if(listitem == 3)
			{
				GivePlayerWeapon(playerid, 5, 1);
			}
			if(listitem == 4)
			{
				GivePlayerWeapon(playerid, 6, 1);
			}
			if(listitem == 5)
			{
				GivePlayerWeapon(playerid, 7, 1);
			}
			if(listitem == 6)
			{
				GivePlayerWeapon(playerid, 8, 1);
			}
			if(listitem == 7)
			{
				GivePlayerWeapon(playerid, 10, 1);
			}
			if(listitem == 8)
			{
				GivePlayerWeapon(playerid, 41, 500);
			}
            if(listitem == 9)
			{
				GivePlayerWeapon(playerid, 15, 1);
			}
		}
		return 1;
	}
	
	if(dialogid == DIALOGID+2) // Pistols
	{
		if(response)
		{
			if(listitem == 0) 
			{
				GivePlayerWeapon(playerid, 22, 500);
			}
			if(listitem == 1) 
			{
				GivePlayerWeapon(playerid, 23, 500);
			}
			if(listitem == 2) 
			{
				GivePlayerWeapon(playerid, 24, 500);
			}
		}
		return 1;
	}
	
	if(dialogid == DIALOGID+3) // Sub's
	{
		if(response)
		{
			if(listitem == 0)
			{
				GivePlayerWeapon(playerid, 28, 500);
			}
			if(listitem == 1) 
			{
				GivePlayerWeapon(playerid, 29, 500);
			}
			if(listitem == 2) 
			{
				GivePlayerWeapon(playerid, 32, 500);
			}
		}
		return 1;
	}
	
	if(dialogid == DIALOGID+4) // Rifle's
	{
		if(response)
		{
			if(listitem == 0)
			{
				GivePlayerWeapon(playerid, 33, 500);
			}
			if(listitem == 1)
			{
				GivePlayerWeapon(playerid, 34, 500);
			}
		}
		return 1;
	}

	if(dialogid == DIALOGID+5) // Assault
	{
		if(response)
		{
			if(listitem == 0) 
			{
				GivePlayerWeapon(playerid, 30, 500);
			}
			if(listitem == 1)
			{
				GivePlayerWeapon(playerid, 31, 500);
			}
		}
		return 1;
	}
	
	if(dialogid == DIALOGID+6) // Shotguns
	{
		if(response)
		{
			if(listitem == 0)
			{
				GivePlayerWeapon(playerid, 25, 500);
			}
			if(listitem == 1) 
			{
				GivePlayerWeapon(playerid, 26, 500);
			}
			if(listitem == 2)
			{
	  			GivePlayerWeapon(playerid, 27, 500);
			}
		}
		return 1;
	}

	if(dialogid == DIALOGID+7) // Misc Fire Extinguisher\nSatchel Charge\nParachute\nNightvision Goggles\nFlowers
	{
		if(response)
		{
			if(listitem == 0) 
			{
				GivePlayerWeapon(playerid, 42, 500);
			}
			if(listitem == 1)
			{
				GivePlayerWeapon(playerid, 46, 1);
			}
			if(listitem == 2)
			{
				GivePlayerWeapon(playerid, 44, 1);
			}
			if(listitem == 3)
			{
				GivePlayerWeapon(playerid, 14, 1);
   			}
		}
		return 1;
 	}
	return 0;
}
Код:
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : error 017: undefined symbol "file"
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : error 017: undefined symbol "file"
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : error 029: invalid expression, assumed zero
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : fatal error 107: too many error messages on one line
Reply
#2

updated EDIT.
Reply
#3

sorry dont knew about it !
Reply
#4

pawn Код:
new file;
??
Reply
#5

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
pawn Код:
new file;
??
BOOM!

Код HTML:
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : error 035: argument type mismatch (argument 1)
E:\Global Freeroam\filterscripts\wmenu.pwn(10) : error 035: argument type mismatch (argument 1)
E:\Global Freeroam\filterscripts\wmenu.pwn(11) : warning 217: loose indentation
E:\Global Freeroam\filterscripts\wmenu.pwn(11) : error 017: undefined symbol "dini_Exists"
E:\Global Freeroam\filterscripts\wmenu.pwn(13) : error 017: undefined symbol "dini_Create"
E:\Global Freeroam\filterscripts\wmenu.pwn(14) : error 017: undefined symbol "dini_IntSet"
E:\Global Freeroam\filterscripts\wmenu.pwn(14) : warning 215: expression has no effect
E:\Global Freeroam\filterscripts\wmenu.pwn(14) : error 001: expected token: ";", but found "]"
E:\Global Freeroam\filterscripts\wmenu.pwn(14) : error 029: invalid expression, assumed zero
E:\Global Freeroam\filterscripts\wmenu.pwn(14) : fatal error 107: too many error messages on one line
Reply
#6

Convert to Y_INI man. It rocks and you have more tutorial. And i can help you with weapon saving with y_ini!
Reply
#7

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
Convert to Y_INI man. It rocks and you have more tutorial. And i can help you with weapon saving with y_ini!
and i dont know how to convert it. thanks anyway hopefully someone convert it for me.
Reply
#8

Lol you don't even have dini included?
pawn Код:
#include <dini>
Reply
#9

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Lol you don't even have dini included?
pawn Код:
#include <dini>
I forgot but, still same error.
Reply
#10

Download Y_INI and then convert it, DINI is just buggy to be honest, if no one wishes to convert it for you, I shall do it once I return home from school.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)