Raised This Month: $ Target: $400
 0% 

set task doesnt want to work.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 03-21-2006 , 23:43   set task doesnt want to work.
Reply With Quote #1

Im having trouble with this plugin. I want it to check a players time spent on a server. Now for the sake of testing, that value is 15 seconds.

When I use a set_task to check a players time every second, it doesnt do anything when a players time gets to 15 seconds. But if I use client_PreThink instead, it works. Now I would use client_prethink, but it executed the code 40-50 times, which I dont want, as I want it to play a sound also and it gets quite loud.

So I wanted to know why client_prethink works in this case, but set_task doesnt.


Edit - Problem solved. Attachments removed, no longer needed.
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 03-22-2006 , 00:03  
Reply With Quote #2

Code:
public check_time(){ //If prethink is used here it works, but set_task doesnt.     new players[32], count     get_players( players[32], count, "c") // Skip bots         new i, name[32], id, playtime     for(i = 0; i < count; i++)     {         name[0] = 0         id = players[i]                 get_user_name(id, name, 17)         playtime = get_user_time(id)         store_time = playtime + connecttime[id]         if(store_time == 15) {             client_print(0, print_chat,"If you are seeing this, then it is working.")         }     } }

When you do task like that for all players, You have do something like I did above.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 03-22-2006 , 00:10  
Reply With Quote #3

Thank you so much. +karma on the way.

But I did need to change
Code:
get_players( players[32], count, "c") // Skip bots
to
Code:
get_players( players, count, "c") // Skip bots
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-22-2006 , 00:11  
Reply With Quote #4

tsk tsk teame06
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 03-22-2006 , 09:31  
Reply With Quote #5

--Edited--
SubStream is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 03-22-2006 , 09:37  
Reply With Quote #6

connecttime[id] is a global variable which is an integer, stored in a mysql database. Basically, when a player plays on a server and leaves, the amount of time they played would be stored as connecttime
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 03-22-2006 , 10:35  
Reply With Quote #7

--Edited--
SubStream is offline
Rixorster
Senior Member
Join Date: Jul 2005
Old 03-22-2006 , 13:46  
Reply With Quote #8

IDK about that, but here's another way:
Code:
public plugin_init() {     set_task(15.0,"textloop") } public textloop(id) {     client_print(0, print_chat,"If you are seeing this, then it is working.") }
;P (it works, trust me, now +karma me ;D )
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
akysiev
Junior Member
Join Date: Mar 2006
Location: Earth
Old 03-22-2006 , 13:50  
Reply With Quote #9

SubStream: Yes, what you wrote should work fine. Although instead of storing it as a global var, you could use modulo as well

Really though, set_task was made for this type of stuff.

Oh, and Rix, I don't think that's what he's looking for. He want to track user time, not display that message to everyone every 15 seconds. Furthermore, you have id as a parameter in the textloop function while set_task does not pass along an integer parameter but rather an array parameter and the one you provided does not pass any parameters at all. Hell, it doesn't even loop like the name suggests it would.
akysiev is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-22-2006 , 13:52  
Reply With Quote #10

it wouldn't loop. also no id, so why do you have id defined in textloop?
Code:
public plugin_init() {     set_task(15.0,"textloop", 0, _, _, "b") } public textloop() {     client_print(0, print_chat,"If you are seeing this, then it is working.") }
[ --<-@ ] Black Rose is offline
Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode