Jump to content

Question

Posted

Salut, o problema in care mereu cand ma loghez, imi da payday-ul.

COD:

task SecondTimer[1000]() / asta nu stiu daca conteaza dar mna
{
    new string[64];
    
    new hour, minute, second, year, month, day;
    gettime(hour, minute, second);
    getdate(year, month, day);
    
    format(string, sizeof string, "%02d.%02d.%d~N~%02d:%02d:%02d", day, month, year, hour, minute, second);
    TextDrawSetString(ServerTimeTD, string);
    
    format(string, sizeof string, "T: ~Y~%d~W~~H~ Q: ~B~%d", GetServerTickRate(), mysql_unprocessed_queries());
    TextDrawSetString(ServerInfoTD, string);
    return true;
}

ptask SecondPlayerTimer[1000](playerid)
{
    if(IsPlayerPaused(playerid) || IsPlayerInRangeOfPoint(playerid, 1.0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]))
    {
        PlayerInfo[playerid][pAFKSeconds] ++;
    }
    else
    {
        PlayerInfo[playerid][pAFKSeconds] = 0;
    }
    
    if(PlayerInfo[playerid][pAFKSeconds] < 10)
    {
        PlayerInfo[playerid][pSeconds] ++;
    }
        
    if(PlayerInfo[playerid][pPayday] <= gettime())
    {
        SendClientMessage(playerid, 0x00b3b3FF, "---------------------------------------------------------");
        SendFormatMessage(playerid, COLOR_WHITE, "Paycheck: $%s, Hours Played: %.2f (%.0f minutes).", FormatNumber(PlayerInfo[playerid][pLevel] * 125), (PlayerInfo[playerid][pSeconds] / 3600), (PlayerInfo[playerid][pSeconds] / 60));
        SendClientMessage(playerid, 0x00b3b3FF, "---------------------------------------------------------");

        PlayerInfo[playerid][pHours] += (PlayerInfo[playerid][pSeconds] / 3600);
        PlayerInfo[playerid][pSeconds] = 0;
        PlayerInfo[playerid][pPayday] = (gettime() + 3600);
        PlayerInfo[playerid][pRespectPoints] ++;
        
        if(PlayerInfo[playerid][pDrivingLic] > 0)
            PlayerInfo[playerid][pDrivingLic] --;

        if(PlayerInfo[playerid][pWeaponLic] > 0)
            PlayerInfo[playerid][pWeaponLic] --;

        if(PlayerInfo[playerid][pBoatLic] > 0)
            PlayerInfo[playerid][pBoatLic] --;

        if(PlayerInfo[playerid][pFlyLic] > 0)
            PlayerInfo[playerid][pFlyLic] --;

        if(PlayerInfo[playerid][pDrivingLicS] > 0)
            PlayerInfo[playerid][pDrivingLicS] --;

        if(PlayerInfo[playerid][pWeaponLicS] > 0)
            PlayerInfo[playerid][pWeaponLicS] --;

        if(PlayerInfo[playerid][pBoatLicS] > 0)
            PlayerInfo[playerid][pBoatLicS] --;

        if(PlayerInfo[playerid][pFlyLicS] > 0)
            PlayerInfo[playerid][pFlyLicS] --;


        GivePlayerMoneyEx(playerid, (PlayerInfo[playerid][pLevel] * 125));
        UpdateLevelBar(playerid);
        
        mysqlQuery("UPDATE `users` SET `Hours` = '%f', `Seconds` = '0', `Payday` = '3600', `RespectPoints` = '%d' `Licenses` = '%d|%d|%d|%d|%d|%d|%d|%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pHours], PlayerInfo[playerid][pRespectPoints], PlayerInfo[playerid][pSQLID]);
    }
    
    new string[64];
    format(string, sizeof string, "Next payday in ~Y~%s", Calculate(PlayerInfo[playerid][pPayday] - gettime()));
    PlayerTextDrawSetString(playerid, PaydayPTD[playerid], string);
    GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    return true;

9 answers to this question

Recommended Posts

  • 0
Posted

Tu updatezi 'Payday' la 3600, deci e normal sa ti se dea payday-ul la fiecare logare. Inlocuieste query-ul cu ce am pus eu mai sus, iar apoi verifica baza de date, sa vezi cum este salvata valoarea in 'Payday'. Si totodata, poate asa vei invata cum functioneaza gettime().

 

mysqlQuery("UPDATE `users` SET `Hours` = '%f', `Seconds` = '0', `Payday` = '%d', `RespectPoints` = '%d' `Licenses` = '%d|%d|%d|%d|%d|%d|%d|%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pHours], PlayerInfo [playerid] [pPayday], PlayerInfo[playerid][pRespectPoints], PlayerInfo[playerid][pSQLID]);

  • 0
Posted
La 27.05.2020 la 12:45, NuamNume a spus:

Nu merge

Ce nu merge? 

  • 0
Posted

Încearcă la OnPlayerConnect(playerid) să pui 

PlayerInfo[playerid][pPayday] = (gettime() + 3600);

 

public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

  • 0
Posted

Mai uita-te inca odata la GroWy si vezi cum a facut el 😃 

Omu' a facut tutorial pe yt si tu nu esti in stare sa copiezi...Urat... :D 

NU E DE COMPETENTA MEA SA FAC LUMEA MAI BUNA.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.