Wait a certained time before you receive money.
#1

Normally I got my own server scripter to help me if needed, currently he is on a 3 day trip so I need someone to help me out. Its really easy if you know it.. I don't so yeah.

This is my actuall first time scripting. I just want to know if you are able to make a delay/time of receiving money.
Lets say I type a command /Money and I want it to get it after 5 minutes.
This is what I know and can do myself, just want to know how to add that one line(or multiple) to make it receive after 5mins.

Here is an example I just made:
pawn Код:
if (strcmp("/money", cmdtext, true, 10) == 0)
    {
         SendClientMessage(playerid, COLOR_RED,"You will receive the money in 5 MINUTES.");
         // WHAT HERE?
         GivePlayerMoney(playerid, 25000);
    }
This is not the actuall command I'm using, this is just a easier one to make clear what I mean.
I know that COLOR_RED wont work without having it defined, I do have it defined in my actuall script.

If you can help me, please do.
Thanks for your time.
- Verth.
Reply
#2

You need a public function with parameters for playerid and maybe the money if it's supposed to be a little bit more dynamic. (the function must be forwarded and use the keyword public) This way you can use SetTimerEx to call this function with a certain delay.
Reply
#3

if(strcmp("/money", cmdtext, true, 10) == 0)
{
SendClientMessageEx(playerid, COLOR_RED, "You will receive your money in five minutes.");
SetTimerEx("giveplayermoney", 30000, false, "d", playerid);
}

forward giveplayermoney(playerid);
public giveplayermoney(playerid)
{
GivePlayerMoney(playerid, MONEY HERE);
SendClientMessage(playerid, COLOR_RED, "You have received your money!");
return 1;
}
Reply
#4

Quote:
Originally Posted by Jack.7331
Посмотреть сообщение
if(strcmp("/money", cmdtext, true, 10) == 0)
{
SendClientMessageEx(playerid, COLOR_RED, "You will receive your money in five minutes.");
SetTimerEx("giveplayermoney", 30000, false, "d", playerid);
}

forward giveplayermoney(playerid);
public giveplayermoney(playerid)
{
GivePlayerMoney(playerid, MONEY HERE);
SendClientMessage(playerid, COLOR_RED, "You have received your money!");
return 1;
}
Well the /money was just for example. This worked without any compile errors. But doesnt work. It does it directly.

Here is the bit of code.

pawn Код:
// ==== Above in script ==== //
forward giveplayermoney(playerid);
public giveplayermoney(playerid);
// ==== Above in script ==== //

if (IsPlayerInRangeOfPoint(playerid, 7.0,CheckpointMainEnd))
     {
         SendClientMessage(playerid, COLOR_GREEN,"Calvin Miller says: 'Thanks mate, I will deposit the money to your bank soon!'");
         DisablePlayerCheckpoint(playerid);
         deliveryjobrunning = 0;
         SetTimerEx("giveplayermoney", 300000, false, "d", playerid);
         GivePlayerMoney(playerid, random(200) + 300); // CHANGE TO BANK
         SendClientMessage(playerid, COLOR_RED,"You just received a payment from 'Calvin Miller' on your bank.");
     }
the script itself works, this checkpoint aswell, its just the timer thing.
Ignore the "//CHANGE TO BANK" that is for my scripter.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)