• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Question / Help

Status
Not open for further replies.

Fidera-Global

Banned User
Joined
Jun 13, 2017
Messages
32
Solutions
1
Reaction score
2
I'm trying to put 10 seconds delay in the transactions, but the delay never seems to end, what am I doing wrong?

player.h
C++:
bool canTransferCoins(int32_t delay) {
        if ((OTSYS_TIME() - lastCoinTransfer) < delay) {
        return false;
        }
        lastCoinTransfer = OTSYS_TIME();
        return true;
        }

game.cpp
C++:
if (!player->canTransferCoins(10000)) {
    return player->sendStoreError(STORE_ERROR_TRANSFER, "Sorry you need wait 10 seconds to transfer again.");
    }

tfs 1.3
 
Solution
Solved with:


game.cpp
if (lastCoinTransfer > OTSYS_TIME()) {
player->sendStoreError(STORE_ERROR_TRANSFER, "Sorry you need wait 10 seconds to transfer again.");
return false;
}

lastCoinTransfer = OTSYS_TIME() + 10000; // 10 seconds delay

game.h
int64_t lastCoinTransfer;
Solved with:


game.cpp
if (lastCoinTransfer > OTSYS_TIME()) {
player->sendStoreError(STORE_ERROR_TRANSFER, "Sorry you need wait 10 seconds to transfer again.");
return false;
}

lastCoinTransfer = OTSYS_TIME() + 10000; // 10 seconds delay

game.h
int64_t lastCoinTransfer;
 
Solution
Status
Not open for further replies.

Similar threads

Back
Top