//---------------------A Mód Hátuljára----------------------------------//
public PlayedTime(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
PlayerTime[playerid][seconds]++;
if(PlayerTime[playerid][seconds] == 60)
{
PlayerTime[playerid][Minutes]++;
PlayerTime[playerid][seconds] = 0;
}
if(PlayerTime[playerid][Minutes] == 60)
{
PlayerTime[playerid][Hours]++;
PlayerTime[playerid][Minutes] = 0;
}
if(PlayerTime[playerid][Hours] == 24)
{
PlayerTime[playerid][Days]++;
PlayerTime[playerid][Hours] = 0;
}
return 1;
}
//------------------OnPlayerDisconnect--------------//
new file[128];
new name[MAX_PLAYER_NAME];
format(file,sizeof(file),\"%s.ini\",name);
if(fexist(file))
{
dini_IntSet(file, \"Seconds\", PlayerTime[playerid][seconds]);
dini_IntSet(file, \"Minutes\", PlayerTime[playerid][Minutes]);
dini_IntSet(file, \"Hours\", PlayerTime[playerid][Hours]);
dini_IntSet(file, \"Days\", PlayerTime[playerid][Days]);
KillTimer(PlayerTimer[playerid]);
}
//----------------------OnPlayerConnect--------------//
new file[128];
PlayerTimer[playerid] = SetTimerEx(\"PlayedTime\", 1000, 1, \"%d\", playerid);
UzenetTimer[playerid] = SetTimer(\"Uzenet\", 300000, true);
if(!fexist(file))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),\"%s.ini\",name);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file, \"Seconds\", 0);
dini_IntSet(file, \"Minutes\", 0);
dini_IntSet(file, \"Hours\", 0);
dini_IntSet(file, \"Days\", 0);
}
}
if(fexist(file))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),\"%s.ini\",name);
if(fexist(file))
{
PlayerTime[playerid][seconds] = dini_Int(file, \"Seconds\");
PlayerTime[playerid][Minutes] = dini_Int(file, \"Minutes\");
PlayerTime[playerid][Hours] = dini_Int(file, \"Hours\");
PlayerTime[playerid][Days] = dini_Int(file, \"Days\");
}
}
//---------------------Mód Elejére a new stb.---------------------//
enum pTime
{
Seconds,
Minutes,
Hours,
Days
};
new PlayerTime[MAX_PLAYERS][pTime];
new PlayerTimer[MAX_PLAYERS];
new UzenetTimer[MAX_PLAYERS];
//--------------Az Üzi Küldése-------------//
public Uzenet(playerid)
{
new st[128];
format(st, sizeof(st), \"Szerveren Eltötött Idöd: %d Óra, %d Perc, %d Másodperc\", PlayerTime[playerid][Hours], PlayerTime[playerid][Minutes], PlayerTime[playerid][seconds]);
SendClientMessage(playerid, st);
}
Dupla hozzászólás automatikusan összefûzve. ( 2015. február 04. - 16:35:11 )
//ha akarod tedd be, az OnPlayerKeyStateChange-alá. Ha berakod, akkor az Y gomb lenyomásával, küld neked egy üzit, hogy menyi idöt töltöttél a szerón.
if(newkeys == KEY_YES)
{
new st[128];
format(st, sizeof(st), \"Szerveren Eltötött Idöd: %d Óra, %d Perc, %d Másodperc\", PlayerTime[playerid][Hours], PlayerTime[playerid][Minutes], PlayerTime[playerid][seconds]);
SendClientMessage(playerid, st);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
}