Raised This Month: $ Target: $400
 0% 

set_task problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarlD
Senior Member
Join Date: Aug 2004
Old 11-06-2005 , 03:24   set_task problem
Reply With Quote #1

Im trying to set a task using set_task:

the "Task" it has to do is supposed to be defined by a variable.

here is my code:
Code:
public level4(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 59 && death <= 30)         {         new thing[64]         new ONOFF = get_cvar_string("offon",thing,63)         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_t")             set_task(1.0, ONOFF)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_ct")             set_task(1.0, ONOFF)         }     } }

i want the set_task to be defined by the variable but it doesnt work :S wont compile

Code:
public level4(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 59 && death <= 30)         {         new thing[64]         new ONOFF = get_cvar_string("offon",thing,63)         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_t")             set_task(1.0, "ONOFF") // also tried like this but dint work         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_ct")             set_task(1.0, "ONOFF") // I ALSO TRIED LIKE THIS BUT DINT WORK         }     } }
__________________
DarlD is offline
Send a message via MSN to DarlD
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 11-06-2005 , 09:46  
Reply With Quote #2

try this:
Code:
public level4(id)
    {
    new frags = get_user_frags(id)
    new death = get_user_deaths(id)
    if (frags > 59 && death <= 30)
        {
        new thing[64]
        get_cvar_string("offon",thing,63)
        new CsTeams:userTeam = cs_get_user_team(id)
        if (userTeam == CS_TEAM_T)
            {
            client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")
            cs_set_user_model(id, "leet_t")
            set_task(1.0, thing) // also tried like this but dint work
        }
        else if(userTeam == CS_TEAM_CT)
            {
            client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")
            cs_set_user_model(id, "leet_ct")
            set_task(1.0, thing) // I ALSO TRIED LIKE THIS BUT DINT WORK
        }
    }
}
a function will be called
name of function must be equal to what you stored in the CVAR "offon"
__________________
alias White Panther
karlos is offline
DarlD
Senior Member
Join Date: Aug 2004
Old 11-06-2005 , 18:02  
Reply With Quote #3

it fixed the errors, but i still get a bug while running the plugin on line 197 of my script:

Code:
L 11/06/2005 - 17:59:40: [CSTRIKE] Player out of range (0)
L 11/06/2005 - 17:59:40: [AMXX] Displaying debug trace (plugin "amx_modelrank.amxx")
L 11/06/2005 - 17:59:40: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 11/06/2005 - 17:59:40: [AMXX]    [0] amx_modelrank.sma::highscore (line 197)
Code:
/*================================================================================================ == amx_modelrank ==            Created by ==                        Meta AKA DarlD on the amxmodx forums. ==                                                      Visit:<a href="http://www.metagamez.net" target="_blank" rel="nofollow noopener">www.metagamez.net</a> ================================================================================================== ==ChangeLog: ============ ==Version 2: Fixed some bugs, changed the code so that it actualy works... ==Version 1: Beta Release ================================================================================================== == Description:  With UT sounds you get "sound events" for the amount of kills you make in == a row. Same concept with this plugin, exept you dont get an other model for the amount of kills == you make in a row. Instead, you get differant models with the amount of Frags and Deaths. == There are 4 "levels"; == 1. Newb - From 0 to 20 kills & less than 10 deaths == 2. Killer - From 20 to 40 kills & less than 10 deaths == 3. Pro - From 40 to 60 kills & less than 20 deaths == 4. l33t - From 60 kills & less than 30 deaths ================================================================================================== == TRY TO STAY L33T ONE HOLE GAME OF 40 MINUTES! ================================================================================================== */ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> public plugin_init()     {     register_plugin("Model Rank", "2.3", "DarlD")     register_concmd("amx_modelrank","func_onoff",ADMIN_KICK,"amx_modelrank <1|0>")     register_concmd("amx_highscore","HS_onoff",ADMIN_KICK,"- set to 1 to enable the highscore level 5...")     register_clcmd("say /test","HS_onOFFTEST",ADMIN_ALL,"TEST")     register_cvar("highscore_cvar","0")     register_cvar("offon","resetModel") } // here we define our on off command public func_onoff(id, lvl, cid)     {     if(!cmd_access(id, lvl, cid,1))         return PLUGIN_HANDLED         new arg[32]     read_argv(1,arg,31)         if (arg[0] == '1')         {         new pstr[1]         pstr[0] = id         set_task (0.1,"resetModel",_,pstr,1)     }     else if(arg[0] == '0')         {         new pstr[1]         pstr[0] = id         set_task (0.1,"normal",_,pstr,1)     }     return PLUGIN_CONTINUE } // here we set the command to enable the optional level 5 public HS_onoff(id, lvl, cid)     {     if(!cmd_access(id, lvl, cid,1))         return PLUGIN_HANDLED         new arg[32]     read_argv(1,arg,31)         if (arg[0] == '1')         {         new pstr[1]         pstr[0] = id         set_cvar_num("highscore_cvar",'1')         set_task (0.1,"HS_on",_,pstr,1)     }     else if (arg[0] == '0')         {         new pstr[1]         pstr[0] = id         set_cvar_num("highscore_cvar",'0')         set_task (0.1,"HS_off",_,pstr,1)     }     return PLUGIN_CONTINUE } // here we load the models so that we can use them in the plugin :) public plugin_precache()     {     precache_model("models/player/leet_t/leet_t.mdl")     precache_model("models/player/leet_ct/leet_ct.mdl")     precache_model("models/player/killer_t/killer_t.mdl")     precache_model("models/player/killer_ct/killer_ct.mdl")     precache_model("models/player/pro_t/pro_t.mdl")     precache_model("models/player/pro_ct/pro_ct.mdl")     precache_model("models/player/newb_t/newb_t.mdl")     precache_model("models/player/newb_ct/newb_ct.mdl")         return PLUGIN_CONTINUE } // Creating the first level of our Ranking public resetModel(pstr[])     {     new id = pstr[0]     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags < 19 && death <= 10 )         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             cs_set_user_model(id, "newb_t")             set_task(1.0,"level2")         }         else if(userTeam == CS_TEAM_CT)             {             cs_set_user_model(id, "newb_ct")             set_task(1.0,"level2")         }     } } // Level 2 here we come!! from here on its mostly copy & paste.... public level2(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 19 && death <= 15)         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 2!")             cs_set_user_model(id, "killer_t")             set_task(1.0,"level3")         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 2!")             cs_set_user_model(id, "killer_ct")             set_task(1.0,"level3")         }     } } // level 3 public level3(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 39 && death <= 20)         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 3!")             cs_set_user_model(id, "pro_t")             set_task(1.0,"level4")         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 3!")             cs_set_user_model(id, "pro_ct")             set_task(1.0,"level4")         }     } } // level 4 public level4(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 59 && death <= 30)         {         new thing[64]         get_cvar_string("offon",thing,63)         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_t")             set_task(1.0, thing)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_ct")             set_task(1.0, thing)         }     } } // Level 5 public highscore(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags >= 0 && death >= 0 )         {         new CsTeams:userTeam = cs_get_user_team(id)         new speed = get_user_maxspeed(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached serious level!")             set_user_maxspeed(id,speed + 2000)             cs_set_user_model(id, "leet_t")             set_task(1.0,"resetModel")         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached serious level!")             set_user_maxspeed(id,speed + 2000)             cs_set_user_model(id, "leet_ct")             set_task(1.0,"resetModel")         }     } } // here we setup the optional level 5 (on) public HS_on(id)     {     new ONOFF2 = get_cvar_num("highscore_cvar")     if ( ONOFF2 == '1')         {         set_cvar_string("offon","highscore")     }     return PLUGIN_CONTINUE } // same as above exept off public HS_off(id)     {     new ONOFF3 = get_cvar_num("highscore_cvar")     if ( ONOFF3 == '1')         {         set_cvar_string("offon","resetModel")     }     return PLUGIN_CONTINUE } public HS_onOFFTEST(id)     {     set_task(1.0,"highscore") }
__________________
DarlD is offline
Send a message via MSN to DarlD
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 11-06-2005 , 18:07  
Reply With Quote #4

Code:
public HS_onoff(id, lvl, cid)     {     if(!cmd_access(id, lvl, cid,1))         return PLUGIN_HANDLED         new arg[32]     read_argv(1,arg,31)         if (arg[0] == '1')         {         set_cvar_num("highscore_cvar",'1')         set_task (0.1,"HS_on",id)     }     else if (arg[0] == '0')         {         set_cvar_num("highscore_cvar",'0')         set_task (0.1,"HS_off",id)     }     return PLUGIN_CONTINUE }
Do the same with the other ones.
__________________
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
BAILOPAN
Join Date: Jan 2004
Old 11-06-2005 , 18:08  
Reply With Quote #5

You aren't passing anything to set_task. You must do it like this:
Code:
#define MODEL_TASK 1337 set_task(time, "resetModel", MODEL_TASK+id) public resetModel(task_id) {    new id = task_id - MODEL_TASK    //...code }

When you specify only one extra parameter to set_task, it gets passed that same parameter as a number. Using this you can create a unique task for every player, by specifying a base number and using their id as an offset.
__________________
egg
BAILOPAN is offline
DarlD
Senior Member
Join Date: Aug 2004
Old 11-06-2005 , 18:11  
Reply With Quote #6

im not sure i fully understand what you guyz mean :S
__________________
DarlD is offline
Send a message via MSN to DarlD
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 11-06-2005 , 18:24  
Reply With Quote #7

Try this:
Code:
/*================================================================================================ == amx_modelrank ==            Created by ==                        Meta AKA DarlD on the amxmodx forums. ==                                                      Visit:<a href="http://www.metagamez.net" target="_blank" rel="nofollow noopener">www.metagamez.net</a> ================================================================================================== ==ChangeLog: ============ ==Version 2: Fixed some bugs, changed the code so that it actualy works... ==Version 1: Beta Release ================================================================================================== == Description:  With UT sounds you get "sound events" for the amount of kills you make in == a row. Same concept with this plugin, exept you dont get an other model for the amount of kills == you make in a row. Instead, you get differant models with the amount of Frags and Deaths. == There are 4 "levels"; == 1. Newb - From 0 to 20 kills & less than 10 deaths == 2. Killer - From 20 to 40 kills & less than 10 deaths == 3. Pro - From 40 to 60 kills & less than 20 deaths == 4. l33t - From 60 kills & less than 30 deaths ================================================================================================== == TRY TO STAY L33T ONE HOLE GAME OF 40 MINUTES! ================================================================================================== */ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> public plugin_init()     {     register_plugin("Model Rank", "2.3", "DarlD")     register_concmd("amx_modelrank","func_onoff",ADMIN_KICK,"amx_modelrank <1|0>")     register_concmd("amx_highscore","HS_onoff",ADMIN_KICK,"- set to 1 to enable the highscore level 5...")     register_clcmd("say /test","HS_onOFFTEST",ADMIN_ALL,"TEST")     register_cvar("highscore_cvar","0")     register_cvar("offon","resetModel") } // here we define our on off command public func_onoff(id, lvl, cid)     {     if(!cmd_access(id, lvl, cid,1))         return PLUGIN_HANDLED         new arg[32]     read_argv(1,arg,31)         if (arg[0] == '1')         {         set_task (0.1,"resetModel",id)     }     else if(arg[0] == '0')         {         set_task (0.1,"normal",id)     }     return PLUGIN_CONTINUE } // here we set the command to enable the optional level 5 public HS_onoff(id, lvl, cid)     {     if(!cmd_access(id, lvl, cid,1))         return PLUGIN_HANDLED         new arg[32]     read_argv(1,arg,31)         if (arg[0] == '1')         {         new pstr[1]         pstr[0] = id         set_cvar_num("highscore_cvar",1)         set_task (0.1,"HS_on",id)     }     else if (arg[0] == '0')         {         new pstr[1]         pstr[0] = id         set_cvar_num("highscore_cvar",'0')         set_task (0.1,"HS_off",id)     }     return PLUGIN_CONTINUE } // here we load the models so that we can use them in the plugin Smile public plugin_precache()     {     precache_model("models/player/leet_t/leet_t.mdl")     precache_model("models/player/leet_ct/leet_ct.mdl")     precache_model("models/player/killer_t/killer_t.mdl")     precache_model("models/player/killer_ct/killer_ct.mdl")     precache_model("models/player/pro_t/pro_t.mdl")     precache_model("models/player/pro_ct/pro_ct.mdl")     precache_model("models/player/newb_t/newb_t.mdl")     precache_model("models/player/newb_ct/newb_ct.mdl")         return PLUGIN_CONTINUE } // Creating the first level of our Ranking public resetModel(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags < 19 && death <= 10 )         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             cs_set_user_model(id, "newb_t")             set_task(1.0,"level2",id)         }         else if(userTeam == CS_TEAM_CT)             {             cs_set_user_model(id, "newb_ct")             set_task(1.0,"level2",id)         }     } } // Level 2 here we come!! from here on its mostly copy & paste.... public level2(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 19 && death <= 15)         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 2!")             cs_set_user_model(id, "killer_t")             set_task(1.0,"level3",id)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 2!")             cs_set_user_model(id, "killer_ct")             set_task(1.0,"level3",id)         }     } } // level 3 public level3(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 39 && death <= 20)         {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 3!")             cs_set_user_model(id, "pro_t")             set_task(1.0,"level4",id)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 3!")             cs_set_user_model(id, "pro_ct")             set_task(1.0,"level4",id)         }     } } // level 4 public level4(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags > 59 && death <= 30)         {         new thing[64]         get_cvar_string("offon",thing,63)         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_t")             set_task(1.0, "highscore", id)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached Level 4!")             cs_set_user_model(id, "leet_ct")             set_task(1.0, thing)         }     } } // Level 5 public highscore(id)     {     new frags = get_user_frags(id)     new death = get_user_deaths(id)     if (frags >= 0 && death >= 0 )         {         new CsTeams:userTeam = cs_get_user_team(id)         new Float:speed = get_user_maxspeed(id)         if (userTeam == CS_TEAM_T)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached serious level!")             set_user_maxspeed(id,speed + 2000.0)             cs_set_user_model(id, "leet_t")             set_task(1.0,"resetModel",id)         }         else if(userTeam == CS_TEAM_CT)             {             client_print(id,print_chat,"[MR]: Congrats!! You have reached serious level!")             set_user_maxspeed(id,speed + 2000.0)             cs_set_user_model(id, "leet_ct")             set_task(1.0,"resetModel",id)         }     } } // here we setup the optional level 5 (on) public HS_on(id)     {     new ONOFF2 = get_cvar_num("highscore_cvar")     if ( ONOFF2 == '1')         {         set_cvar_string("offon","highscore")     }     return PLUGIN_CONTINUE } // same as above exept off public HS_off(id)     {     new ONOFF3 = get_cvar_num("highscore_cvar")     if ( ONOFF3 == '1')         {         set_cvar_string("offon","resetModel")     }     return PLUGIN_CONTINUE } public HS_onOFFTEST(id)     {     set_task(1.0,"highscore",id) }
__________________
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
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 23:36.


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