Raised This Month: $ Target: $400
 0% 

trouble returning a float from a stock


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
diamond-optic
Veteran Member
Join Date: May 2005
Old 01-22-2009 , 22:00   trouble returning a float from a stock
Reply With Quote #1

alright i feel really dumb about not understanding why this is happening..

but anyway im getting tag mismatch errors when i call the stock and also at the end of the stock (at the closing }), ingame it all seems to still work fine, but id really like to get rid of the error msgs..

this is in a function where its called:
Code:
new Float:hitOrigin[3] hitOrigin = get_hitplace_origin(victim,hitplace)

here's the stock:
Code:
stock get_hitplace_origin(id,hitplace) {     new Float:origin[3],Float:angles[3]     switch(hitplace)         {         case HIT_HEAD: hitplace = 19         case HIT_CHEST: hitplace = 11         case HIT_LEFTARM: hitplace = 15         case HIT_RIGHTARM: hitplace = 18         case HIT_STOMACH: hitplace = 9         case HIT_GENERIC: hitplace = 10         case HIT_LEFTLEG: hitplace = 3         case HIT_RIGHTLEG: hitplace = 6         }         engfunc(EngFunc_GetBonePosition,id,hitplace,origin,angles)                         return origin }

i do not get these errors if i dont use floats, but i rather just use the floats and save myself from having to convert them back and forth if at all possible
__________________
diamond-optic is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-22-2009 , 22:47   Re: trouble returning a float from a stock
Reply With Quote #2

Why not just do this:
Code:
new Float:hitOrigin[3] get_hitplace_origin(victim,hitplace, hitOrigin)

Code:
stock get_hitplace_origin(id,hitplace,Float:origin[3]) {     new Float:angles[3]     switch(hitplace)         {         case HIT_HEAD: hitplace = 19         case HIT_CHEST: hitplace = 11         case HIT_LEFTARM: hitplace = 15         case HIT_RIGHTARM: hitplace = 18         case HIT_STOMACH: hitplace = 9         case HIT_GENERIC: hitplace = 10         case HIT_LEFTLEG: hitplace = 3         case HIT_RIGHTLEG: hitplace = 6         }         engfunc(EngFunc_GetBonePosition,id,hitplace,origin,angles) }

But, I will show you how to do it your way:
When returning values from a method, the data type must be declared:
Code:
// returning ints get_int() {     return 1; } // returning floats Float:get_float() {     return 1.0; } // returning booleans bool:get_bool() {     return true; } // IMPORTANT NOTE!: When returning an array, the receiving and sending arrayss must be the same cell size. // returning strings new mystring[20]; mystring = get_string(); //.. get_string() {     return "some stuff";     // or     new string[20];     // format string     return string; } // Invalid: new mystring[2]; mystring = get_string(); //.. get_string() {     new string[20];     //..     return string; } // Also invalid: new mystring[40]; mystring = get_string(); //.. get_string() {     new string[20];     //..     return string; } // and you can continue for other data types
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
diamond-optic
Veteran Member
Join Date: May 2005
Old 01-22-2009 , 23:19   Re: trouble returning a float from a stock
Reply With Quote #3

wow im embarrassed i even posted now.. the first method you posted works and is something i somehow never even thought of

thanks!
__________________
diamond-optic is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-22-2009 , 23:29   Re: trouble returning a float from a stock
Reply With Quote #4

Exolent: Can you really return arrays if the dimensions are the same? I thought that you couldn't ever return them. But if so, that's pretty cool.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-23-2009 , 00:44   Re: trouble returning a float from a stock
Reply With Quote #5

Yes we can
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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 01:49.


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