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 ?