AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compile for 0 bytes + set_task help. (https://forums.alliedmods.net/showthread.php?t=5411)

twistedeuphoria 08-31-2004 15:07

Compile for 0 bytes + set_task help.
 
This compiles to .amx for a lovely 0 bytes. Since I'm new at this it's probably something very obvious(a PLUGIN_CONTINUE should be PLUGIN_HANDLED???), but please help me. Also, are my set_tasks doing what they are supposed to do. (Plugin is supposed to give one health a second to a player who has the boost activated.)

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

new bool:booston[32] = false

public plugin_init()
{
        register_plugin("Health Boost","0.1","twistedeuphoria")
        register_concmd("hboost","health_switch",ADMIN_IMMUNITY,"Blah-To be added later.")
        register_clcmd("hboost","health_switch",ADMIN_IMMUNITY,"Blah-To be added later.")
        set_task(.5,"check_boost",1,"b",1)
        return PLUGIN_CONTINUE
}



public health_switch(id)
{
        if(booston[id] == false)
                booston[id] = true
        if(booston[id] == true)
                booston[id] = false       
        return PLUGIN_CONTINUE
}

public check_boost()
{
        new i
        for(i=0,i<=31,i++)
        {
                if(booston[i] == true)
                        set_task(1,"give_health",2,id,"b",1)
                if(booston[i] == false)
                        remove_task(i,2)
        }       
        return PLUGIN_CONTINUE
}

public give_health(id)
{
        new oldhealth
        new newhealth
        oldhealth = get_user_health(id)
        newhealth = (oldhealth + 1)
        set_user_health(id,newhealth)
        return PLUGIN_CONTINUE
}

Thank you for your time.

sanaell 08-31-2004 15:11

invert tag plz and change Code to small tag

KRoT@L 08-31-2004 22:37

Code:
#include <amxmodx> #include <amxmisc> #include <fun> new bool:booston[32] = false public plugin_init() { register_plugin("Health Boost","0.1","twistedeuphoria") register_concmd("hboost","health_switch",ADMIN_IMMUNITY,"Blah-To be added later.") register_clcmd("hboost","health_switch",ADMIN_IMMUNITY,"Blah-To be added later.") set_task(1.0,"check_boost",941,"",0,"b") return PLUGIN_CONTINUE } public health_switch(id, level, cid) {     if (!cmd_access(id,level,cid,1))         return PLUGIN_HANDLED     if(!booston[id])         booston[id] = true     else         booston[id] = false     return PLUGIN_CONTINUE } public check_boost() {       for(new i=0;i<32;i++)     {         if(booston[i])             set_user_health(i,get_user_health(i)+1)     }     return PLUGIN_CONTINUE }

twistedeuphoria 08-31-2004 23:36

What is the 941 in set_task? Just a random number? When I try to use it it give hboost:invalid command.

Wierd got it to work by taking out clcmd and changeing command name(I think).

Haha well I got mine working well and I originally just wanted a console command anyway so hey its all good for me.

I would bind it anyway so length of command isn't really an issue either.

Anyway thanks again KroT@L!

KRoT@L 08-31-2004 23:45

Yeah random number.
I've just tried the plugin and it has worked fine.. (I've typed hboost in the console)


All times are GMT -4. The time now is 17:21.

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