Skill system, help me again psz
#1

Hello,
I've a problem with my new skill system... every time i restart closing and start my samp-server.exe it not load scriptfiles where it save the skills level, kills and skill points...

this is my code:
Код:
// Weapon skills by DarK_FeneR
#define FILTERSCRIPT

#include <a_samp>
#include <Dini>
#include <Dutils>
#include <Dudb>

#define COLOR_RED   0xFF0000FF
#define COLOR_BLUE   0x0004FFFF
#define COLOR_GREEN   0x00FF55FF
#define COLOR_YELLOW   0xEAFF00FF
#define COLOR_ORANGE   0xFFB300FF
#define COLOR_BLACK   0x000000FF
#define COLOR_WHITE   0xFFFFFFFF

#define DIALOG_SKILLS 15

#define savefolder "/skills/%s.ini"

#pragma unused ret_memcpy

new Killz[MAX_PLAYERS];
new Skillz_Pt[MAX_PLAYERS];
new Skillz_Weap[MAX_PLAYERS];
new Skillz_Armour[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("Weapon Skill FS by DarK_FeneR LOADED");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print("Weapon Skill FS by DarK_FeneR UNLOADED");
	print("----------------------------------\n");
}

#endif

public OnPlayerConnect(playerid)
{
    new pname[128];  // This get's the length of the player name
    new file[128];        // This get's the lenght of the file
    GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the lenght of the player name
    format(file, sizeof(file), savefolder,pname); // This describe's where to save and how to save it
    if(!dini_Exists(file)) { // If the file exist
        dini_Create(file); // Create the file
        dini_IntSet(file, "Kills", Killz[playerid]); // Set's "Kills"
        dini_IntSet(file, "Skill_Pt", Skillz_Pt[playerid]); // Set's "Skill_Weap"
        dini_IntSet(file, "Skill_Weap", Skillz_Weap[playerid]);
		dini_IntSet(file, "Skill_Armo", Skillz_Armour[playerid]); // Set's "Skill_Weap"
        // and at last this set's the value which were on the file
    }
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new pname[128]; // The name length
    new file[128]; // The file length
    GetPlayerName(playerid, pname, sizeof(pname)); //  This get's the player name with the name length
    format(file, sizeof(file), savefolder,pname);
    if(!dini_Exists(file)) {
    }
    else
	{ // if not
        dini_IntSet(file, "Kills", Killz[playerid]);
        dini_IntSet(file, "Skill_Pt", Skillz_Pt[playerid]); // Set's "Skill_Weap"
        dini_IntSet(file, "Skill_Weap", Skillz_Weap[playerid]);
        dini_IntSet(file, "Skill_Armo", Skillz_Armour[playerid]);
    }
	return 1;
}

public OnPlayerSpawn(playerid)
{
    if(Killz[playerid]==10)//livello 1 skill
    {
        Skillz_Pt[playerid] ++;
		Killz[playerid]=0;
	}
	if(Skillz_Weap[playerid]>=1)
	{
         GivePlayerWeapon(playerid,42,100);
         if(Skillz_Weap[playerid]>=2)
         {
               GivePlayerWeapon(playerid,39,15);
               if(Skillz_Weap[playerid]==3)
               {
                      GivePlayerWeapon(playerid,35,15);
			   }
		 }
	}
	if(Skillz_Armour[playerid]==1)
	{
		 SetPlayerArmour(playerid, 10);
	}
	if(Skillz_Armour[playerid]==2)
	{
		 SetPlayerArmour(playerid, 20);
	}
	if(Skillz_Armour[playerid]==3)
	{
		 SetPlayerArmour(playerid, 30);
	}
	if(Skillz_Armour[playerid]==4)
	{
		 SetPlayerArmour(playerid, 40);
	}
	if(Skillz_Armour[playerid]==5)
	{
		 SetPlayerArmour(playerid, 50);
	}
	if(Skillz_Armour[playerid]==6)
	{
		 SetPlayerArmour(playerid, 60);
	}
	if(Skillz_Armour[playerid]==7)
	{
		 SetPlayerArmour(playerid, 70);
	}
	if(Skillz_Armour[playerid]==8)
	{
		 SetPlayerArmour(playerid, 80);
	}
	if(Skillz_Armour[playerid]==9)
	{
		 SetPlayerArmour(playerid, 90);
	}
	if(Skillz_Armour[playerid]==10)
	{
		 SetPlayerArmour(playerid, 100);
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/skills", true) == 0)
    {
        ShowPlayerDialog(playerid,DIALOG_SKILLS,DIALOG_STYLE_LIST,"Skill Menu","Armi\nVita","OK","ANNULLA");
        return 1;
    }
    if(strcmp(cmdtext, "/skillspt", true) == 0)
    {
        Skillz_Pt[playerid] ++;
        return 1;
    }
	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(listitem == 0)
	{
        if(Skillz_Pt[playerid]>=1)//If they have more or equal to the price.
        {
			 if(Skillz_Weap[playerid]<=2)
			 {
			      Skillz_Pt[playerid] --;
			      Skillz_Weap[playerid] ++;
                  SendClientMessage(playerid,COLOR_GREEN,"Hai uppato la Skill Armi di 1 livello");
			 }

		}
		else
		{
             SendClientMessage(playerid,COLOR_RED,"Non hai abbastanza Punti Skill per uppare!");//Tell them.
		}
	}
	if(listitem == 1)
	{
        if(Skillz_Pt[playerid]>=1)//If they have more or equal to the price.
        {
			 if(Skillz_Armour[playerid]<=9)
			 {
			      Skillz_Pt[playerid] --;
			      Skillz_Armour[playerid] ++;
                  SendClientMessage(playerid,COLOR_GREEN,"Hai uppato la Skill Armatura di 1 livello");
			 }

		}
		else
		{
             SendClientMessage(playerid,COLOR_RED,"Non hai abbastanza Punti Skill per uppare!");//Tell them.
		}
	}
	return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
    Killz[killerid] ++; // The killer value will be increased
	return 1;
}
Reply
#2

Nothing
Reply
#3

pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];  // This get's the length of the player name
    new file[128];        // This get's the lenght of the file
    GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the lenght of the player name
    format(file, sizeof(file), savefolder,pname); // This describe's where to save and how to save it
    if(dini_Exists(file)) { // If the file exist
        Killz[playerid] = dini_Int(file, "Kills"); // Set's "Kills"
        Skillz_Pt[playerid] = dini_Int(file, "Skill_Pt"); // Set's "Skill_Weap"
        Skillz_Weap[playerid] = dini_Int(file, "Skill_Weap");
    Skillz_Armour[playerid] = dini_Int(file, "Skill_Armo"); // Set's "Skill_Weap"
        // and at last this set's the value which were on the file
    }
    return 1;
}
But this method is bad, because anyone who connects with existing username can get its stats. You should make proper registration system.
Reply
#4

You can give me any tutorial?
Reply
#5

http://forum.sa-mp.com/forumdisplay.php?f=70
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)