• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] help with /payday command in samp
#1
hi, i have a problem with the /payday command in my samp script. i have a function called PayDay that gives players their salary at fixed times, but i want to create a /payday command that allows admins to grant the salary manually.

i thought that if i call the function it might work or if i call ResetPD it might work, but i don't understand how it should be done. if someone can help me understand, i would appreciate it.

function ResetPD() {
Paydaydat = 0;
return 1;
}

function PayDay() {
    new hour,minn,sec;
    gettime(hour,minn,sec);
    if(minn == 0 && Paydaydat == 0) {
        SetTimer("ResetPD", 60000, false);
        Paydaydat = 1;
        new string[128];
        new interest,account[MAX_PLAYERS];
        new rent[MAX_PLAYERS];
        SetTimer("ScadeLicentele", 4000, false);
        foreach(Player,i) {
            if(IsPlayerConnected(i) && IsPlayerLogged[i] == 1) {
                // Verifică limita de gift points
                if(PlayerInfo[i][pGiftpuncte] >= 200) {
                    SendClientMessage(i, COLOR_RED, "ERROR: Ai atins limita de 200 gift points. Nu mai poți primi gift points.");
                } else {
                    // Adaugă 50 gift points la payday
                    PlayerInfo[i][pGiftpuncte] += 50;
                    new giftMsg[128];
                    format(giftMsg, sizeof(giftMsg), "Ai primit 50 gift points la payday.");
                    SendClientMessage(i, COLOR_GREEN, giftMsg);
                }

                new key = PlayerInfo[i][pHouse];
                if(key != 999) {
                    rent[i] = HouseInfo[key][hRent];
                    HouseInfo[key][hTakings] += rent[i];
                }
                new tmpintrate;
                SendClientMessage(i, COLOR_SERVER, "------------------------------------------------------------------------------------------------");
                if(PlayerInfo[i][pPremiumAccount] == 1) {
                    tmpintrate = 2;
                    PlayerInfo[i][pPayDayHad] += 1;
                    if(PlayerInfo[i][pPayDayHad] >= 5) {
                        PlayerInfo[i][pExp]++;
                        PlayerInfo[i][pPayDayHad] = 0;
                    }
                    new bonus = PlayerInfo[i][pPayCheck] / 2;
                    PlayerInfo[i][pPayCheck] += bonus;
                } else {
                    tmpintrate = 1;
                }
                account[i] = PlayerInfo[i][pAccount];
                Tax += TaxValue;

                new checks = PlayerInfo[i][pLevel] * 2500 + random(3000);
                if(PlayerInfo[i][pDailyLogin] == 0) checks = checks * 2;
                GivePlayerCash(i, checks);
                interest = (PlayerInfo[i][pAccount] / 5000) * (tmpintrate);
                if(PlayerInfo[i][pDailyLogin] == 0) interest = interest * 2;
                if(PlayerInfo[i][pDailyLogin] == 0) PlayerInfo[i][pExp] += 2;
                else PlayerInfo[i][pExp] += 1;
                UpdateProgress(i, 0);
                PlayerInfo[i][pAccount] += interest + 1000;

                SCM(i, COLOR_WHITE, "Salariul tau a sosit! Viziteaza banca pentru a retrage banii.");
                format(string, sizeof(string), "Ai primit %0.2f ore jucate. (%.0f minute)", PlayerInfo[i][pSeconds] / 3600, PlayerInfo[i][pSeconds] / 60);
                SendClientMessage(i, COLOR_WHITE, string);
                PlayerInfo[i][pConnectTime] += PlayerInfo[i][pSeconds] / 3600;
                if(PlayerInfo[i][pSeconds] >= 1800) {
                    new query[180];
                    format(query, sizeof(query), "UPDATE `users` SET `DayHours`=`DayHours`+1 WHERE `ID`='%d'", PlayerInfo[i][pSQLID]);
                    mysql_query(SQL, query);
                    format(query, sizeof(query), "UPDATE `users` SET `HoursMonth`=`HoursMonth`+1 WHERE `ID`='%d'", PlayerInfo[i][pSQLID]);
                    mysql_query(SQL, query);
                }
                PlayerInfo[i][pSeconds] = 0;
               
                if(PlayerInfo[i][pDailyLogin] == 0) {
                    PlayerInfo[i][pDailyLogin] = 1;
                    UpdateVar(i, "DailyLogin", 1);
                    SCM(i, COLOR_LIGHTBLUE, "Ai primit de doua ori mai multe respect points si bani pentru primul tau payday de astazi.");
                }

                if(PlayerInfo[i][pHouse] != 999) {
                    format(string, sizeof(string), "Paycheck: $%s | Tax: -$%d | Rent: -$%d | Old Balance: $%s", FormatNumber(checks), FormatNumber(TaxValue), HouseInfo[PlayerInfo[i][pHouse]][hRent], FormatNumber(account[i]));
                    SendClientMessage(i, COLOR_GREY, string);
                    format(string, sizeof(string), "Interest rate: 0.%d% | Interest: $%s | New balance: $%s", tmpintrate, FormatNumber(interest), FormatNumber(PlayerInfo[i][pAccount]));
                    SendClientMessage(i, COLOR_GREY, string);
                } else {
                    format(string, sizeof(string), "Paycheck: $%s | Tax: -$%d | Rent: -$0 | Old Balance: $%s", FormatNumber(checks), FormatNumber(TaxValue), FormatNumber(account[i]));
                    SendClientMessage(i, COLOR_GREY, string);
                    format(string, sizeof(string), "Interest rate: 0.%d% | Interest: $%s | New balance: $%s", tmpintrate, FormatNumber(interest), FormatNumber(PlayerInfo[i][pAccount]));
                    SendClientMessage(i, COLOR_GREY, string);
                }

                PlayerInfo[i][pPayDay] = 0;
                PlayerInfo[i][pPayCheck] = 0;
                SendClientMessage(i, COLOR_SERVER, "------------------------------------------------------------------------------------------------");
            }
        }
        if(hour == 21) {
            new gold = 1 + random(10);
            new money = 10000 + random(5000);
            for(new h = 0; h < MAX_CLANS; h++) {
                if(strlen(ClanInfo[h][clName]) != 0) {
                    if(GetClanTurfs(h) >= 10) {
                        foreach(Player, i) {
                            if(PlayerInfo[i][pClan] == h && h != 0) {
                                PlayerInfo[i][pPremiumPoints] += gold;
                                Update(i, pPremiumPointsx);
                                GivePlayerCash(i, money);
                                format(string, sizeof(string), "Ai primit %d puncte premium si $%s deoarece clanul tau are peste 10 teriotrii.", gold, FormatNumber(money));
                                SCM(i, COLOR_MONEY, string);
                            }
                        }
                    }
                }
            }
        }
        if(RestartPayday == 1) {
            SendClientMessageToAll(COLOR_CLIENT, "Server-ul a fost restartat! Va rugam sa reveniti.");
            GameModeExit();
        }
    }
    return 1;
}



This is the payday and RESETPD system.


and here is what i tried to do

CMD:payday(playerid) {
    if (PlayerInfo[playerid][pAdmin] < 6) {
        return SendClientMessage(playerid, COLOR_RED, "Nu ai permisiuni pentru a folosi aceasta comanda.");
    }

    Paydaydat = 0;
    SendClientMessage(playerid, COLOR_GREEN, "Payday a fost acordat cu succes.");
    return 1;
}
  Reply


Forum Jump: