[HELP]Vote npc

06/23/2011 12:49 Daci225#1
Can anyone give me vote npc every 12 hours code?
Thanks.
06/23/2011 16:18 JobvdH#2
Please read this carefully:
[Only registered and activated users can see links. Click Here To Register...]
06/23/2011 17:11 BaussHacker#3
Code:
if (DateTime.Now.Hour == 00 || DateTime.Now.Hour == 12)
{
    // Vote
}
else
{
    // Can't vote
}
Might as well make a check if the player already voted.
06/23/2011 22:06 pro4never#4
Quote:
Originally Posted by BaussHacker View Post
Code:
if (DateTime.Now.Hour == 00 || DateTime.Now.Hour == 12)
{
    // Vote
}
else
{
    // Can't vote
}
Might as well make a check if the player already voted.
That would be for entire server to reset and doesn't keep track of when THAT IP last voted.


What I do is quite simple...

Make a little database that holds


username, ip, lastvoted


On login I check if that table contains the user's ip...

if ! contains their ip, they can vote (if they chose to vote, set that ip vote to now and credit their account)

if contains their ip, check when lastvoted was, if over 12 hours, let them vote. If they vote set that ip vote to now and credit account, if not don't let them vote


This means it's an IP based check vs username (multiple accounts all voting for rewards) and it takes into account when THEY last voted.