Raised This Month: $32 Target: $400
 8% 

Origin Problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-11-2008 , 19:48   Origin Problems
Reply With Quote #1

ok im trying to get this stock to work but it gives me this error in my runtime logs:

Code:
L 04/11/2008 - 19:39:12: SourceMod error session started
L 04/11/2008 - 19:39:12: Info (map "de_dust") (file "errors_20080411.log")
L 04/11/2008 - 19:39:12: [SM] Native "GetEntDataFloat" reported: Offset -1 is invalid
L 04/11/2008 - 19:39:12: [SM] Displaying call stack trace for plugin "SourceMod Stocks Test.smx":
L 04/11/2008 - 19:39:12: [SM]   [0]  Line 176, C:\Documents and Settings\jared.JAREDS\Desktop\sourcemod-1.0.0\addons\sourcemod\scripting\include\sm_functions.inc::DistanceToTheFloor()
L 04/11/2008 - 19:39:12: [SM]   [1]  Line 26, C:\Documents and Settings\jared.JAREDS\Desktop\sma\SourceMod Stocks Test.sp::Spawn()
Heres Whats Supposed To Happen :

Code:
 
/*
DistanceToTheFloor(Ent)
 
 * Returns The Distance To The Floor (Float)
 * Ent Is The Index Of The Entity/Player (Integer)
 * Returns -1 On Failure
 
*/
and heres my stock function:

PHP Code:
 
public Float:DistanceToTheFloor(Ent)
{
 new 
m_Origin FindSendPropOffs("CBaseFlex""m_vecAbsOrigin");
 new 
Float:Origins[3];
 new 
Float:Distance;
 
 if(
IsValidEntity(Ent))
 {
  
Origins[2] = GetEntDataFloat(Ent,m_Origin);
  
Origins[1] == Distance;
 
  return 
Distance
 }
 return -
1.0;

and heres my test plugin :

PHP Code:
 
 
#include <sourcemod>
#include <sm_functions>
public Plugin:myinfo 
{
 
name "SourceMod Stocks Test",
 
author "Peoples Army",
 
description "<- Description ->",
 
version "1.0",
 
url "<- URL ->"
}
public 
OnPluginStart()
{
 
HookEvent("player_spawn",Spawn);
}
public 
Action:Spawn(Handle:event,const String:name[], bool:dontBroadcast)
{
 new 
userid GetEventInt(event,"userid");
 new 
client GetClientOfUserId(userid);
 
 if(
IsClientInGame(client))
 {
  new 
Float:Test DistanceToTheFloor(client);
  
PrintToChatAll("Distance is %d",Test);
 }

ive used m_vecAbsOrigin before (actualy earlier today) and it worked fine , i did it the same exact way i did here retrieving the offset with a FIndSendPropOffs();


any ideas why im getting this error and how to get and calcualte the origins properly ?
Peoples Army is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 04-11-2008 , 20:10   Re: Origin Problems
Reply With Quote #2

CBaseFlex doesn't seem to fit in there. See http://developer.valvesoftware.com/wiki/CBaseFlex for details.

The origin you are trying to read is relative to the world origin (0,0,0) and not related in any way to the floor the player is standing on/flying above.

I suggest drawing a traceline from the client's origin to the floor along the client's z-angle vector (or (0,0,-1)=vec_world_z_0 if you expect it to be perpendicular to the vec_world_x x vec_world_y plane).
sfPlayer is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-11-2008 , 20:32   Re: Origin Problems
Reply With Quote #3

hmm see thats weird , cuz i jsut used it an hour ago in another plugin and it worked perfectly , then i used it here and got this error .

well [1] is the x axis , which is measure by its distance to the floor (or maybee z is measure by its distance to the floor )
Peoples Army is offline
Davethegreat
Senior Member
Join Date: Nov 2007
Old 04-11-2008 , 20:37   Re: Origin Problems
Reply With Quote #4

To help you out
http://www.we-r-here.com/cad/tutoria...s/xyz_axes.gif
Davethegreat is offline
Send a message via AIM to Davethegreat
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-11-2008 , 20:39   Re: Origin Problems
Reply With Quote #5

so then the z axis would be measured from the floor
Peoples Army is offline
Davethegreat
Senior Member
Join Date: Nov 2007
Old 04-11-2008 , 20:39   Re: Origin Problems
Reply With Quote #6

Yep.
Davethegreat is offline
Send a message via AIM to Davethegreat
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-11-2008 , 20:41   Re: Origin Problems
Reply With Quote #7

ok , so theoritcly , the z model would give me the distance to the floor .

so how should i correctly get the origins ? cuz my above script gives me an error

should
Peoples Army is offline
Davethegreat
Senior Member
Join Date: Nov 2007
Old 04-11-2008 , 20:44   Re: Origin Problems
Reply With Quote #8

the error says
L 04/11/2008 - 199:12: [SM] Native "GetEntDataFloat" reported: Offset -1 is invalid
Maybe changed -1 to 0?
Davethegreat is offline
Send a message via AIM to Davethegreat
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-11-2008 , 20:50   Re: Origin Problems
Reply With Quote #9

no , look at the way i got the offset

PHP Code:
 
new Origins[3];
new 
m_Origin FindSendPropOffs("CBaseFlex""m_vecAbsOrigin");
 
Origins[2] = GetEntDataFloat(Ent,m_Origin); 
see i got the offset using a

PHP Code:
 
findsendpropoff
() 
that reaches for the offset "m_vecAbsOrigin", then it stors that offset in m_Origin (my variable) , and i use the variable to get the origin from

PHP Code:
 
 GetEntDataFLoat
() 
so the question is , why is it returning -1 to my varaible ? or how else can i retirieve the offset?
Peoples Army is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 04-13-2008 , 01:28   Re: Origin Problems
Reply With Quote #10

try with GetEntDataVector()
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
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 01:49.


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