ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old December 22nd, 2004, 09:43 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
need help with sceduling tasks

In my casual table i have a playable field. if it is 'o' they can play the game, if it is 'x' that means they are jailed. then if they are jailed i have a jaileddays field showing how many days they are jailed for.. everyday at reset i want it to go down a number obviously.. but i cant get it to! here is what i have

<cfquery name="jailstuff" datasource="userlogin">
Select * from casual
</cfquery>
<cfoutput query="jailstuff">

<cfif playable is 'x'>
<cfquery datasource="userlogin">
update Casual
set jaileddays = jaileddays - 1
</cfquery>
</cfif>
</cfoutput>


but first off it is update EVERYONE so if they are 'o' playable then it makes them go into the negatives, AND it makes everyone go down like 3 instead of 1..

ie, those at 8 days jailed, go down to 5... and those who arent even jailed go to -3.. :S

Reply With Quote
  #2  
Old December 22nd, 2004, 09:54 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
You could create a scheduled task to automatically update this. Use <cfschedule> or the CF administrator.

However, this seems *really* inefficient. Why not just set a value in the table with a date stamp of when their "jail time" expires, and then at any time you can calculate the difference between the current time and the end of the jail time to determine how much longer they'll be in jail. Updating this value for every user for every day seems like overkill.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old December 22nd, 2004, 09:57 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
umm i am doing this in the sceduled tasks part of cf administrator, if thats what you meant.. i am new to cf so i dont know about how to do a timestamp and stuff yet so i am just trying it this way - is that possible?

Quote:
Originally Posted by kiteless
You could create a scheduled task to automatically update this. Use <cfschedule> or the CF administrator.

However, this seems *really* inefficient. Why not just set a value in the table with a date stamp of when their "jail time" expires, and then at any time you can calculate the difference between the current time and the end of the jail time to determine how much longer they'll be in jail. Updating this value for every user for every day seems like overkill.

Reply With Quote
  #4  
Old December 22nd, 2004, 10:21 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
It would be possible to have a scheduled task update the database every day (or on whatever schedule you set). However, like I said it really is an inefficient method. I mean, if the system had 10,000 entities you'd be updating all 10,000 of them every day just to subtract 1 from one of the columns. So...possible? Yes. Efficient? Definitely not.

I'd try to look into comparing dates instead.

Reply With Quote
  #5  
Old December 22nd, 2004, 10:36 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
well do you know what is wrong with my current code since its not working properly?

Reply With Quote
  #6  
Old December 22nd, 2004, 11:34 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
Maybe something like:

<cfquery datasource="userlogin">
update Casual
set jaileddays = jaileddays - 1
where jaileddays > 0
</cfquery>

Reply With Quote
  #7  
Old December 23rd, 2004, 08:01 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
That worked

One last question -about sheduling tasks..

I have the battle table with fields like HP and stuff

but then im trying to update the user_id's information in another table with info from the battle table

battle:
user_id
hp:

Table:
user_id:
field:

im trying to get their hp from the hp field, and put it in the "field" field...

<cfquery name="gethp" datasource="userlogin">
Select * from battle
</cfquery>
<cfoutput query="gethp">

<cfquery datasource="userlogin">
update Table
set field = #hp#
</cfquery>

it's setting everyone to 50 in the second table, when not everyone has 50 HP in the battle table...

what can i do :S

</cfoutput>

Reply With Quote
  #8  
Old December 23rd, 2004, 09:46 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
It seems like you need to look into SQL some more...I highly recommend Ben Forta's SQL in 10 Minutes, it's very cheap, small, and packed with good stuff.

I'd try something like this:

<cfquery datasource="userlogin">
update Table t, Battle b.
set t.field = b.hp
where t.user_id = b.user_id
</cfquery>

However this seems like overkill, is there a reason why you would want to duplicate the HP field into the other table? Duplication is evil and when you see it this should trigger a red flag in your mind.

Reply With Quote
  #9  
Old December 23rd, 2004, 10:01 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
If you saw my game you'd know. I have two different battle systems and they are completely different, but require the same HP. They are not connected in any way except that, so.. that's how it has to be done. Thanks for the code though i will try it now.

Quote:
Originally Posted by kiteless
It seems like you need to look into SQL some more...I highly recommend Ben Forta's SQL in 10 Minutes, it's very cheap, small, and packed with good stuff.

I'd try something like this:

<cfquery datasource="userlogin">
update Table t, Battle b.
set t.field = b.hp
where t.user_id = b.user_id
</cfquery>

However this seems like overkill, is there a reason why you would want to duplicate the HP field into the other table? Duplication is evil and when you see it this should trigger a red flag in your mind.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > need help with sceduling tasks


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway