SA-MP Forums Archive
[Tutorial] How To Make Score System With Timers - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How To Make Score System With Timers (/showthread.php?tid=207768)



How To Make Score System With Timers - -•♥♠♦♣-•Arshavin•-♥♠♦♣•- - 06.01.2011

How To Make Score System With Timers
Introduction
I'll be showing u today how to make score system with timers....
first we will be defining them then set the timers then set the publics to gain score and killtimers after u gain it
so it doesnt just reapet all over and i'll be making if player already have score < 2 ,, 2= number of timers scores u did so if u loged out and loged in just doesnt repeat

The Start

so first lets define our timers
pawn Code:
new ScoreTimer1[MAX_PLAYERS];
new ScoreTimer2[MAX_PLAYERS];
Scripting

so now we will set the timers

pawn Code:
ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);
ScoreTimer2[playerid] = SetTimerEx("AddScore2", 120000, true, "i", playerid);
60000 = 1minute with milliseconds cuase timers aint 1 = second so
1000 = 1second 1minute = 60000 1hr = 3,600,000 so if u want it by hours just multiply 3,600,000 x [number of hrs] to get u the number of hrs u want in milliseconds same with minutes 60000 x [number of mins]

So after ur done with setting ur timers now lets go to the part of gaining score and killtimer after the timer pass
and gaining the score ...

pawn Code:
forward AddScore1(playerid);
public AddScore1(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    new string[200];
    format(string, sizeof(string, "~g~U're now level 1 Congratz");
    GameTextForPlayer(playerid, string, 1000, 0);
    KillTimer(ScoreTimer1[playerid]);
    if(GetPlayerScore(playerid) < 2)
    {
               KillTimer(ScoreTimer1[playerid]);
    }
    return 1;
}
pawn Code:
forward AddScore2(playerid);
public AddScore2(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    new string[200];
    format(string, sizeof(string, "~g~U're now level 2 Congratz");
    GameTextForPlayer(playerid, string, 1000, 0);
    KillTimer(ScoreTimer2[playerid]);
    if(GetPlayerScore(playerid) < 2) // Change the < 2 of the numbers to the number of scoretimers u got
    {
               KillTimer(ScoreTimer2[playerid]);
    }
    return 1;
}
Summary


In This Tutorial we used timers and game texts

1st (First): we defined them

2nd (Second): we set the timers

3rd (Third): we set the publics for gaining scores and killtimers


Conclusion


Now if u stayed 1minute online on server u gonna be lvl 1 means +1 then 2minutes lvl2 +1 more so score2
So i was showing u ex: for 2 scoretimers u can just keep adding to the number of lvls u want
I Hope it was good tutorial if you got any errors i'll be glad to help post ur errors in a comment please


Ok Thanks For Reading my tutorial i hope it was usefull for ur server Don't worry if u got any errors just post it down here and i'll help
PS: If something u didnt understand in my explanation just post it and i'll explain it Bai!

Arshavin, Thanks bb..


AW: How To Make Score System With Timers - NuggaN_ - 08.01.2011

Nice one


Re: How To Make Score System With Timers - Souvlaki - 08.01.2011

Nevermind


Re: How To Make Score System With Timers - admantis - 08.01.2011

Wow.. and I need to add this 30 times for 30 levels?. There are more efficent ways, nice tuts.


Re: How To Make Score System With Timers - Lorenc_ - 08.01.2011

Quote:
Originally Posted by admantis
View Post
Wow.. and I need to add this 30 times for 30 levels?. There are more efficent ways, nice tuts.
Lol'd. Just make one timer and a varible.

pawn Code:
new LevelPlayer[MAX_PLAYERS];
So every 2 minutes for example put inside the timers callback

pawn Code:
public Timer(playerid)
{
      LevelPlayer[playerid]++;
      new string[50];
      format(string, sizeof(string), "You are now level %i.",LevelPlayer[playerid]);
      SendClientMessage(playerid, COLOR_, string);
      return 1;
}

Get me? Yea and anyway nice tut.


AW: How To Make Score System With Timers - NuggaN_ - 08.01.2011

And how do I add respect points. So they get respect points each hour. For example theyre level 1, for level 2 they need 6 respect points. After playing 6hours they got 6/6. They have to do /buylevel and they get into level 2. So, for level 3 they need play 8hours (so they need 8 respect points) after playing 8h and they've got 8/8 /buylevel etc. If they have 4/6 for example by level 1, they should not be allowed to buy next level.
Could anyone tell me how to do it?


Re: How To Make Score System With Timers - admantis - 08.01.2011

Quote:
Originally Posted by Lorenc_
View Post
Lol'd. Just make one timer and a varible.

pawn Code:
new LevelPlayer[MAX_PLAYERS];
So every 2 minutes for example put inside the timers callback

pawn Code:
public Timer(playerid)
{
      LevelPlayer[playerid]++;
      new string[50];
      format(string, sizeof(string), "You are now level %i.",LevelPlayer[playerid]);
      SendClientMessage(playerid, COLOR_, string);
      return 1;
}

Get me? Yea and anyway nice tut.
I know, it's a bit ironic, It's obvious and I could easily do that, but I mean, he did it in a very cheap way.

_NuggaN you should learn scripting and not make a RP from scratch when you're a beginner.


Re: How To Make Score System With Timers - Lorenc_ - 08.01.2011

Btw, via my system to add timing
pawn Code:
new NewTime[MAX_PLAYERS];
Ongamemodeonit:
pawn Code:
SetTimerEx("AddScore1", NewTime[playerid], true, "i", playerid);
A timer to detect if the player is level 0..
pawn Code:
if(LevelPlayer[playerid] == 0)
      {
              NewTime[playerid] = 60000;
      }
pawn Code:
public Timer(playerid)
{
      LevelPlayer[playerid]++;
      NewTime[playerid] = NewTime[playerid] + 60000;
      new string[50];
      format(string, sizeof(string), "You are now level %i.",LevelPlayer[playerid]);
      SendClientMessage(playerid, COLOR_, string);
      return 1;
}
I think its like for adding extra time, correct me if im wrong there, UNTESTED.


Re: AW: How To Make Score System With Timers - Tee - 08.01.2011

Quote:
Originally Posted by NuggaN_
View Post
And how do I add respect points. So they get respect points each hour. For example theyre level 1, for level 2 they need 6 respect points. After playing 6hours they got 6/6. They have to do /buylevel and they get into level 2. So, for level 3 they need play 8hours (so they need 8 respect points) after playing 8h and they've got 8/8 /buylevel etc. If they have 4/6 for example by level 1, they should not be allowed to buy next level.
Could anyone tell me how to do it?
Make a function that is called every hour and give the player 1 score every hour, i don't know if that's what you mean. Is it?


Re: How To Make Score System With Timers - ToPhrESH - 08.01.2011

Nice job Arshavin!


Re: How To Make Score System With Timers - -•♥♠♦♣-•Arshavin•-♥♠♦♣•- - 08.01.2011

Quote:
Originally Posted by ToPhrESH
Посмотреть сообщение
Nice job Arshavin!
Thanks


Re: AW: How To Make Score System With Timers - -•♥♠♦♣-•Arshavin•-♥♠♦♣•- - 08.01.2011

Quote:
Originally Posted by Tee
View Post
Make a function that is called every hour and give the player 1 score every hour, i don't know if that's what you mean. Is it?
no i think he ment for ex he must do 6/6 points to gain 1+ score so each ??/6 points = number of mins online to make him pass to a point so wht will happen is 1/6 2/6 3/6 ... until it reach 6/6 then he /buylevel then it give him 1 score then turns to 6/12 or smthin


Re: How To Make Score System With Timers - Stefand - 13.11.2011

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Btw, via my system to add timing
pawn Код:
new NewTime[MAX_PLAYERS];
Ongamemodeonit:
pawn Код:
SetTimerEx("AddScore1", NewTime[playerid], true, "i", playerid);
A timer to detect if the player is level 0..
pawn Код:
if(LevelPlayer[playerid] == 0)
      {
              NewTime[playerid] = 60000;
      }
pawn Код:
public Timer(playerid)
{
      LevelPlayer[playerid]++;
      NewTime[playerid] = NewTime[playerid] + 60000;
      new string[50];
      format(string, sizeof(string), "You are now level %i.",LevelPlayer[playerid]);
      SendClientMessage(playerid, COLOR_, string);
      return 1;
}
I think its like for adding extra time, correct me if im wrong there, UNTESTED.

Can you help me with that score thing becouse i get errors :S


Re: How To Make Score System With Timers - Kostas' - 13.11.2011

You forgot the ")"
pawn Код:
format(string, sizeof(string, "~g~U're now level 1 Congratz");
Should be
pawn Код:
format(string, sizeof(string), "~g~U're now level 1 Congratz");



Re: How To Make Score System With Timers - Janek17 - 21.12.2011

Yeah nice tutorial..


Re: How To Make Score System With Timers - LaGrande - 29.04.2012

Nice, it helped me alot


Re: How To Make Score System With Timers - ReD_HunTeR - 01.12.2012

Nice Job Keep it Up


Re: How To Make Score System With Timers - xMCx - 05.12.2012

theres a little mistake here
pawn Код:
forward AddScore1(playerid);
public AddScore1(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    new string[200];//here
    format(string, sizeof(string, "~g~U're now level 1 Congratz");//here
    GameTextForPlayer(playerid, string, 1000, 0);//here
    KillTimer(ScoreTimer1[playerid]);
    if(GetPlayerScore(playerid) < 2)
    {
               KillTimer(ScoreTimer1[playerid]);
    }
    return 1;
}
pawn Код:
format(string, sizeof(string, "~g~U're now level 1 Congratz");//your not using any value here like %i or %s so you
//you dont need to format it so you can simply add this?
GameTextForPlayer(playerid, "~g~your now level 1 Gratz", 1000, 0);//easily without adding string it would take more memory cause of its size
but its not a big problem it will work anyways, thanks nice tut!


Re: How To Make Score System With Timers - --LooD-- - 05.12.2012

Nice tut


Re: How To Make Score System With Timers - UserName31 - 01.02.2014

Quote:
Originally Posted by -•♥♠♦♣-•Arshavin•-♥♠♦♣•-
Посмотреть сообщение
How To Make Score System With Timers
Introduction
I'll be showing u today how to make score system with timers....
first we will be defining them then set the timers then set the publics to gain score and killtimers after u gain it
so it doesnt just reapet all over and i'll be making if player already have score < 2 ,, 2= number of timers scores u did so if u loged out and loged in just doesnt repeat

The Start

so first lets define our timers
pawn Код:
new ScoreTimer1[MAX_PLAYERS];
new ScoreTimer2[MAX_PLAYERS];
Scripting

so now we will set the timers

pawn Код:
ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);
ScoreTimer2[playerid] = SetTimerEx("AddScore2", 120000, true, "i", playerid);
60000 = 1minute with milliseconds cuase timers aint 1 = second so
1000 = 1second 1minute = 60000 1hr = 3,600,000 so if u want it by hours just multiply 3,600,000 x [number of hrs] to get u the number of hrs u want in milliseconds same with minutes 60000 x [number of mins]

So after ur done with setting ur timers now lets go to the part of gaining score and killtimer after the timer pass
and gaining the score ...

pawn Код:
forward AddScore1(playerid);
public AddScore1(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    new string[200];
    format(string, sizeof(string, "~g~U're now level 1 Congratz");
    GameTextForPlayer(playerid, string, 1000, 0);
    KillTimer(ScoreTimer1[playerid]);
    if(GetPlayerScore(playerid) < 2)
    {
               KillTimer(ScoreTimer1[playerid]);
    }
    return 1;
}
pawn Код:
forward AddScore2(playerid);
public AddScore2(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    new string[200];
    format(string, sizeof(string, "~g~U're now level 2 Congratz");
    GameTextForPlayer(playerid, string, 1000, 0);
    KillTimer(ScoreTimer2[playerid]);
    if(GetPlayerScore(playerid) < 2) // Change the < 2 of the numbers to the number of scoretimers u got
    {
               KillTimer(ScoreTimer2[playerid]);
    }
    return 1;
}
Summary


In This Tutorial we used timers and game texts

1st (First): we defined them

2nd (Second): we set the timers

3rd (Third): we set the publics for gaining scores and killtimers


Conclusion


Now if u stayed 1minute online on server u gonna be lvl 1 means +1 then 2minutes lvl2 +1 more so score2
So i was showing u ex: for 2 scoretimers u can just keep adding to the number of lvls u want
I Hope it was good tutorial if you got any errors i'll be glad to help post ur errors in a comment please


Ok Thanks For Reading my tutorial i hope it was usefull for ur server Don't worry if u got any errors just post it down here and i'll help
PS: If something u didnt understand in my explanation just post it and i'll explain it Bai!

Arshavin, Thanks bb..
PHP код:
C:\Users\Elvis VJR\Desktop\FreeRoams Los Santos GangWar!\gamemodes\GW.pwn(2093) : error 001expected token")"but found ","
C:\Users\Elvis VJR\Desktop\FreeRoams Los Santos GangWar!\gamemodes\GW.pwn(2108) : error 001expected token")"but found ","
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors