Score by Playing hours
#1

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

Anyone ?
Reply
#3

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

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

You don't need to make an own timer for each players

And, what is "onplayerconnect"?

He will compile it and gets an error
Reply
#6

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

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

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

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;
}

Reply
#10

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 :[
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)