SA-MP Forums Archive
lil question - 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: lil question (/showthread.php?tid=245803)



lil question - tanush - 02.04.2011

How can i make if player does /stats, it will show how long the player played in the server by hours and time?


Re: lil question - -Rebel Son- - 02.04.2011

Save the hours and time in Pvars, And then show them with a formmated text..


Re: lil question - tanush - 02.04.2011

Sorry i don't know how to use PVar that much :P


Re: lil question - -Rebel Son- - 02.04.2011

OnPlayerConnect.

pawn Code:
SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);
Function.

pawn Code:
forward UpdateTime(playerid);
public UpdateTime(playerid)
{
    SetPVarInt(playerid, "Time", GetPVarInt(playerid, "Time")+1);
    return 1;
}



Re: lil question - tanush - 02.04.2011

Lil question,how i make how many minutes player played in /stats xD?


Re: lil question - -Rebel Son- - 02.04.2011

Is stats a dialog?


Re: lil question - tanush - 02.04.2011

yes
pawn Code:
CMD:stats(playerid, params[])
{
    new AdminRank[30];
    new string[128];
    new Name[MAX_PLAYER_NAME];
    switch (PlayerData[playerid][AdminLevel])
    {
    case 0: format(AdminRank, 30, "(Not Admin)");
    case 1: format(AdminRank, 30, "(Server Moderator)");
    case 2: format(AdminRank, 30, "(Global Moderator)");
    case 3: format(AdminRank, 30, "(Administrator)");
    case 4: format(AdminRank, 30, "(Server Owner)");
    }
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    format(string, sizeof(string), " {FFB300}Name: %s \n\n Adminlevel: %d %s\n\n Vip: %d\n\n Cash: %d\n\n Score: %d",Name,PlayerData[playerid][AdminLevel],AdminRank,PlayerData[playerid][vip],GetPlayerMoney(playerid),GetPlayerScore(playerid));
    ShowPlayerDialog(playerid,10000,DIALOG_STYLE_MSGBOX, "Stats",string,"Close","");
    return 1;
}



Re: lil question - -Rebel Son- - 02.04.2011

Just create the new line in the text.

(Time %i)

And for its variable put
pawn Code:
GetPVarInt(playerid, "Time");



Re: lil question - tanush - 02.04.2011

thanks for everything but i have problem with saving it on connect,
on top
pawn Code:
enum pData
{
    AdminLevel,
    Cash,
    Score,
    vip,
    Hour,
    Minute
};
new PlayerData[MAX_PLAYERS][pData];
on player connect
pawn Code:
SetTimerEx("Hours",3600000, 1, "i", playerid);
    SetTimerEx("Minutes", 60*1000, 1, "i", playerid);
OnPlayerDisconnect
pawn Code:
dini_IntSet(file, "Hours",PlayerData[playerid][Hour]);
        dini_IntSet(file, "Minutes",PlayerData[playerid][Minute]);
When player registers
pawn Code:
dini_IntSet(file, "Hours",PlayerData[playerid][Hour]);
            dini_IntSet(file, "Minutes",PlayerData[playerid][Minute]);
when player loggs
pawn Code:
SetPVarInt(playerid,"Minutes",dini_Int(file, "Minutes"));
            SetPVarInt(playerid,"Hours",dini_Int(file, "Hours"));
and forward/public
pawn Code:
forward Hours(playerid);
public Hours(playerid)
{
    SetPVarInt(playerid, "Hours", GetPVarInt(playerid, "Hours")+1);
    return 1;
}
forward Minutes(playerid);
public Minutes(playerid)
{
    SetPVarInt(playerid, "Minutes", GetPVarInt(playerid, "Minutes")+1);
    return 1;
}



Re: lil question - Joe Staff - 02.04.2011

Quote:
Originally Posted by -Rebel Son-
View Post
OnPlayerConnect.

pawn Code:
SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);
You shouldn't create a new infinitely repeating timer every time a player joins the server...


Re: lil question - tanush - 02.04.2011

still please help me with saving


Re: lil question - tanush - 02.04.2011

please help, i only need help with saving stats


Re: lil question - SchurmanCQC - 02.04.2011

Don't bump like that, you have to wait FORTY EIGHT hours first.

And search for account system tutorials instead of spamming the forums with your "lil questions."


Re: lil question - -Rebel Son- - 02.04.2011

Torrans Account system saves time, Just like the example i gave you. Now. Quit spamming the forum/repeated bumping. It wont help you get replys.


Re: lil question - tanush - 03.04.2011

i already have an account saving, i just only need help with how to save the PVar. please help


Re: lil question - tanush - 05.04.2011

*bump*


Re: lil question - gamer931215 - 05.04.2011

Edit:
i hate your signature...