payday code didn't work ?! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: payday code didn't work ?! (
/showthread.php?tid=472858)
payday code didn't work ?! -
MrTinder - 31.10.2013
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;
}
Re: payday code didn't work ?! -
DobbysGamertag - 31.10.2013
What do you mean "it didn't work". What are you trying to do?
Re: payday code didn't work ?! -
Tagathron - 31.10.2013
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;
}
Re: payday code didn't work ?! -
Konstantinos - 31.10.2013
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?
Re: payday code didn't work ?! -
MrTinder - 31.10.2013
So..I add a timer that check what's the time every 1 second and it's work now.Tnx all :>
Re: payday code didn't work ?! -
Elorreli - 31.10.2013
Код:
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.