AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how do i set_task() and transfer three parameters with it? (https://forums.alliedmods.net/showthread.php?t=87223)

Owyn 03-08-2009 12:56

how do i set_task() and transfer three parameters with it?
 
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

Bugsy 03-08-2009 12:59

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

Originally Posted by .Owyn. (Post 776518)
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];



ConnorMcLeod 03-08-2009 13:02

Re: how do i set_task() and transfer three parameters with it?
 
Just don't run the task if the player has not the acces level could be better...

Owyn 03-08-2009 13:46

Re: how do i set_task() and transfer three parameters with it?
 
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
}


Bugsy 03-08-2009 13:47

Re: how do i set_task() and transfer three parameters with it?
 
#include <amxmisc>

Owyn 03-08-2009 13:49

Re: how do i set_task() and transfer three parameters with it?
 
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>

Bugsy 03-08-2009 13:52

Re: how do i set_task() and transfer three parameters with it?
 
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



Owyn 03-08-2009 14:13

Re: how do i set_task() and transfer three parameters with it?
 
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) =\

Bugsy 03-08-2009 14:20

Re: how do i set_task() and transfer three parameters with it?
 
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.

Owyn 03-08-2009 14:29

Re: how do i set_task() and transfer three parameters with it?
 
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);


All times are GMT -4. The time now is 08:49.

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