AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to pass someone's id to another function? (https://forums.alliedmods.net/showthread.php?t=46041)

Rolnaaba 10-17-2006 10:04

how to pass someone's id to another function?
 
if I had this function:
Code:
public function(id) { //want this (id) to pass to next function //blah blah }

could I use set_task to pass this id to another function and if so how?

Greenberet 10-17-2006 10:05

Re: how to pass someone's id to another function?
 
Code:
public funtion(id) {     function2(id); } function2( id ) {   // id got passed }

Rolnaaba 10-17-2006 10:06

Re: how to pass someone's id to another function?
 
ahh so simple, but I want a delay to occur before that second function is executed, specifically five seconds, and the only way I know to do this is set_task is there another, and if set_task is the only way how can I pass id through set_task?

umarsa 10-17-2006 10:19

Re: how to pass someone's id to another function?
 
set_task()

Rolnaaba 10-17-2006 10:21

Re: how to pass someone's id to another function?
 
how do I pass an id through set task is my question

umarsa 10-17-2006 10:24

Re: how to pass someone's id to another function?
 
i think..

1st of all the set_task :

set_task(Float:time,const function[],id = 0,parameter[]="",len = 0,flags[]="", repeat = 0)

ok.

public funtion(id)
{
function2(id);
set_task here

function2( id )
{
// id got passed
}

i dont have my amxx studio atm so im not sure nort tested

Rolnaaba 10-17-2006 10:25

Re: how to pass someone's id to another function?
 
that would make the func execute before set_task is even looked at that makes no sense

wonsae 10-17-2006 11:02

Re: how to pass someone's id to another function?
 
PHP Code:

public func1(id)
{
        new 
parm[1]
        
param[0] = id
        set_task
(5.0,"func2",0,parm,1)
}
 
public 
func2(parm[])
{
       
id parm[0]


thanks to Emp`! :)

Rolnaaba 10-17-2006 11:05

Re: how to pass someone's id to another function?
 
awesome you rock wonsae ty ty -karma fo joo

XxAvalanchexX 10-17-2006 15:02

Re: how to pass someone's id to another function?
 
If you want, you can pass the player id as the task id. If no extra parameters are set, then the task id will be passed to the function. Example:

Code:
public function1(id) {      set_task(5.0,"function2",id); } public function2(id) {      // id in function2 is the same as in function1 }

But if you plan to have multiple tasks and also use the other task functions (change_task, task_exists, remove_task), then you should use unique task ids and instead pass the player id the way that wonsae showed you.


All times are GMT -4. The time now is 04:48.

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