+- +-

+-User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+-Stats ezBlock

Members
Total Members: 82
Latest: justinfloyd
New This Month: 0
New This Week: 0
New Today: 0
Stats
Total Posts: 50
Total Topics: 23
Most Online Today: 29
Most Online Ever: 34
(June 22, 2021, 04:58:42 am)
Users Online
Members: 0
Guests: 28
Total: 28

Author Topic: How to make a score system [1 score every minute]  (Read 631 times)

Offline Marsigne

  • Beta Tester
  • Little clucker
  • *****
  • Posts: 9
  • Reputation : 2
    • View Profile
How to make a score system [1 score every minute]
« on: May 19, 2012, 11:00:08 pm »
First step

In the first step I will show how to create a global variable that will control (and will be needed) the constants and the timer.
Now we will add this at the top of the script. Warning: must be on top of script but not above a_samp!! or else will give error. why on the top of the script? to make it a GLOBAL variable.

Code: [Select]
new GiveScoreTimer[MAX_PLAYERS];
with this new global variable we will control the score timer. the [MAX_PLAYERS] consist that will be to entire players (in other words, up to max players)
Warning: The new global variable must be at the end with the ; (semi colon). why? it is self explanatory, it is like the sentence. it finish the lines, or else it wont finish and will ruin an error.

Second step

In the second step I will show how to convert a variable to a timer and explain the functions.

Code: [Select]
GiveScoreTimer[playerid] = SetTimerEx ("GivePlayerScore", 1000*60, true, "d", playerid);
Now we converted the variable into a timer. I will explain the steps.

Code: [Select]
GiveScoreTimer[playerid]
The GiveScoreTimer is the variable, but you say, why playerid there?  well, playerid is for the player, but this works DEPENDING on where you put it to work. We will show later where will be put.

Code: [Select]
SetTimerEx ("GivePlayerScore", 1000*60, true, "d", playerid);
This is the converted timer. "GivePlayerScore" tells which variable will be used for the timer. the 1000*60 is 1000 x 60 = 60,000 that is 60 seconds in decimal. "true" is self explanatory. and playerid is for the player DEPENDING where you put it.

Third step

In the third step I will show where to put it and WHY put it there. As i said before, the playerid works DEPENDING on where you put it, now I will show you where to put it. Why to put it there? because there will work the playerid FOR all players.

Code: [Select]
public OnPlayerConnect(playerid)
{
    return 1;
}

Here you will put your converted timer so once the player connects the timer will run FOR the player (playerid). Now understand why playerid here, right? Now, we will do this....

Code: [Select]
public OnPlayerConnect(playerid)
{
    GiveScoreTimer[playerid] = SetTimerEx ("GivePlayerScore", 1000*60, true, "d", playerid);
    return 1;
}

Yes, put the converted timer above the return 1;. why? self explanatory, must be the timer before the public constant returns. if you put it after the return, it will return, THEN it will do the timer, so, it will be nothing.

Fourth step

In the fourth step I will show how to stop the timer once the player disconnects.
Now you will ask, but? when the timer stops? I tell you, It won't stop! But don't die, this can be fixed with just 1 constant!
go to here...

Code: [Select]
public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

Here is the part when the player disconnect. Now you say, How I stop it? Which constant? Wait, let me talk, I will do it just right now.

Code: [Select]
KillTimer(GiveScoreTimer[playerid]);
This constant is to "Kill" the timer, in other words, it stop the timer.
Now, We will do this...

Code: [Select]
public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(GiveScoreTimer[playerid]);
    return 1;
}

As I told before, it must be above the return, so it can return.

Fifth step

In the fourth step I will show to do a "score" in each minute. and of course, where.
Now you say, but... What will give me once a minute? Nothing? Wait, let me do the last step, to do the function to do a "score" every minute as I set it up on the timer.

Now in this part, we will do a forward, because we will make a custom function.
Let's go up all the script and put this....

Code: [Select]
forward GivePlayerScore(playerid);
Here this function will forward the public function. after you do this, as this is a public function, you can put this everywhere you put it DOWN (of course) the global variable and the a_samp. Here it is the code...

Code: [Select]
public GivePlayerScore(playerid)
{
    return 1;
}

Here we created the public function. Now here will set up the player score every minute as set up on the timer.

Now we will do this....

Code: [Select]
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
Now I will explain these steps.

Code: [Select]
SetPlayerScore
Here we "set" the player score to something... Let's follow...

Code: [Select]
(playerid, GetPlayerScore(playerid) + 1)
The playerid, of course, is to give the score to the player. and GetPlayerScore(playerid) + 1 is to give +1 score to the player.

Conclusion:
Nice tutorial, huh? Here I showed you how to create a score system. You can comment, You can suggest me to do other scripts, and I will do others too!
« Last Edit: May 20, 2012, 02:43:15 pm by Marsigne »

Share on Facebook Share on Twitter


Offline мυ∂υℓ_вacнα

  • Community Developer
  • God Father
  • ******
  • Posts: 1221
  • Reputation : 3
  • Location: London
    • View Profile
Hmmm realy good but i need the whole script as pastabin or pawno ?

Offline Marsigne

  • Beta Tester
  • Little clucker
  • *****
  • Posts: 9
  • Reputation : 2
    • View Profile
Hmmm realy good but i need the whole script as pastabin or pawno ?
Does your server have an score system?
« Last Edit: May 22, 2012, 05:05:31 pm by Marsigne »

Offline мυ∂υℓ_вacнα

  • Community Developer
  • God Father
  • ******
  • Posts: 1221
  • Reputation : 3
  • Location: London
    • View Profile
Hmmm realy good but i need the whole script as pastabin or pawno ?
Does your server have an score system?
Of course it hasss ....
« Last Edit: May 22, 2012, 05:05:45 pm by Marsigne »

Gamer

  • Guest
Who are Owner's?

Offline Marsigne

  • Beta Tester
  • Little clucker
  • *****
  • Posts: 9
  • Reputation : 2
    • View Profile

Offline мυ∂υℓ_вacнα

  • Community Developer
  • God Father
  • ******
  • Posts: 1221
  • Reputation : 3
  • Location: London
    • View Profile
Re: How to make a score system [1 score every minute]
« Reply #6 on: February 24, 2013, 01:59:25 am »
+1 ... + this will be added i think

 

+-Recent Topics

UNS Is Back But Still under Construction. by мυ∂υℓ_вacнα
January 30, 2014, 07:21:59 am

Coming Back :P by мυ∂υℓ_вacнα
March 09, 2013, 12:49:18 pm

How to make a score system [1 score every minute] by мυ∂υℓ_вacнα
February 24, 2013, 01:59:25 am

[Forum Report]Reputation charge wait time 99999 hours? by мυ∂υℓ_вacнα
February 24, 2013, 01:56:27 am

[UNIVERSAL 2013 Update]: Server Has Been Update To 0.3x ... An Brand New Changes by Smokie
February 04, 2013, 03:32:21 pm

looong time dudes by мυ∂υℓ_вacнα
December 08, 2012, 12:54:21 pm

[UNIVERSAL 2012 UPDATE]:- Server Has Been Updated To 0.3e R-2 And Stuff ADDED : by мυ∂υℓ_вacнα
October 14, 2012, 01:35:41 am

Idiot by Gamer
June 17, 2012, 01:28:45 am

Universal House info-Center. by Marsigne
June 05, 2012, 08:32:12 pm

[Universal Vedios] : Universal Stutning Vedio. by Smokie
June 05, 2012, 06:58:46 am