AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set Task not working correctly (https://forums.alliedmods.net/showthread.php?t=132231)

vL. 07-13-2010 02:39

Set Task not working correctly
 
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;



RedRobster 07-13-2010 02:44

Re: Set Task not working correctly
 
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")



vL. 07-13-2010 02:46

Re: Set Task not working correctly
 
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

tm. 07-13-2010 03:08

Re: Set Task not working correctly
 
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.

vL. 07-13-2010 04:33

Re: Set Task not working correctly
 
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 :)

One 07-13-2010 07:46

Re: Set Task not working correctly
 
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.

fysiks 07-13-2010 17:00

Re: Set Task not working correctly
 
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"?

Bugsy 07-13-2010 17:20

Re: Set Task not working correctly
 
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.

vL. 07-14-2010 03:09

Re: Set Task not working correctly
 
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.

fysiks 07-14-2010 03:15

Re: Set Task not working correctly
 
Quote:

Originally Posted by vL. (Post 1238645)
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 (Post 1238094)
Is there a command that a player uses to use the "loto"?

You didn't answer my question.


All times are GMT -4. The time now is 07:14.

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