Raised This Month: $ Target: $400
 0% 

Set Task not working correctly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 07-13-2010 , 02:39   Set Task not working correctly
Reply With Quote #1

So I got this script. The point is that they can use the Loto every 10th minute. When they connect they also have to wait 10 minutes before they can use it.

PS: These are just partions of the script.

PHP Code:
new InvisUsed[33];

public 
plugin_init()
{
    
register_plugin("Stuff""1.0""vL.");

    
RegisterHam(Ham_Spawn"player""Fwd_Ham_Spawn_Post"1); // <- This works

    
set_task(600.0,"LotoUnUsed",_,_,_,"b"); // <- This doesn't works
}

public 
client_putinserver(id
{
    
set_task(3.0,"LotoUsed",id);
}

public 
LotoUsed(id)
{
    
LotoUsed[id] = true;
}

public 
Fwd_Ham_Spawn_Post(id// <- This works
{
    
LotoUsed[id] = false;
}

public 
LotoUnUsed(id// <- This doesn't works
{
    
LotoUsed[id] = false;

vL. is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-13-2010 , 02:44   Re: Set Task not working correctly
Reply With Quote #2

You never specify an ID to pass in the task. Do like:
PHP Code:
public client_putinserver(id)
{
          
set_task(600.0"LotoUnUsed"id,_,_,"b")

RedRobster is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 07-13-2010 , 02:46   Re: Set Task not working correctly
Reply With Quote #3

Thats not the problem, just a mistake I made writing it to here , the problem is in LotoUnUsed, it will not set it to false
vL. is offline
tm.
Member
Join Date: Apr 2010
Old 07-13-2010 , 03:08   Re: Set Task not working correctly
Reply With Quote #4

This should do what you've asked:
PHP Code:
#include <amxmodx>

new bool:g_AllowLoto[33];

public 
plugin_init()
{
    
register_plugin("Stuff""1.0""vL.");
}

public 
client_putinserver(id
{
    
set_task(600.0"AllowLoto"id);
}

public 
AllowLoto(id)
{
    
g_AllowLoto[id] = true;
}

public 
client_disconnect(id)
{
    
g_AllowLoto[id] = false;
    
remove_task(id);
}

public 
the_loto_thing(id)
{
    if(!
g_AllowLoto[id])
        return 
PLUGIN_HANDLED;
    
    
// your code
    
    
g_AllowLoto[id] = false;
    
set_task(600.0"AllowLoto"id);
    
    return 
PLUGIN_CONTINUE;

It's a bit redundant how you did it. The task set in plugin_init will not do anything because you don't have an id to use in plugin_init. And why do you need to know when the player spawns? Maybe I'm missing something.
tm. is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 07-13-2010 , 04:33   Re: Set Task not working correctly
Reply With Quote #5

The spawn thing was just there, because with spawn it worked but with set task it didn't, but as I can understand your code it will work, because it loops it. Your code works
vL. is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 07-13-2010 , 07:46   Re: Set Task not working correctly
Reply With Quote #6

Code:
new InvisUsed[33];

public plugin_init()
{
    register_plugin("Stuff", "1.0", "vL.");

    RegisterHam(Ham_Spawn, "player", "Fwd_Ham_Spawn_Post", 1); // <- This works

    set_task(600.0,"LotoUnUsed",_,_,_,"b"); // <- This doesn't works
}

public client_putinserver(id) 
{
    set_task(3.0,"LotoUsed",id);
}

public LotoUsed(id)
{
    LotoUsed[id] = true;
}

public Fwd_Ham_Spawn_Post(id) // <- This works
{
    LotoUsed[id] = false;
}

public LotoUnUsed(id) // <- This doesn't works
{
    LotoUsed[id] = false;
}
see here...

in plugin_init and you task you didnt registered any IDs.
but in the function you registered the ID. this is why your code will not works.

i hope you understand what i want to say or understand where are you wrong.
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-13-2010 , 17:00   Re: Set Task not working correctly
Reply With Quote #7

There is a better way to do this (without set_task) if there is a command that a person must use to activate this "loto" thing. Is there a command that a player uses to use the "loto"?
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-13-2010 , 17:20   Re: Set Task not working correctly
Reply With Quote #8

I agree with fysiks. You are better off explaining your goal instead of posting your code and expecting everyone to know what you're trying to do.
__________________
Bugsy is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 07-14-2010 , 03:09   Re: Set Task not working correctly
Reply With Quote #9

Its just an set task, so if 10 minutes have pass the player can use loto and if he uses it he has to wait for another 10m to use it again.
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-14-2010 , 03:15   Re: Set Task not working correctly
Reply With Quote #10

Quote:
Originally Posted by vL. View Post
Its just an set task, so if 10 minutes have pass the player can use loto and if he uses it he has to wait for another 10m to use it again.
Quote:
Originally Posted by fysiks View Post
Is there a command that a player uses to use the "loto"?
You didn't answer my question.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 07:14.


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