SA-MP Forums Archive
Score Timer Not Working properly.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Score Timer Not Working properly.. (/showthread.php?tid=364738)



Score Timer Not Working properly.. - kbalor - 31.07.2012

Any can check this script if it is correct?

new seconds[MAX_PLAYERS];


pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) continue;
        {
         seconds[i] ++;
         if(seconds[i] >= 1800)
         {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
         }
       }
    }
    return 1;
}
public OnPlayerConnect(playerid)
seconds[playerid] = 0; //Count Score timer


Re: Score Timer Not Working properly.. - Majed - 31.07.2012

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)


Re: Score Timer Not Working properly.. - kbalor - 31.07.2012

Quote:
Originally Posted by Majed
Посмотреть сообщение
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)
OMG thank so much! Thanks for sharing + rep can i changed time to 30 minutes = 1 score??


Re: Score Timer Not Working properly.. - Majed - 31.07.2012

Quote:
Originally Posted by kbalor
Посмотреть сообщение
OMG thank so much! Thanks for sharing + rep can i changed time to 30 minutes = 1 score??
Yes indeed.
if 60000=1 minute, then count on how much will be for 30 minutes.

60,000x30=1,800,000

So set it 1,800,000 = 30 minutes.

Enjoy


Re: Score Timer Not Working properly.. - kbalor - 31.07.2012

Quote:
Originally Posted by Majed
Посмотреть сообщение
Yes indeed.
if 60000=1 minute, then count on how much will be for 30 minutes.

60,000x30=1,800,000

So set it 1,800,000 = 30 minutes.

Enjoy
Oh I see but to make it clear ill change 60*1000 (1000 to 1800)?


Re: Score Timer Not Working properly.. - Majed - 31.07.2012

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Oh I see but to make it clear ill change 60*1000 (1000 to 1800)?
60*1000(1000 to 1800)<-- Wrong.


180000<- like this.


Re: Score Timer Not Working properly.. - RelaxCafe - 31.07.2012

Just do this, now if you know how to read time, this will be easier:
y*1000=y seconds
3*1000 = 3 seconds
y*60*1000 = y minutes
3*60*1000 = 3 minutes..

It couldn't be easier..


Re: Score Timer Not Working properly.. - XStormiest - 31.07.2012

an hour 3.600.000 so 1.800.000 for a 30 min

try
pawn Код:
SetTimer("scoretimer", 60*1000*3, true); // so will be 1.800.000 :D



Re: Score Timer Not Working properly.. - Majed - 31.07.2012

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
an hour 3.600.000 so 1.800.000 for a 30 min

try
pawn Код:
SetTimer("scoretimer", 60*1000*3, true); // so will be 1.800.000 :D
Yes wanted to say this too xD.
Sorry lol :P


Re: Score Timer Not Working properly.. - XStormiest - 31.07.2012

if you know alrgorythm function this is easy , for example

in this
SetTimer("scoretimer", 60*1000-1000, true); // so will be 59 seconds because 60 * 1000 = 60.000 - 1.000 = 59.000