Raised This Month: $51 Target: $400
 12% 

[TUT/INFO] set_tasks: when they are and when they aren't necessary


Post New Thread Reply   
 
Thread Tools Display Modes
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 04-25-2008 , 11:15   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #41

So should I make a fake "info_target" entity think and loop all entities when it thinks?
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Tomppaduulis
Junior Member
Join Date: Apr 2008
Old 05-19-2008 , 15:28   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #42

How to create a cooldown for this script? I have been trying it for a while now.
Code:
public say_handle(id)
{
    new buffer[256], buffer1[33], buffer2[33], buffer3[33], origin[3]
    get_user_origin(id,origin)
    read_argv(1,buffer,255)
    parse(buffer, buffer1, 32, buffer2, 32, buffer3, 32)

    if(equali(buffer1,"/glock18") || equali(buffer1,"/glock 18"))
    {
        ts_giveweapon(id, 1, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Glock18")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/uzi"))
    {
        ts_giveweapon(id, 3, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Mini-Uzi")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/benelli"))
    {
        ts_giveweapon(id, 4, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Benelli m3")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m4a1"))
    {
        ts_giveweapon(id, 5, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned M4A1")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mp5sd"))
    {
        ts_giveweapon(id, 6, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned MP5SD")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mp5k"))
    {
        ts_giveweapon(id, 7, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned MP5K")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/beretta"))
    {
        ts_giveweapon(id, 8, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Beretta")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/socom"))
    {
        ts_giveweapon(id, 9, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Socom MK23")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/usas"))
    {
        ts_giveweapon(id, 11, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Usas 12")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/deagle"))
    {
        ts_giveweapon(id, 12, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Desert Eagle")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ak47"))
    {
        ts_giveweapon(id, 13, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned AK-47")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/aug") || equali(buffer1,"/steyraug"))
    {
        ts_giveweapon(id, 15, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Steyr Aug")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/fiveseven"))
    {
        ts_giveweapon(id, 14, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Five/Seven")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/scorpion"))
    {
        ts_giveweapon(id, 17, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Scorpion")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/barret"))
    {
        if( get_cvar_num("disable_barret") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Barret is not allowed")
        }
        else
        {
            ts_giveweapon(id, 18, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Barret")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/pdw") || equali(buffer1,"/mp7"))
    {
        ts_giveweapon(id, 19, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned HK PDW")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/spas"))
    {
        ts_giveweapon(id, 20, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Spas 12")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/colts"))
    {
        ts_giveweapon(id, 21, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Golden Colts")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/glock20"))
    {
        ts_giveweapon(id, 22, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Glock 20 C")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ump"))
    {
        ts_giveweapon(id, 23, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned UMP")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/cknife"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 25, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Combat Knife")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mossberg"))
    {
        ts_giveweapon(id, 26, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Mossberg 500")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m16"))
    {
        ts_giveweapon(id, 27, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned M16A4")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ruger"))
    {
        ts_giveweapon(id, 28, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Ruger MK1")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/rbull") || equali(buffer1,"/ragingbull"))
    {
        ts_giveweapon(id, 31, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Raging Bull")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m60"))
    {
        if( get_cvar_num("disable_m60") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]M60 is not allowed")
        }
        else
        {
            ts_giveweapon(id, 32, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned M60")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/sawnoff"))
    {
        ts_giveweapon(id, 33, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Sawed off shotgun")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/katana"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            ts_giveweapon(id, 34, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Katana")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/sknife"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 35, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Seal Knife")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/contender"))
    {
        if( get_cvar_num("disable_contender") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Contender is not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 36, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Contender G2")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE 
}
__________________

+ karma if helpful
Tomppaduulis is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-19-2008 , 16:37   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #43

Read the tutorial and at least try and do part of it yourself. I'll help you if you have a problem with that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Tomppaduulis
Junior Member
Join Date: Apr 2008
Old 05-20-2008 , 08:55   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #44

I read the tutorial, but I couldn't get it to work. Here is the same code with the task thing I tried.
Code:
#include <amxmodx>
#include <amxmisc>
#include <tsx>
#include <tsxaddon>
#include <dbi>
#include <engine>
#include <engine_stocks>
#include <fun>
#include <fakemeta>
#include <tsfun>
#include <harbu>
#include <ava_ts>

#define spawn_cooldown 120.0

new Float:g_Lastspawn[33]
new Float:g_Cooldown = spawn_cooldown

public plugin_init
{
       register_plugin(PLUGIN, AUTHOR, VERSION)
    //all say commands
    register_clcmd( "say","say_handle")
}

public say_handle(id)
{
    new buffer[256], buffer1[33], buffer2[33], buffer3[33], origin[3]
    get_user_origin(id,origin)
    read_argv(1,buffer,255)
    parse(buffer, buffer1, 32, buffer2, 32, buffer3, 32)

    if(equali(buffer1,"/glock18") || equali(buffer1,"/glock 18"))
    {
        new Float:Time
        global_get(glb_time,Time)    
    
        if(!is_user_alive(id) || Time - g_Cooldown < g_Lastspawn[id])
            return
    
        g_LastAttack[id] = Time

        ts_giveweapon(id, 1, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Glock18")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/uzi"))
    {
        ts_giveweapon(id, 3, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Mini-Uzi")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/benelli"))
    {
        ts_giveweapon(id, 4, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Benelli m3")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m4a1"))
    {
        ts_giveweapon(id, 5, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned M4A1")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mp5sd"))
    {
        ts_giveweapon(id, 6, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned MP5SD")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mp5k"))
    {
        ts_giveweapon(id, 7, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned MP5K")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/beretta"))
    {
        ts_giveweapon(id, 8, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Beretta")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/socom"))
    {
        ts_giveweapon(id, 9, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Socom MK23")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/usas"))
    {
        ts_giveweapon(id, 11, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Usas 12")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/deagle"))
    {
        ts_giveweapon(id, 12, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Desert Eagle")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ak47"))
    {
        ts_giveweapon(id, 13, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned AK-47")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/aug") || equali(buffer1,"/steyraug"))
    {
        ts_giveweapon(id, 15, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Steyr Aug")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/fiveseven"))
    {
        ts_giveweapon(id, 14, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Five/Seven")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/scorpion"))
    {
        ts_giveweapon(id, 17, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Scorpion")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/barret"))
    {
        if( get_cvar_num("disable_barret") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Barret is not allowed")
        }
        else
        {
            ts_giveweapon(id, 18, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Barret")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/pdw") || equali(buffer1,"/mp7"))
    {
        ts_giveweapon(id, 19, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned HK PDW")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/spas"))
    {
        ts_giveweapon(id, 20, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Spas 12")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/colts"))
    {
        ts_giveweapon(id, 21, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Golden Colts")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/glock20"))
    {
        ts_giveweapon(id, 22, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Glock 20 C")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ump"))
    {
        ts_giveweapon(id, 23, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned UMP")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/cknife"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 25, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Combat Knife")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/mossberg"))
    {
        ts_giveweapon(id, 26, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Mossberg 500")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m16"))
    {
        ts_giveweapon(id, 27, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned M16A4")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/ruger"))
    {
        ts_giveweapon(id, 28, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Ruger MK1")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/rbull") || equali(buffer1,"/ragingbull"))
    {
        ts_giveweapon(id, 31, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Raging Bull")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/m60"))
    {
        if( get_cvar_num("disable_m60") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]M60 is not allowed")
        }
        else
        {
            ts_giveweapon(id, 32, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned M60")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/sawnoff"))
    {
        ts_giveweapon(id, 33, 255, 14)
        client_print(id,print_chat,"[Zombiemod]You spawned Sawed off shotgun")
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/katana"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            ts_giveweapon(id, 34, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Katana")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/sknife"))
    {
        if( get_cvar_num("disable_blades") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Blades are not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 35, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Seal Knife")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    if(equali(buffer1,"/contender"))
    {
        if( get_cvar_num("disable_contender") > 0 )
        {
            client_print(id,print_chat,"[Zombiemod]Contender is not allowed")
        }
        else
        {
            
            ts_giveweapon(id, 36, 255, 14)
            client_print(id,print_chat,"[Zombiemod]You spawned Contender G2")
            return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE 
}
This gives me a error of using the return and return <value>. I tried
to remove return PLUGIN_HANDLED but it didnt work. then all commands execpt the
/glock18 spawn the glock18. I tried to remove the return, but it didnt work either.
Iam not very good at coding (actually iam not good at all) and
I really cant understand this tutorial better since english is not
my native language. Please help
__________________

+ karma if helpful

Last edited by Tomppaduulis; 05-21-2008 at 10:41.
Tomppaduulis is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-21-2008 , 10:14   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #45

You didn't try, look at this:

Code:
public plugin_init
{
    register_plugin(PLUGIN, AUTHOR, VERSION)
    //all say commands
    register_clcmd( "say","say_handle")

    public say_handle(id)
Give me some fairly intelligible code and I'll help.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Tomppaduulis
Junior Member
Join Date: Apr 2008
Old 05-21-2008 , 10:40   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #46

Well that happened because I am using this thing as part of another code and I copy pasted that from there. Then I removed the unneeded things from my plugin_init and must have accidentally removed that } too.
__________________

+ karma if helpful
Tomppaduulis is offline
Old 05-21-2008, 10:53
Hawk552
This message has been deleted by Hawk552.
Tomppaduulis
Junior Member
Join Date: Apr 2008
Old 05-21-2008 , 11:09   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #47

Thank you very much. I already gave you +karma on your last post, so can't give it on this yet. By the way, I know that I am not a good coder. This is my first coding project since amxx scripting is the first time I really got interested in coding. I have tried to start coding c++ and other languages like that, but I always just got too bored. And everyones got to start somewhere.
__________________

+ karma if helpful
Tomppaduulis is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 05-26-2008 , 12:40   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #48

FOSS: where you pay by accepting patronising insults.

How would buffer1 ever be equal to "glock 18" when its contents is supplied by parse()?

You only need two return statements; add an 'else' at the end of the if/else if block and return PLUGIN_CONTINUE. You'd then return PLUGIN_HANDLED at the end of say_handle().

Of course, the never-ending if/else block could be condensed to one or two loops/arrays to give (or disallow) each and every weapon.

Last edited by Lee; 05-26-2008 at 12:46.
Lee is offline
Old 05-26-2008, 12:45
Lee
This message has been deleted by Lee. Reason: Double Post.
Old 05-26-2008, 15:22
Hawk552
This message has been deleted by Hawk552.
Lo6idZe
Member
Join Date: May 2008
Old 08-10-2008 , 13:39   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #49

How can I replace set_task with fakemate? I tried but it didn't work...
Or I don't need to replace it?

Code:
 
new plugon, plug;
new timecount, seconds;
new g_creathud, g_timeleft;
public plugin_init()
{
register_plugin("mKSeRv Timeleft Countdown","0.2","KIL"); 
plugon = register_cvar("amx_mk_tlcd","1");
timecount = register_cvar("amx_mk_seconds","59");

plug = get_pcvar_num(plugon);
seconds = get_pcvar_num(timecount); 
g_creathud = CreateHudSyncObj();
set_task(1.0, "countdown", 666666, "", 0, "b");
}
public countdown()
{ 
g_timeleft = get_timeleft() 

if(g_timeleft <= seconds && plug == 1)
{
if(g_timeleft <= 10) set_hudmessage(139, 0, 0, 0.7, 0.88, 1, 1.0, 1.0, 0.01, 0.01, -1);
else if(g_timeleft <= 30) set_hudmessage(0, 255, 255, 0.7, 0.88, 1, 1.0, 1.0, 0.01, 0.01, -1);
else set_hudmessage(255, 255, 255, 0.7, 0.88, 1, 1.0, 1.0, 0.01, 0.01, -1);
ShowSyncHudMsg(0, g_creathud, "%d second(s) remaining", g_timeleft);
}

}
Lo6idZe is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-10-2008 , 13:48   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #50

I think set_task is fine in your case.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 07:30.


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