Score by Playing hours - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Score by Playing hours (
/showthread.php?tid=167413)
Score by Playing hours -
Rady - 12.08.2010
I want the score to show the playing hours
Is this code right?
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerScore(i, Player[playerid][PlayingHours]);
}
}
return 1;
If so, where do I put it ?
Re: Score by Playing hours -
Rady - 12.08.2010
Anyone ?
Re: Score by Playing hours -
Jakku - 12.08.2010
pawn Код:
forward SetScore();
SetTimer("SetScore", 4000,1);
public SetScore()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerScore(i, Player[i][PlayingHours]);
}
}
}
Just change the "4000" to your own value if you want so
Re: Score by Playing hours -
0ne - 12.08.2010
Quote:
Originally Posted by Jakku
pawn Код:
forward SetScore();
SetTimer("SetScore", 4000,1);
public SetScore() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetPlayerScore(i, Player[playerid][PlayingHours]); } } }
Just change the "4000" to your own value if you want so
|
Hmm, a fail code?
pawn Код:
new OnlineTimer[MAX_PLAYERS];
enum pinfo
{
MinutesPlayed,
HoursPlayed
}
new PInfo[MAX_PLAYERS][pinfo];
onplayerconnect:
OnlineTimer[playerid] = SetTimerEx("OnlineTimeUpdate", 60000, 1, "i", playerid);
forward OnlineTimeUpdate(playerid);
public OnlineTimeUpdate(playerid)
{
PInfo[playerid][MinutesPlayed] ++;
if(PInfo[playerid][MinutesPlayed] == 60)
{
PInfo[playerid][HoursPlayed] ++;
SetPlayerScore(playerid,PInfo[playerid][HoursPlayed]);
PInfo[playerid][MinutesPlayed] = 0;
}
}
Re: Score by Playing hours -
Jakku - 12.08.2010
You don't need to make an own timer for each players
And, what is "onplayerconnect"?
He will compile it and gets an error
Re: Score by Playing hours -
Jakku - 12.08.2010
I think he is just a beginner, he wouldn't know that 0ne meant it.
I know it, but Rady might not.
Don't be so cheeky
Re: Score by Playing hours -
0ne - 12.08.2010
Quote:
Originally Posted by Jakku
You don't need to make an own timer for each players
And, what is "onplayerconnect"?
He will compile it and gets an error
|
Yes you do need to create the timer.
Don't pretend to be an idiot , it is an Callback called: OnPlayerConnect.
He won't get an error if he uses this code and puts everything as given.
Re: Score by Playing hours -
Jakku - 12.08.2010
I can just laugh.
A timer which will be set under OnGameModeInit will be better & working, and there will be no useless timers
E:
And you could also set the score when a player is logged in - No timers needed
Re: Score by Playing hours -
HyperZ - 12.08.2010
Try This lol:
Quote:
//Top of on you'r script
forward GiveScore(playerid);
//under on ongamemodeinit
SetTimer("GiveScore",120000,1);//change ur timer
public GiveScore(playerid)
{
SendClientMessage(playerid, COLOR_YELLOW, "Thanks for playing on server, you 1+ score !");
//GivePlayerMoney(playerid, 5000);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
return 1;
}
|
Re: Score by Playing hours -
Rady - 12.08.2010
Quote:
Originally Posted by 0ne
Hmm, a fail code?
pawn Код:
new OnlineTimer[MAX_PLAYERS]; enum pinfo { MinutesPlayed, HoursPlayed } new PInfo[MAX_PLAYERS][pinfo];
onplayerconnect:
OnlineTimer[playerid] = SetTimerEx("OnlineTimeUpdate", 60000, 1, "i", playerid);
forward OnlineTimeUpdate(playerid); public OnlineTimeUpdate(playerid) { PInfo[playerid][MinutesPlayed] ++; if(PInfo[playerid][MinutesPlayed] == 60) { PInfo[playerid][HoursPlayed] ++; SetPlayerScore(playerid,PInfo[playerid][HoursPlayed]); PInfo[playerid][MinutesPlayed] = 0; } }
|
I tried this code, but the score still stays 0 :[