AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Transfer string arguments in set_task (https://forums.alliedmods.net/showthread.php?t=89263)

Empowers 04-04-2009 09:59

Transfer string arguments in set_task
 
I wanna to execute function restore_targetname( name[1][] ) via set_task

so tryed to do it like this:
PHP Code:

new targetname[1][32]
pev(entpev_targetnametargetname[0],31)

set_task(0.1"restore_targetname"_,targetname1

But I've got compiler error: Array dimensions do not match

Note: I can't use global vars bzc task is in loop and could be executed many times in 0.1second so the var would be rewritten :(
Any Suggestions? :)

Empowers 04-04-2009 10:11

Re: Transfer string arguments in set_task
 
PHP Code:

set_task0.1"restore_targetname"_"szTargetName" ); 
// or this 
set_task0.1"restore_targetname""szTargetName" ); 

O_o I'm sure this 2 would't work for sure, bcz you just transfering string "szTargetName", but not the var szTargetName.

Now gonna try the first one
------------------------------

When using the 1st got server shutdown and error memory can't be "read"

Any suggestions?

Arkshine 04-04-2009 10:21

Re: Transfer string arguments in set_task
 
try : set_task( 0.1, "restore_targetname", _, szTargetName, 32 );

Empowers 04-04-2009 10:30

Re: Transfer string arguments in set_task
 
Quote:

Originally Posted by arkshine (Post 797129)
try : set_task( 0.1, "restore_targetname", _, szTargetName, 32 );

The same :evil:
Server crash

Anyone help plz :crab:

Arkshine 04-04-2009 11:51

Re: Transfer string arguments in set_task
 
Show your whole code. Make sure it crashes because of what I write and nothing else also.

SnoW 04-04-2009 11:58

Re: Transfer string arguments in set_task
 
Your function is:
PHP Code:

restore_targetnametargetname[32] ) 

or
PHP Code:

restore_targetnametargetname[32], dummy 

right?

xPaw 04-04-2009 12:10

Re: Transfer string arguments in set_task
 
snow read his post again.
PHP Code:

restore_targetnamename[1][] ) 

btw try to make it
PHP Code:

restore_targetnamename[] ) 

and really provide code.

Emp` 04-04-2009 12:29

Re: Transfer string arguments in set_task
 
I doubt you can pass a two-dimensional array through. Index the first dimension (targetname[0])

SnoW 04-04-2009 12:41

Re: Transfer string arguments in set_task
 
Quote:

Originally Posted by xPaw (Post 797223)
snow read his post again.
PHP Code:

restore_targetnamename[1][] ) 

btw try to make it
PHP Code:

restore_targetnamename[] ) 


I don't need to read it again, I know what code he posted in the thread. Still because a better way was suggested to him(The way I used), I obviously thought that he was testing that one.

Empowers 04-04-2009 13:54

Re: Transfer string arguments in set_task
 
Quote:

Originally Posted by Emp` (Post 797239)
I doubt you can pass a two-dimensional array through. Index the first dimension (targetname[0])

but when we pass one-dimensional arrays

we do it like this
PHP Code:

new param[10]
set_task(10.0,"task",_,param

but not like this
PHP Code:

new param[10]
set_task(10.0,"task",_,param[])

//or this
set_task(10.0,"task",_,param[1]) 

OR if i wanna pass somethink like this..
PHP Code:

new param[10][32]

param[1] = "string1"
param[2] = "string2"
           
...
param[9] = "string9"

//so what index should we write?
set_task(1.0,"go",_,param[or or 3]) // ????

set_task(1.0,"go",_,param[]) // <------ I thougth that this is nice 
//but it doesn't work 



All times are GMT -4. The time now is 02:27.

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