Score Timer Not Working properly..
#1

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
Reply
#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
#3

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??
Reply
#4

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
Reply
#5

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)?
Reply
#6

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.
Reply
#7

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..
Reply
#8

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
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)