Raised This Month: $ Target: $400
 0% 

pass origin through functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-06-2009 , 09:45   pass origin through functions
Reply With Quote #1

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 */
}
__________________
Hunter-Digital is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 03-06-2009 , 10:05   Re: pass origin through functions
Reply With Quote #2

Quote:
/* blablabla spawn something at origin */
What does this bit actually do?
And what line is the warning on?
__________________
minimiller is offline
Send a message via MSN to minimiller
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-06-2009 , 10:41   Re: pass origin through functions
Reply With Quote #3

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
__________________
Hunter-Digital is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 03-06-2009 , 11:09   Re: pass origin through functions
Reply With Quote #4

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 */
}
__________________
minimiller is offline
Send a message via MSN to minimiller
stupok
Veteran Member
Join Date: Feb 2006
Old 03-06-2009 , 11:18   Re: pass origin through functions
Reply With Quote #5

Quote:
Originally Posted by Hunter-Digital View Post
oh... btw, the function was called via set_task() ... I think there was the error...
That's the line you should show us, then.
__________________
stupok is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-06-2009 , 11:52   Re: pass origin through functions
Reply With Quote #6

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 */

__________________

Last edited by Bugsy; 03-06-2009 at 11:57.
Bugsy is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-06-2009 , 12:27   Re: pass origin through functions
Reply With Quote #7

Quote:
Originally Posted by stupok View Post
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...
__________________
Hunter-Digital is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-06-2009 , 13:16   Re: pass origin through functions
Reply With Quote #8

PHP Code:
new Float:g_fOrigin];
// ...

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

public 
something()
// use origin 
__________________

anakin_cstrike is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2009 , 14:43   Re: pass origin through functions
Reply With Quote #9

http://www.amxmodx.org/funcwiki.php?...task&go=search


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

public Task_Name(iOrigin)
{
}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 03-06-2009 , 15:41   Re: pass origin through functions
Reply With Quote #10

that was it thanks... forgot about funcwiki
--------------------------------------------------------
Quote:
Originally Posted by anakin_cstrike View Post
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 View Post
... now I send only an ID and store origin in a global variable and stuff like that...
__________________
Hunter-Digital is offline
Reply


Thread Tools
Display Modes

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:55.


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