SA-MP Forums Archive
Playing hours = level - 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)
+--- Thread: Playing hours = level (/showthread.php?tid=495300)



Playing hours = level - Nourdin - 16.02.2014

Hello there,

Anyone that knows how I can make a system that gives people levels after playing x hours?

What I want exactly is:
Player played 4 hours and now it gives him a level automaticly.


Re: Playing hours = level - anou1 - 16.02.2014

If your level system is already done, maybe you could do a cmd to check if the player can levelup. If he can, you level up him. Else you don.

And everyhour, you could maybe for every player, perform the cmd that check if he can level up.

I'm not sure of what I say, but maybe you could try it.


Re: Playing hours = level - Nourdin - 16.02.2014

Well I don't have any server but I'm making unknown scripts to improve myself in PAWN. I heard that a timer could work each hour it will give +1 and if it reaches 5 hours it will give you a level (SetPlayerScore).

If anyone is interested in helping me it would be greatly appreciated.
Contact on Skype also available: Aarabnordin


Re: Playing hours = level - anou1 - 16.02.2014

Top of your script:
Код:
forward TimerMinute(playerid);
Under OnGamemode Init:
Код:
SetTimer("TimerMinute", 60000, true);
Код:
public TimerMinute(playerid)
{
     pInfo[playerid][MinutesPlayed] += 1;
	if(pInfo[playerid][Compte-minutes] == 60)
        {
                 pInfo[playerid][HeuresPlayed] += 1;
                 pInfo[playerid][MinutesPlayed] = 0;
       } 
       if(pInfo[playerid][HoursPlayed] == 5)
       {
               // Do what you want here    
           pInfo[playerid][HoursPlayed] = 0;
       }

}
I'm not sure of this. But maybe it will help you. Adapt it for your case if it's what you want.


Re: Playing hours = level - Dignity - 16.02.2014

Following method will always give one level every four hours.

pawn Код:
new pHours[MAX_PLAYERS];
new pLevel[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    SetTimer("gainExperience", 3600000, true); // Set a timer of 3.6 million miliseconds (1 hour)
    return 1;
}

forward gainExperience(playerid);
public gainExperience(playerid)
{
    if(pHours[playerid] == 4)
    {
        pLevel[playerid] += 1;
        pHours[playerid] = 0; // Reset variable
        return 1;
    }
    pHours[playerid] += 1; // Give one hour
    return 1;
}



Re: Playing hours = level - Nourdin - 16.02.2014

Thanks for helping, both of you are repped.