AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pass origin through functions (https://forums.alliedmods.net/showthread.php?t=87066)

Hunter-Digital 03-06-2009 09:45

pass origin through functions
 
Hello again :}

I cannot get a function to receive origins, I get compile "invalid tag" warnings.

Something like this:
Code:

public function(id)
{
      static Float:fOrigin[3], origin[3]
      get_user_origin(id, fOrigin)
 
      origin[0] = floatround(fOrigin[0])
      origin[1] = floatround(fOrigin[1])
      origin[2] = floatround(fOrigin[2])
 
      do_something(origin)
}
 
public do_something(origin[3])
{
        /* blablabla spawn something at origin */
}


minimiller 03-06-2009 10:05

Re: pass origin through functions
 
Quote:

/* blablabla spawn something at origin */
What does this bit actually do?
And what line is the warning on?

Hunter-Digital 03-06-2009 10:41

Re: pass origin through functions
 
I don't remember exacly, but I know it is because of the sent variable !... origin... now I send only an ID and store origin in a global variable and stuff like that...

Code:

public do_something(origin[3])
here is something wrong, I dunno how to parse arrays with functions...

oh... btw, the function was called via set_task() ... I think there was the error...

this is not to solve something, I already solved it through other method, it's just to know how to write things down... like parsing an array to a function via set_task()... 'cause I got a invalid tag error there :)

minimiller 03-06-2009 11:09

Re: pass origin through functions
 
are you exec ing the "do_something" on a player?
If so, do this:
Code:

public do_something(id, origin[3])
{
    /* blablabla spawn something at origin */
}


stupok 03-06-2009 11:18

Re: pass origin through functions
 
Quote:

Originally Posted by Hunter-Digital (Post 775154)
oh... btw, the function was called via set_task() ... I think there was the error...

That's the line you should show us, then.

Bugsy 03-06-2009 11:52

Re: pass origin through functions
 
get_user_origin expects an integer origin, not float. If you use fakemeta to get an origin, then you would be using a float.

Try this:

PHP Code:

public function(id)
{
       static 
origin[3];
       
get_user_origin(idorigin);
 
       
do_something(origin);
}
 
public 
do_something(origin[3])
{
        
/* blablabla spawn something at origin */


or

PHP Code:

public function(id)
{
       static 
Float:fOrigin[3];
       
pev(idpev_origin fOrigin);
 
       
do_something(fOrigin);
}
 
public 
do_something(Float:fOrigin[3])
{
        
/* blablabla spawn something at origin */



Hunter-Digital 03-06-2009 12:27

Re: pass origin through functions
 
Quote:

Originally Posted by stupok (Post 775173)
That's the line you should show us, then.

I did explain the code I had, it's not that hard to imagine a fricken set_task =), ok LOOK:

Code:

public function(id)
{
      static origin[3]
      get_user_origin(id, origin)
 
      set_task(1.0, "do_something", origin)
}
 
public do_something(origin[3])
{
        /* blablabla spawn something at origin */
}

the error:
test.sma(15) : error 035: argument type mismatch (argument 3)
(line 15 is the set_task)

PS: like I said, I found another method to do this, but just to know how it's made in case I need to send an array via set_task() or something...

anakin_cstrike 03-06-2009 13:16

Re: pass origin through functions
 
PHP Code:

new Float:g_fOrigin];
// ...

public funcindex )
{
pevindexpev_origing_fOrigin );
set_task1.0"something" );
}

public 
something()
// use origin 


ConnorMcLeod 03-06-2009 14:43

Re: pass origin through functions
 
http://www.amxmodx.org/funcwiki.php?...task&go=search


set_task ( 1.0, "Task_Name", iTaskId, iOrigin, 3)

public Task_Name(iOrigin)
{
}

Hunter-Digital 03-06-2009 15:41

Re: pass origin through functions
 
that was it :P thanks... forgot about funcwiki :oops: :mrgreen:
--------------------------------------------------------
Quote:

Originally Posted by anakin_cstrike (Post 775271)
PHP Code:

new Float:g_fOrigin];
// ...
 
public funcindex )
{
pevindexpev_origing_fOrigin );
set_task1.0"something" );
}
 
public 
something()
// use origin 


I already said I found that alternative :)
Quote:

Originally Posted by Hunter-Digital (Post 775154)
... now I send only an ID and store origin in a global variable and stuff like that...



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

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