I don't know much about this but you could maybe have a cron check to see if buffs should be removed at whatever interval.Torniquet wrote:i dont think you could do this through cron tbh (unless you can set a cron to run x amount of time after some1 is buffed).Chris wrote:What if the buff is for defence right. And say it only lasts an hour, but the player is offline for 4. In those 4 hours he gets attacked, and gets extra defence when he shouldn't have?
I guess on the battle script you could check to see if he has any buffs that need to be removed before attacking. But after a while, with so many different types of buffs that will just turn into a mess through the whole site.
Cron would be the best way to do this.
PHP/Msql Timers
Re: PHP/Msql Timers
Re: PHP/Msql Timers
Exactly.Perry wrote:I don't know much about this but you could maybe have a cron check to see if buffs should be removed at whatever interval.Torniquet wrote:i dont think you could do this through cron tbh (unless you can set a cron to run x amount of time after some1 is buffed).Chris wrote:What if the buff is for defence right. And say it only lasts an hour, but the player is offline for 4. In those 4 hours he gets attacked, and gets extra defence when he shouldn't have?
I guess on the battle script you could check to see if he has any buffs that need to be removed before attacking. But after a while, with so many different types of buffs that will just turn into a mess through the whole site.
Cron would be the best way to do this.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Re: PHP/Msql Timers
ye but that would mean there is no set length for a buff...
if you have the cron run every 10 mins... you could get 9 extra mins on the buff time... or you could get 1 minute extra.
you would have to have it run every minute
correct me if i am missin summert
if you have the cron run every 10 mins... you could get 9 extra mins on the buff time... or you could get 1 minute extra.
you would have to have it run every minute
correct me if i am missin summert
New Site Coming Soon! Stay tuned 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP/Msql Timers
you could still do it the way I said. It would be very little calculation on the server. If someone attacks someone while they are offline it checks buffs where PID = that players ID, then calculates the time like I mentioned before.
Re: PHP/Msql Timers
ok with your code halls... it displays seconds.milliseconds...
i can remove the milliseconds npz.
how do i make it so its minutes:seconds.
thnx
i can remove the milliseconds npz.
how do i make it so its minutes:seconds.
thnx
New Site Coming Soon! Stay tuned 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP/Msql Timers
Code: Select all
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
else
milisec-=1
document.counter.d2.value=seconds+"."+milisec
setTimeout("display()",100)
} Re: PHP/Msql Timers
i dont wanna sound like a complete cunt about this...
but any chance of accually givin abit mroe than 'just add this'
not everyone knows how to use ajax... i have tried doing it, i got it to display the minutes:seconds... but asoon as it hit 0.. it stopped counting.
i appreciate u sharing this code nall... but seriously u have to give some thought to those who dont know what they are doin.
but any chance of accually givin abit mroe than 'just add this'
not everyone knows how to use ajax... i have tried doing it, i got it to display the minutes:seconds... but asoon as it hit 0.. it stopped counting.
i appreciate u sharing this code nall... but seriously u have to give some thought to those who dont know what they are doin.
New Site Coming Soon! Stay tuned 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP/Msql Timers
no problem, its actually javascript, no ajax involved
I am doing this where I can't test it but it should be close
You need to use a modulus operator
hope that helps and works
I am doing this where I can't test it but it should be close
You need to use a modulus operator
Code: Select all
<script language="javascript">
var bufftime = <?php echo $finaltime;?>;
var milisec=0;
var minutes = 0;
var seconds=bufftime;
if (seconds > 60)
{
minutes =seconds / 60;
seconds = seconds % 60;
}
document.counter.d2.value='30'
function display(){
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
if (seconds<=0){
seconds=60
minutes-=1
}
else
milisec-=1
document.counter.d2.value=minutes+"."+seconds+"."+milisec
setTimeout("display()",100)
}
display()
</script>Re: PHP/Msql Timers
Appreciate it halls. appologies on the above, but it frustrates me when people do that kind of thing.
it works... kinda lol.
but i have managed to alter it, because it was displaying minutes with decimals in :s
whether what i have added in there (the parseInt part) which has caused the next problem, i dont know. but i cant seem to fix it lol.
when it hits 0:0 it goes to -1:60 and counts down again... then -2, -3 the list goes on lol. i have tried moving the if statements around, and no joy. i have tried killing off the timeout... no joy. i have become confused lol
also. a minor thing.... then the seconds reach less then 10, how to i add a 0 infront of the 9,8,7,6 etc and then have it removed when its a double figure?
ok i seem to have fixed the whole running into minus minutes problem. i added
if (secondsEXP < 60 && minutesEXP <= -1){
secondsEXP = 0;
minutesEXP = 0;
milisecEXP = 0;
}
which seems to have done the job. just a case of the missing 0 now -.-
edit again.
i have fixed the missing 0 ^^
damn im getting good @ this lol.
added this into the else conditional
if (secondsEXP < 10){
displaysecondsEXP = "0"+secondsEXP
} else if (secondsEXP > 9) {
displaysecondsEXP = secondsEXP
}
i am sure there are better ways of going about all this. but i dont care lol... i got it working. thts all i give a hoot about
it works... kinda lol.
but i have managed to alter it, because it was displaying minutes with decimals in :s
Code: Select all
var bufftimeEXP = <?php echo $EXPtime;?>;
var milisecEXP=0;
var minutesEXP = 0;
var secondsEXP=bufftimeEXP;
if (secondsEXP > 60)
{
minutesEXP = parseInt(secondsEXP / 60);
secondsEXP = secondsEXP % 60;
}
function displayEXP(){
if (minutesEXP < 1){
if(secondsEXP <=20){
document.counter.experience.style.color='red';
}
}
if (milisecEXP<=0){
milisecEXP=9
secondsEXP-=1
}
if (secondsEXP<=-1){
milisecEXP=0
secondsEXP+=1
}
if (secondsEXP<=0){
secondsEXP=60
minutesEXP-=1
}
if (secondsEXP < 60 && minutesEXP <= -1){
secondsEXP = 0;
minutesEXP = 0;
milisecEXP = 0;
}
else
milisecEXP-=1
if (secondsEXP < 10){
displaysecondsEXP = "0"+secondsEXP
} else if (secondsEXP > 9) {
displaysecondsEXP = secondsEXP
}
document.counter.experience.value=minutesEXP+":"+displaysecondsEXP
setTimeout("displayEXP()",100)
}
displayEXP()when it hits 0:0 it goes to -1:60 and counts down again... then -2, -3 the list goes on lol. i have tried moving the if statements around, and no joy. i have tried killing off the timeout... no joy. i have become confused lol
also. a minor thing.... then the seconds reach less then 10, how to i add a 0 infront of the 9,8,7,6 etc and then have it removed when its a double figure?
ok i seem to have fixed the whole running into minus minutes problem. i added
if (secondsEXP < 60 && minutesEXP <= -1){
secondsEXP = 0;
minutesEXP = 0;
milisecEXP = 0;
}
which seems to have done the job. just a case of the missing 0 now -.-
edit again.
i have fixed the missing 0 ^^
damn im getting good @ this lol.
added this into the else conditional
if (secondsEXP < 10){
displaysecondsEXP = "0"+secondsEXP
} else if (secondsEXP > 9) {
displaysecondsEXP = secondsEXP
}
i am sure there are better ways of going about all this. but i dont care lol... i got it working. thts all i give a hoot about
New Site Coming Soon! Stay tuned 
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP/Msql Timers
and now you know why I never posted a completed code. You learned so much this way and have solved the problem 