$1000 per hour.
#1

I want something in my gamemode that will do like if a player plays 1 hour, he will get $1000 and a message "You have played an hour and for that you get $1000", my script is strcmp.
Reply
#2

No, your script cannot be called as "strcmp". It's a function which is used to compare strings and had been used before to create commands, some of them still uses but there are better methods.

You can run a timer that runs every X seconds, loop through every players and see if they've passed 1 hour since they've been in game. A better way is to count seconds through a timer only if they're active (not AFK) in game.
Reply
#3

pawn Код:
new moneytimer[MAX_PLAYERS];
forward UpdateTimer(playerid);

public OnPlayerConnect(playerid)
{
    moneytimer[playerid] = SetTimerEx("UpdateTimer", 1000*60*60, true, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(moneytimer[playerid]);
    return 1;
}

public UpdateTimer(playerid)
{
    GivePlayerMoney(playerid, 1000);
    SendClientMessage(playerid, -1, "You have played for 1 hour straight! Enjoy your $1000!");
    return 1;
}
Reply
#4

Not working.
Reply
#5

@[XST]O_x why would you need to check that every second just set the timer to repeating and set it for an hour.
Reply
#6

Quote:
Originally Posted by KamalBakri
Посмотреть сообщение
Not working.
His code should work. The single thing I can see differently is that:

PHP код:
new timeplayed[MAX_PLAYERS] = {0,...}; 
change to:

PHP код:
new timeplayed[MAX_PLAYERS]; 
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
@[XST]O_x why would you need to check that every second just set the timer to repeating and set it for an hour.
Because I'm dumb, duh.
But it should work anyway, don't see a reason why not
Reply
#8

I think I'm doing a mistake, can you guys tell me where to put these? like adding // and writing there // at the top, like this.
Reply
#9

news at the top , other given up check the posts and forwarding and public of timer at the bottom would be good
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)