Weapon Loading
#1

Hey Guys,
I've got a little problem with reading weapons out of a file with dini. I wrote a script which saves the Weapon Slots to the player-ini file, but I can't load the weapons. Maybe someone of you can help me.



Here is the code: ("Waffe" is german for weapon and "Munition" means ammo )

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <dini>

    new Waffe0;
    new Munition0;
    new Waffe1;
    new Munition1;
    new Waffe2;
    new Munition2;
    new Waffe3;
    new Munition3;
    new Waffe4;
    new Munition4;
    new Waffe5;
    new Munition5;
    new Waffe6;
    new Munition6;
    new Waffe7;
    new Munition7;
    new Waffe8;
    new Munition8;
    new Waffe9;
    new Munition9;
    new Waffe10;
    new Munition10;
    new Waffe11;
    new Munition11;
    new Waffe12;
    new Munition12;

#if defined FILTERSCRIPT





public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("Weapon Saver");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print("Weapon Saver");
	print("----------------------------------\n");
}

#endif

public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], path[200];  
    GetPlayerName(playerid, pname, sizeof(pname));
    format(path, sizeof(path), "/spieler/%s.ini", pname);

    new waffe;
    new munition;
	
    if(!dini_Exists(path))
    {
    dini_Create(path);
    }
    else
    {}
	
    //Waffen Slots abspeichern
    GetPlayerWeaponData(playerid, 0, waffe, munition);	//Slot 1
    dini_IntSet(path, "Waffe_Slot0", waffe);
    dini_IntSet(path, "Munition_Slot0", munition);
 	
    GetPlayerWeaponData(playerid, 1, waffe, munition);  //Slot 2
    dini_IntSet(path, "Waffe_Slot1", waffe);
    dini_IntSet(path, "Munition_Slot1", munition);

	GetPlayerWeaponData(playerid, 2, waffe, munition);  //Slot 3
    dini_IntSet(path, "Waffe_Slot2", waffe);
	dini_IntSet(path, "Munition_Slot2", munition);

	GetPlayerWeaponData(playerid, 3, waffe, munition);  //Slot 4
    dini_IntSet(path, "Waffe_Slot3", waffe);
	dini_IntSet(path, "Munition_Slot3", munition);

	GetPlayerWeaponData(playerid, 4, waffe, munition);  //Slot 5
    dini_IntSet(path, "Waffe_Slot4", waffe);
	dini_IntSet(path, "Munition_Slot4", munition);

	GetPlayerWeaponData(playerid, 5, waffe, munition);  //Slot 6
    dini_IntSet(path, "Waffe_Slot5", waffe);
	dini_IntSet(path, "Munition_Slot5", munition);

	GetPlayerWeaponData(playerid, 6, waffe, munition);  //Slot 7
    dini_IntSet(path, "Waffe_Slot6", waffe);
	dini_IntSet(path, "Munition_Slot6", munition);
	
	GetPlayerWeaponData(playerid, 7, waffe, munition);  //Slot 8
    dini_IntSet(path, "Waffe_Slot7", waffe);
	dini_IntSet(path, "Munition_Slot7", munition);
	
	GetPlayerWeaponData(playerid, 8, waffe, munition);  //Slot 9
    dini_IntSet(path, "Waffe_Slot8", waffe);
	dini_IntSet(path, "Munition_Slot8", munition);

	GetPlayerWeaponData(playerid, 9, waffe, munition);  //Slot 10
    dini_IntSet(path, "Waffe_Slot9", waffe);
	dini_IntSet(path, "Munition_Slot9", munition);
	
	GetPlayerWeaponData(playerid, 10, waffe, munition);  //Slot 11
    dini_IntSet(path, "Waffe_Slot10", waffe);
	dini_IntSet(path, "Munition_Slot10", munition);
	
    GetPlayerWeaponData(playerid, 11, waffe, munition);  //Slot 12
    dini_IntSet(path, "Waffe_Slot11", waffe);
	dini_IntSet(path, "Munition_Slot11", munition);
	
	GetPlayerWeaponData(playerid, 12, waffe, munition);  //Slot 13
    dini_IntSet(path, "Waffe_Slot12", waffe);
	dini_IntSet(path, "Munition_Slot12", munition);
	
	return 1;
}

public OnPlayerSpawn(playerid)
{
    new pname[MAX_PLAYER_NAME], path[200];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(path, sizeof(path), "/spieler/%s.ini", pname);
    
    
	Waffe0 = dini_Int(path, "Waffe_Slot0");
	Munition0 = dini_Int(path, "Munition_Slot0");
	Waffe1 = dini_Int(path, "Waffe_Slot1");
    Munition1 = dini_Int(path, "Munition_Slot1");
    Waffe2 = dini_Int(path, "Waffe_Slot2");
    Munition2 = dini_Int(path, "Munition_Slot2");
    Waffe3 = dini_Int(path, "Waffe_Slot3");
    Munition3 = dini_Int(path, "Munition_Slot3");
    Waffe4 = dini_Int(path, "Waffe_Slot4");
    Munition4 = dini_Int(path, "Munition_Slot4");
    Waffe5 = dini_Int(path, "Waffe_Slot5");
    Munition5 = dini_Int(path, "Munition_Slot5");
    Waffe6 = dini_Int(path, "Waffe_Slot6");
    Munition6 = dini_Int(path," Munition_Slot6");
    Waffe7 = dini_Int(path, "Waffe_Slot7");
    Munition7 = dini_Int(path, "Munition_Slot7");
    Waffe8 = dini_Int(path, "Waffe_Slot8");
    Munition8 = dini_Int(path, "Munition_Slot8");
    Waffe9 = dini_Int(path, "Waffe_Slot9");
    Munition9 = dini_Int(path, "Munition_Slot9");
    Waffe10 = dini_Int(path, "Waffe_Slot10");
    Munition10 = dini_Int(path, "Munition_Slot10");
    Waffe11 = dini_Int(path, "Waffe_Slot11");
    Munition11 = dini_Int(path, "Munition_Slot11");
    Waffe12 = dini_Int(path, "Waffe_Slot12");
    Munition12 = dini_Int(path, "Munition_Slot12");

    //Waffen dem Spieler zuweisen
    GivePlayerWeapon(playerid, Waffe0, Munition0); //Slot 1
    GivePlayerWeapon(playerid, Waffe1, Munition1); //Slot 2
    GivePlayerWeapon(playerid, Waffe2, Munition2); //Slot 3
	GivePlayerWeapon(playerid, Waffe3, Munition3); //Slot 4
	GivePlayerWeapon(playerid, Waffe4, Munition4); //Slot 5
	GivePlayerWeapon(playerid, Waffe5, Munition5); //Slot 6
	GivePlayerWeapon(playerid, Waffe6, Munition6); //Slot 7
	GivePlayerWeapon(playerid, Waffe7, Munition7); //Slot 8
	GivePlayerWeapon(playerid, Waffe8, Munition8); //Slot 9
	GivePlayerWeapon(playerid, Waffe9, Munition9); //Slot 10
	GivePlayerWeapon(playerid, Waffe10, Munition10); //Slot 11
	GivePlayerWeapon(playerid, Waffe11, Munition11); //Slot 12
	GivePlayerWeapon(playerid, Waffe12, Munition12); //Slot 13
    
    
	return 1;
}
I've already posted this in the German section, but I don't get answers there, so I'll give it a try here.
Reply
#2

Any Solutions? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)