PDA

View Full Version : payday code didn't work ?!


MrTinder
31/10/2013, 09:01 AM
this is it

public Payday(playerid)
{
new hour, minute, second;
gettime(hour, minute, second);
if(minute == 00)
{
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
{
if(PlayerInfo[i][ExpS] == 0)
{
PlayerInfo[i][Exp]++;
}
else
{
PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
}
if(PlayerInfo[i][Level] < 30)
{
GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
}
else
{
GivePlayerMoney(i, 30000);
}
}
}
return 1;
}

DobbysGamertag
31/10/2013, 09:21 AM
What do you mean "it didn't work". What are you trying to do?

Tagathron
31/10/2013, 09:55 AM
Try like this
public Payday(playerid)
{
new hour, minute, second;
gettime(hour, minute, second);
if(minute == 00)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) {
if(PlayerInfo[i][ExpS] == 0)
{
PlayerInfo[i][Exp]++;
}
else
{
PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
}
if(PlayerInfo[i][Level] < 30)
{
GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
}
else
{
GivePlayerMoney(i, 30000);
}
}
}
}
return 1;
}

Konstantinos
31/10/2013, 10:09 AM
Instead of using a timer (assuming ~ 1ms) and check the minute everytime whether it's 0 (when it takes 60 minutes to be 0 again), why don't you make a timer every 1 hour?

MrTinder
31/10/2013, 10:15 AM
So..I add a timer that check what's the time every 1 second and it's work now.Tnx all :>

Elorreli
31/10/2013, 10:25 AM
public Payday(playerid) //You assign this to a playerid
{
new hour, minute, second;
gettime(hour, minute, second);
if(minute == 00)
{
for(new i = 0; i < MAX_PLAYERS; i++) //Then you loop it for everyone
{
if(IsPlayerConnected(i)) {
if(PlayerInfo[i][ExpS] == 0)
{
PlayerInfo[i][Exp]++;
}
else
{
PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
}
if(PlayerInfo[i][Level] < 30)
{
GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
}
else
{
GivePlayerMoney(i, 30000);
}
}
}
}
return 1;
}

Do like this instead


forward Payday();
public Payday()
{
new hour, minute, second;
gettime(hour, minute, second);
if(minute == 00)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) {
if(PlayerInfo[i][ExpS] == 0)
{
PlayerInfo[i][Exp]++;
}
else
{
PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
}
if(PlayerInfo[i][Level] < 30)
{
GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
}
else
{
GivePlayerMoney(i, 30000);
}
}
}
}
return 1;
}

You'll need a timer or something to check it aswell.

SetTimer("Payday", 1000, true);

But yeah, making a timer checking every hour would be better.