Score Timer Not Working properly..
#2

Here is My filterscript of it.


Here you go.


Код:
//                                  Score Saving by Joker
#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <foreach>
#if defined FILTERSCRIPT

#define SAVE_SCORE true

#define SERVER_USER_FILE "Users/%s.ini"
#include "../include/gl_common.inc"
#if SAVE_SCORE == true
enum pInfo
{
    pScore
}
#endif
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Score Saving by Joker loaded");
	print("--------------------------------------\n");
	SetTimer("scoretimer", 60*1000, true);
	return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
	print(" Score Saving by Joker unloaded");
	print("--------------------------------------\n");
	return 1;
}
public OnPlayerConnect(playerid)
{
	 #if SAVE_SCORE == true
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
    if (!dini_Exists(file))
    {
    	dini_Create(file);
        dini_IntSet(file, "Score",SetPlayerScore(playerid,0));
    }
    if(fexist(file))
    {
        SetPlayerScore(playerid,dini_Int(file, "Score"));
    }
    #endif
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	  #if SAVE_SCORE == true
	new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
	dini_IntSet(file, "Score", GetPlayerScore(playerid));
	#endif
	return 1;
}
forward scoretimer();
public scoretimer()
{
    foreach(Player,i)
    {
        if(IsPlayerConnected(i) == 1)
            AddScoreForPlayer(i,1);
    }
    return 1;
}
#endif

stock AddScoreForPlayer(playerid,score)
{
  return SetPlayerScore(playerid,GetPlayerScore(playerid)+score);
}
Enjoy .


P.S: Here is Pastebin direct link : http://pastebin.com/cBmgTQW5
Hope this helped you
(rep+ :P)
Reply


Messages In This Thread
Score Timer Not Working properly.. - by kbalor - 31.07.2012, 18:23
Re: Score Timer Not Working properly.. - by Majed - 31.07.2012, 18:29
Re: Score Timer Not Working properly.. - by kbalor - 31.07.2012, 18:43
Re: Score Timer Not Working properly.. - by Majed - 31.07.2012, 18:45
Re: Score Timer Not Working properly.. - by kbalor - 31.07.2012, 18:52
Re: Score Timer Not Working properly.. - by Majed - 31.07.2012, 19:08
Re: Score Timer Not Working properly.. - by RelaxCafe - 31.07.2012, 19:15
Re: Score Timer Not Working properly.. - by XStormiest - 31.07.2012, 19:17
Re: Score Timer Not Working properly.. - by Majed - 31.07.2012, 19:18
Re: Score Timer Not Working properly.. - by XStormiest - 31.07.2012, 19:21

Forum Jump:


Users browsing this thread: 2 Guest(s)