Raised This Month: $ Target: $400
 0% 

how do i set_task() and transfer three parameters with it?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owyn
Veteran Member
Join Date: Nov 2007
Old 03-08-2009 , 12:56   how do i set_task() and transfer three parameters with it?
Reply With Quote #1

hi, i have a " public function(client, level, cid) "

and i want to set_task to execute function in 0.1 sec once and give it three paramaters
Owyn is offline
Send a message via ICQ to Owyn
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-08-2009 , 12:59   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #2

Quote:
Originally Posted by .Owyn. View Post
hi, i have a " public function(client, level, cid) "

and i want to set_task to execute function in 0.1 sec once and give it three paramaters
PHP Code:
new param[3];
param[0] = val1;
param[1] = val2;
param[2] = val3;

set_task 0.1 "func" param3);

//Called function
public funcparam[3] )
{
     
//val1 = param[0];
     //val2 = param[1];
     //val3 = param[2];

__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-08-2009 , 13:02   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #3

Just don't run the task if the player has not the acces level could be better...
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 03-08-2009 , 13:46   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #4

i must be doing something wrong, why does it says unknown command and returns usage 1st time i use function via console cmd and it works fine 2nd time i use it


Code:
 register_concmd("amx_cmdone", "cmdone", ADMIN_BAN, "<nick, #userid, authid> <param1> <param2>");


public cmdone(client, level, cid)
{
if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;

new steamid[35];
get_user_authid(client, steamid, sizeof(steamid) - 1);

new param[3];
param[0] = client;
param[1] = level;
param[2] = cid;

if( equali(steamid, "STEAM_0", 7) )
{        
set_task ( 0.1 , "cmdtwo" , _ , param, 3);
}
else
{
return PLUGIN_HANDLED;
}

return PLUGIN_CONTINUE;
}

public cmdtwo( param[3] )
{
    new client = param[0];
    new level = param[1];
    new cid = param[2];

//my actions here
}

Last edited by Owyn; 03-08-2009 at 13:48.
Owyn is offline
Send a message via ICQ to Owyn
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-08-2009 , 13:47   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #5

#include <amxmisc>
__________________
Bugsy is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 03-08-2009 , 13:49   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #6

i have it included, my code isnt the full plugin code, just a part i have problems with (set task)
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <regex>

Last edited by Owyn; 03-08-2009 at 13:51.
Owyn is offline
Send a message via ICQ to Owyn
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-08-2009 , 13:52   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #7

Not sure if I'm understanding correctly but if you are trying to not pass cmdtwo to players without access, just do.

PHP Code:
public cmdone(clientlevelcid)
{
    if ( !
cmd_access(id,level,cid,1) )
        return 
PLUGIN_HANDLED;
    
    new 
steamid[35];
    
get_user_authid(clientsteamidsizeof(steamid) - 1);
    
    if( 
equal(steamid"STEAM_0"7) )
        
set_task 0.1 "cmdtwo" client);

    return 
PLUGIN_HANDLED;
}
    
public 
cmdtwoid )
{
    
//my actions here

__________________
Bugsy is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 03-08-2009 , 14:13   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #8

it just returns it's usage when i type "amx_cmdone player 1 2" but when i do it 2nd time it works fine =\ and if i do it once then reconnect then do it again once it works too =\ but not if i connect and do it once from beginning.
and if i do
set_task ( 0.1 , "cmdtwo" , _ , param, 3, "a",2);
it will return its usage twice and won't do anything (first time) =\

Last edited by Owyn; 03-08-2009 at 14:17.
Owyn is offline
Send a message via ICQ to Owyn
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-08-2009 , 14:20   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #9

Oops, if you are using my code above and passing 3 arguments, change the cmd_access to accept 4 params instead of 1. You had it correctly but I didn't know the commands usage.
__________________
Bugsy is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 03-08-2009 , 14:29   Re: how do i set_task() and transfer three parameters with it?
Reply With Quote #10

no, actually i'm useing my code i posted above (it must work =\ )
may my problem be becouse of read_argv() in cmdtwo?
if i remove access level check from cmdtwo instead of usage return it will say client with that name or userid not found (first time)
i think problem is in read_argv(), i still don't understand how it works second time, cuz i have in cmdtwo() these:
read_argv(1, arg, sizeof(arg) - 1);
read_argv(2, arg, sizeof(arg) - 1);
read_argv(3, arg, sizeof(arg) - 1);

Last edited by Owyn; 03-08-2009 at 14:39.
Owyn is offline
Send a message via ICQ to Owyn
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 08:49.


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