Please i need time scoring-1h=>1 score
#1

If someone know the code for time played in server.
Something like this:
Player should get one score for one hour playing

please help thanks...
Reply
#2

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] ++;
GivePlayerScore(playerid,GetPlayerScore(playerid)+1);
PInfo[playerid][MinutesPlayed] = 0;
}
}
Reply
#3

https://sampwiki.blast.hk/wiki/SetTimer
Reply
#4

I bet you could make a time played system without timers. Maybe you just stored what time it was when they joined and then added that to the current time when they left.
Reply
#5

Then it wouldnt update unless ur leaving every hour
Reply
#6

Thanks u are the best
i got one error on GivePlayerScore, but i just replaced it with SetPlayerScore and now is without errors..
thanks. :P
Reply
#7

Why don't you just do:

Under OnPlayerConnect
pawn Код:
SetPlayerScore(playerid, 0)
Then, create a function:

pawn Код:
forward AddToScore(playerid);
public AddToScore(playerid)
{
  SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
  return 1
}
and set it on a timer when the player joins in OnPlayerConnect:
pawn Код:
SetTimerEx("AddToScore", 60000, 1, "i", playerid);
Simples?

EDIT: Had a typo, it's good now.
Reply
#8

Dont confuse him, it works now..
Reply
#9

yee u right thats more simple
but thanks i will try all
Reply
#10

Quote:
Originally Posted by Lamano
Dont confuse him, it works now..
It's not confusing .. it's simple(er)

Better off with a simple and less resource using option than the one with variables he doesn't need.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)