Raised This Month: $12 Target: $400
 3% 

Property not found


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ozrich
AlliedModders Donor
Join Date: Oct 2015
Old 04-26-2019 , 01:34   Property not found
Reply With Quote #1

Hi Folks,

I'm getting the below error:

PHP Code:
L 04/26/2019 15:28:04: [SMException reportedProperty "m_vecOrigin" not found (entity 107/ins_ragdoll)
L 04/26/2019 15:28:04: [SMBlamingozrespawn4.3.smx
L 04
/26/2019 15:28:04: [SMCall stack trace:
L 04/26/2019 15:28:04: [SM]   [0GetEntPropVector
L 04
/26/2019 15:28:04: [SM]   [1Line 6026D:\Libraries\Insurgency Development\Sourcemod\WIP\scripting\ozrespawn4.3.sp::HealthkitGroundCheckTimer 
The function is below:

PHP Code:
Action HealthkitGroundCheckTimer(Handle timerany entity)
{
    if (
entity MaxClients && IsValidEntity(entity))
    {
        
float fGameTime GetGameTime();
        if (
fGameTime-g_fTimeCheck[entity] >= 1.0)
        {
            
float fOrigin[3];
            
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
            
//int iRoundHeight = RoundFloat(fOrigin[2]);
            
int iRoundHeight RoundFloat(fOrigin[2]);
            if (
iRoundHeight == g_iTimeCheckHeight[entity])
            {
                
g_fTimeCheck[entity] = GetGameTime();
                
SDKUnhook(entitySDKHook_VPhysicsUpdateHealthkitGroundCheck);
                
SDKHook(entitySDKHook_VPhysicsUpdateOnEntityPhysicsUpdate);
            }
        }
    }

Why would I be getting this? I've compared it to other code where I'm using m_vecOrigin. I've attached the source if that helps.
Attached Files
File Type: sp Get Plugin or Get Source (ozrespawn4.3.sp - 82 views - 221.3 KB)
__________________
ozrich is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-26-2019 , 01:43   Re: Property not found
Reply With Quote #2

It literally tells you why...

Spoiler


EDIT:

Ok ill be abit more helpful
You are passing an entity index into a timer, never do that Pass an entity reference instead.

https://sm.alliedmods.net/new-api/ha...tIndexToEntRef
https://sm.alliedmods.net/new-api/ha...tRefToEntIndex

PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname"healthkit"))
    {
        
Handle hDatapack;
        
CreateDataTimer(Healthkit_Timer_TickrateHealthkithDatapackTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);// you really sure you want it to be a repeat timer?
        
WritePackCell(hDatapackEntIndexToEntRef(entity));
        
WritePackFloat(hDatapackGetGameTime()+Healthkit_Timer_Timeout);
        
g_fLastHeight[entity] = -9999.0;
        
g_iTimeCheckHeight[entity] = -9999.0;
        
SDKHook(entitySDKHook_VPhysicsUpdateHealthkitGroundCheck);
        
CreateTimer(0.1HealthkitGroundCheckTimerEntIndexToEntRef(entity), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);// you really sure you want it to be a repeat timer?
    
}
}

// return Plugin_Stop = stop timer, return Plugin_Continue = continue repeat the timer with repeat flag.
public Action HealthkitGroundCheckTimer(Handle timerany entref)
{
    
int entity EntRefToEntIndex(entref));// converts an entity reference back to an ent index will be -1(0xFFFFFFFF)(INVALID_ENT_REFERENCE ) if invalid
    
if(entref == INVALID_ENT_REFERENCE || !IsValidEntity(entref))
        return 
Plugin_Stop;// CLOSE TIMERS don't leave them running if you don't need them.
    
    
float fGameTime GetGameTime();
    if (
fGameTime-g_fTimeCheck[entity] >= 1.0)
    {
        
float fOrigin[3];
        
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
        
//int iRoundHeight = RoundFloat(fOrigin[2]);
        
int iRoundHeight RoundFloat(fOrigin[2]);
        if (
iRoundHeight == g_iTimeCheckHeight[entity])
        {
            
g_fTimeCheck[entity] = GetGameTime();
            
SDKUnhook(entitySDKHook_VPhysicsUpdateHealthkitGroundCheck);
            
SDKHook(entitySDKHook_VPhysicsUpdateOnEntityPhysicsUpdate);
        }
    }
    return 
Plugin_Continue;// because you put timer repeat flag i'm going to assume you want it to repeat i don't really want to dig into 6k lines sorry
}

public 
Action Healthkit(Handle timerHandle hDatapack)
{
    
ResetPack(hDatapack);
    
int entity EntRefToEntIndex(ReadPackCell(hDatapack));//converting an entref back to an index, if it's -1 means that exact entity nolonger exists.
    
float fEndTime ReadPackFloat(hDatapack);
    
float fGameTime GetGameTime();
    
    if (
entity != INVALID_ENT_REFERENCE && IsValidEntity(entity) && fGameTime <= fEndTime)
    {
        
float fOrigin[3];
        
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
        if (
g_fLastHeight[entity] == -9999.0)
        {
            
g_fLastHeight[entity] = 0.0;
            
EmitSoundToAll("Lua_sounds/healthkit_healing.wav"entitySNDCHAN_STATIC__0.7);
        }
        
//fOrigin[2] += 16.0;
        
fOrigin[2] += 1.0;
        
//TE_SetupBeamRingPoint(beamPos, 1.0, Revive_Indicator_Radius, g_iBeaconBeam, g_iBeaconHalo, 0, 15, 5.0, 3.0, 5.0, {255, 0, 0, 255}, 1, (FBEAM_FADEIN, FBEAM_FADEOUT));
        
TE_SetupBeamRingPoint(fOrigin15.0Healthkit_Radius*0.55g_iBeaconBeamg_iBeaconHalo051.01.02.0, {0204100255},1,0);
        
// // //TE_SetupBeamRingPoint(fOrigin, 5.0, Healthkit_Radius*1.95, g_iBeaconBeam, g_iBeaconHalo, 0, 30, 5.0, 3.0, 5.0, {0, 255, 0, 255}, 1, (FBEAM_FADEOUT));
        //TE_SetupBeamRingPoint(fOrigin, 10.0, Healthkit_Radius*1.95, g_iBeaconBeam, g_iBeaconHalo, 0, 30, 0.6, 3.0, 0.0, {0, 204, 102, 255}, 3, 0);
        
TE_SendToAll();
        
fOrigin[2] -= 16.0;
        if (
fOrigin[2] != g_fLastHeight[entity])
        {
            
g_fLastHeight[entity] = fOrigin[2];
        }
        else
        {
            
float fAng[3];
            
GetEntPropVector(entityProp_Send"m_angRotation"fAng);
            if (
fAng[1] > 89.0 || fAng[1] < -89.0)
                
fAng[1] = 90.0;
            if (
fAng[2] > 89.0 || fAng[2] < -89.0)
            {
                
fAng[2] = 0.0;
                
fOrigin[2] -= 6.0;
                
TeleportEntity(entityfOriginfAngview_as<float>({0.00.00.0}));
                
fOrigin[2] += 6.0;
                
EmitSoundToAll("ui/sfx/cl_click.wav"entitySNDCHAN_STATIC__1.0);
            }
        }
        for (
int iPlayer 1;iPlayer <= MaxClients;iPlayer++)
        {
            if (
IsClientInGame(iPlayer) && IsPlayerAlive(iPlayer) && GetClientTeam(iPlayer) == 2)
            {
                
float fPlayerOrigin[3];
                
GetClientEyePosition(iPlayerfPlayerOrigin);
                if (
GetVectorDistance(fPlayerOriginfOrigin) <= Healthkit_Radius)
                {
                    
DataPack hData CreateDataPack();
                    
WritePackCell(hDataentity);
                    
WritePackCell(hDataiPlayer);
                    
fOrigin[2] += 32.0;
                    
Handle trace TR_TraceRayFilterEx(fPlayerOriginfOriginMASK_SOLIDRayType_EndPointFilter_ClientSelfhData);
                    
delete hData;
                    if (!
TR_DidHit(trace))
                    {
                        
int iMaxHealth GetEntProp(iPlayerProp_Data"m_iMaxHealth");
                        
int iHealth GetEntProp(iPlayerProp_Data"m_iHealth");
                        if (
iMaxHealth iHealth)
                        {
                            
iHealth += GetRandomInt(Healthkit_Healing_Per_Tick_MinHealthkit_Healing_Per_Tick_Max);
                            if (
iHealth >= iMaxHealth)
                            {
                                
EmitSoundToAll("Lua_sounds/healthkit_complete.wav"iPlayerSNDCHAN_STATIC__1.0);
                                
iHealth iMaxHealth;
                                
//PrintToChat(iPlayer, "\x05竊긌ua \x01@ \x03You are completely healed!");
                                
PrintCenterText(iPlayer"Healed !\n\n \n %d %%\n \n \n \n \n \n \n \n"iMaxHealth);
                            }
                            else 
PrintCenterText(iPlayer"Healing...\n\n \n   %d %%\n \n \n \n \n \n \n \n"iHealth);
                            
SetEntProp(iPlayerProp_Data"m_iHealth"iHealth);
                        }
                    }
                }
            }
        }
    }
    else
    {
        return 
Plugin_Stop;// You are leaking handles and you are using a repeat time while passing an entindex to a timer don't pass the entindex use a reference.
    
}
    return 
Plugin_Continue;// because you are using a repeat timer flag i'm going to assume you want it to repeat.

I have no idea what else is wrong with this code, i did not look too much into it i'm assuming you want it to be a repeat timer because you are passing a repeat flag into both of them, if you don't want it to be repeat a repeat timer don't pass the repeat flag.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 04-26-2019 at 03:21. Reason: Being more helpful
Lux is offline
ozrich
AlliedModders Donor
Join Date: Oct 2015
Old 04-26-2019 , 06:32   Re: Property not found
Reply With Quote #3

@Lux, thank you for being helpful Still learning much of this as you could tell.

I can understand you not wanting to look into it too much in depth.

I tried to replace GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin); with HasEntProp(entity, Prop_Send, "m_vecOrigin"); and it broke what the code is meant to do. Did I do the wrong thing?

I believe it does need to be a repeat timer. Essentially, the player throws a "healthkit" which displays a beam and restores HP as long as you're there. The healthkit disappears after a while. I assume this is the repeat timer?

I might move this back to a separate plugin for easy troubleshooting and what I imagine would be good practice?
__________________
ozrich is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-26-2019 , 06:41   Re: Property not found
Reply With Quote #4

if 6klines worked flawlessly it would not matter but since this plugin is awful yes splitting it would be eaiser.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
ozrich
AlliedModders Donor
Join Date: Oct 2015
Old 04-26-2019 , 07:45   Re: Property not found
Reply With Quote #5

PHP Code:
/*
 *    [INS] Healthkit Script
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define PLUGIN_DESCRIPTION "Healthkit plugin"
#define PLUGIN_VERSION "2.0"

//LUA Healing define values
#define Healthkit_Timer_Tickrate            0.8        // Basic Sound has 0.8 loop
#define Healthkit_Timer_Timeout                360.0 //6 minutes
#define Healthkit_Radius                    350.0
#define Healthkit_Remove_Type                "1"
#define Healthkit_Healing_Per_Tick_Min        1
#define Healthkit_Healing_Per_Tick_Max        3
#define MAX_ENTITIES 2048

// Plugin info
public Plugin myinfo =
{
    
name "[INS] Healthkit",
    
author "ozzy, original D.Freddo",
    
version PLUGIN_VERSION,
    
description PLUGIN_DESCRIPTION
}

int g_iBeaconBeam,
g_iBeaconHalo;
float g_fLastHeight[2048] = {0.0, ...},
g_fTimeCheck[2048] = {0.0, ...},
g_iTimeCheckHeight[2048] = {0.0, ...};

int g_ammoResupplyAmt[MAX_ENTITIES+1];

public 
void OnPluginStart()
{
    
CreateConVar("Lua_Ins_Healthkit"PLUGIN_VERSIONPLUGIN_DESCRIPTIONFCVAR_NOTIFY FCVAR_DONTRECORD);
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("grenade_thrown"Event_GrenadeThrown);
}

public 
void OnMapStart()
{
    
g_iBeaconBeam PrecacheModel("sprites/laserbeam.vmt");
    
g_iBeaconHalo PrecacheModel("sprites/halo01.vmt");
    
// Healing sounds
    
PrecacheSound("Lua_sounds/healthkit_complete.wav");
    
PrecacheSound("Lua_sounds/healthkit_healing.wav");
    
// Destory, Flip sounds
    
PrecacheSound("soundscape/emitters/oneshot/radio_explode.ogg");
    
PrecacheSound("ui/sfx/cl_click.wav");
    
// Deploying sounds
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup1.ogg");
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup2.ogg");
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup3.ogg");
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/holdposition2.ogg");
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/holdposition3.ogg");
    
PrecacheSound("player/voice/radial/security/leader/unsuppressed/moving2.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/backup3.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition1.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition2.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition3.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition4.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/moving3.ogg");
    
PrecacheSound("player/voice/radial/security/leader/suppressed/ontheway1.ogg");
    
PrecacheSound("player/voice/security/command/leader/located4.ogg");
    
PrecacheSound("player/voice/security/command/leader/setwaypoint1.ogg");
    
PrecacheSound("player/voice/security/command/leader/setwaypoint2.ogg");
    
PrecacheSound("player/voice/security/command/leader/setwaypoint3.ogg");
    
PrecacheSound("player/voice/security/command/leader/setwaypoint4.ogg");

    
/*
    AddFileToDownloadsTable("materials/models/items/healthkit01.vmt");
    AddFileToDownloadsTable("materials/models/items/healthkit01.vtf");
    AddFileToDownloadsTable("materials/models/items/healthkit01_mask.vtf");
    AddFileToDownloadsTable("models/items/healthkit.dx80.vtx");
    AddFileToDownloadsTable("models/items/healthkit.dx90.vtx");
    AddFileToDownloadsTable("models/items/healthkit.mdl");
    AddFileToDownloadsTable("models/items/healthkit.phy");
    AddFileToDownloadsTable("models/items/healthkit.sw.vtx");
    AddFileToDownloadsTable("models/items/healthkit.vvd");
    AddFileToDownloadsTable("sound/Lua_sounds/healthkit_complete.wav");
    AddFileToDownloadsTable("sound/Lua_sounds/healthkit_healing.wav");
    */
}

public 
void OnPluginEnd()
{
    
int ent = -1;
    while ((
ent FindEntityByClassname(ent"healthkit")) > MaxClients && IsValidEntity(ent))
    {
        
//StopSound(ent, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
        
AcceptEntityInput(ent"Kill");
    }
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    
int ent = -1;
    while ((
ent FindEntityByClassname(ent"healthkit")) > MaxClients && IsValidEntity(ent))
    {
        
StopSound(entSNDCHAN_STATIC"Lua_sounds/healthkit_healing.wav");
        
AcceptEntityInput(ent"Kill");
    }
}

public 
Action Event_GrenadeThrown(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
int nade_id GetEventInt(event"entityid");
    if (
nade_id > -&& client > -1)
    {
        if (
IsPlayerAlive(client))
        {
            
char grenade_name[32];
            
GetEntityClassname(nade_idgrenade_namesizeof(grenade_name));
            if (
StrEqual(grenade_name"healthkit"))
            {
                switch(
GetRandomInt(118))
                {
                    case 
1EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup1.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
2EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup2.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
3EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
4EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition2.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
5EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
6EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/moving2.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
7EmitSoundToAll("player/voice/radial/security/leader/suppressed/backup3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
8EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition1.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
9EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition2.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
10EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
11EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition4.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
12EmitSoundToAll("player/voice/radial/security/leader/suppressed/moving3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
13EmitSoundToAll("player/voice/radial/security/leader/suppressed/ontheway1.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
14EmitSoundToAll("player/voice/security/command/leader/located4.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
15EmitSoundToAll("player/voice/security/command/leader/setwaypoint1.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
16EmitSoundToAll("player/voice/security/command/leader/setwaypoint2.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
17EmitSoundToAll("player/voice/security/command/leader/setwaypoint3.ogg"clientSNDCHAN_VOICE__1.0);
                    case 
18EmitSoundToAll("player/voice/security/command/leader/setwaypoint4.ogg"clientSNDCHAN_VOICE__1.0);
                }
            }
        }
    }
}

public 
void OnEntityDestroyed(int entity)
{
    if (
entity MaxClients)
    {
        
char classname[255];
        
GetEntityClassname(entityclassname255);
        if (
StrEqual(classname"healthkit"))
        {
            
StopSound(entitySNDCHAN_STATIC"Lua_sounds/healthkit_healing.wav");
        }
        if (!(
StrContains(classname"wcache_crate_01") > -1))
        {
            
g_ammoResupplyAmt[entity] = 0
        }
    }
}

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname"healthkit"))
    {
        
Handle hDatapack;
        
CreateDataTimer(Healthkit_Timer_TickrateHealthkithDatapackTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
        
WritePackCell(hDatapackentity);
        
WritePackFloat(hDatapackGetGameTime()+Healthkit_Timer_Timeout);
        
g_fLastHeight[entity] = -9999.0;
        
g_iTimeCheckHeight[entity] = -9999.0;
        
SDKHook(entitySDKHook_VPhysicsUpdateHealthkitGroundCheck);
        
CreateTimer(0.1HealthkitGroundCheckTimerentityTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action HealthkitGroundCheck(int entityint activatorint callerUseType typefloat value
{
    
float fOrigin[3];
    
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
    
float iRoundHeight = (fOrigin[2]);
    if (
iRoundHeight != g_iTimeCheckHeight[entity]) 
    {
        
g_iTimeCheckHeight[entity] = iRoundHeight;
        
g_fTimeCheck[entity] = GetGameTime();
    }
}

public 
Action HealthkitGroundCheckTimer(Handle timerany entity)
{
    if (
entity MaxClients && IsValidEntity(entity))
    {
        
float fGameTime GetGameTime();
        if (
fGameTime-g_fTimeCheck[entity] >= 1.0)
        {
            
float fOrigin[3];
            
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
            
int iRoundHeight RoundFloat(fOrigin[2]);
            if (
iRoundHeight == g_iTimeCheckHeight[entity])
            {
                
g_fTimeCheck[entity] = GetGameTime();
                
SDKUnhook(entitySDKHook_VPhysicsUpdateHealthkitGroundCheck);
                
SDKHook(entitySDKHook_VPhysicsUpdateOnEntityPhysicsUpdate);
            }
        }
    }
}

public 
Action OnEntityPhysicsUpdate(int entityint activatorint callerUseType typefloat value)
{
    
TeleportEntity(entityNULL_VECTORNULL_VECTORview_as<float> ({0.00.00.0}));
}

public 
Action Healthkit(Handle timerHandle hDatapack)
{
    
ResetPack(hDatapack);
    
int entity ReadPackCell(hDatapack);
    
float fEndTime ReadPackFloat(hDatapack);
    
float fGameTime GetGameTime();
    if (
entity && IsValidEntity(entity) && fGameTime <= fEndTime)
    {
        
float fOrigin[3];
        
GetEntPropVector(entityProp_Send"m_vecOrigin"fOrigin);
        if (
g_fLastHeight[entity] == -9999.0)
        {
            
g_fLastHeight[entity] = 0.0;
        }
        
fOrigin[2] += 1.0;
        
TE_SetupBeamRingPoint(fOrigin15.0Healthkit_Radius*0.55g_iBeaconBeamg_iBeaconHalo051.01.02.0, {0204100255},1,0);
        
TE_SendToAll();
        
fOrigin[2] -= 16.0;
        if (
fOrigin[2] != g_fLastHeight[entity])
        {
            
g_fLastHeight[entity] = fOrigin[2];
        }
        else
        {
            
float fAng[3];
            
GetEntPropVector(entityProp_Send"m_angRotation"fAng);
            if (
fAng[1] > 89.0 || fAng[1] < -89.0)
                
fAng[1] = 90.0;
            if (
fAng[2] > 89.0 || fAng[2] < -89.0)
            {
                
fAng[2] = 0.0;
                
fOrigin[2] -= 6.0;
                
TeleportEntity(entityfOriginfAngview_as<float>({0.00.00.0}));
                
fOrigin[2] += 6.0;
            }
        }
        for (
int iPlayer 1;iPlayer <= MaxClients;iPlayer++)
        {
            if (
IsClientInGame(iPlayer) && IsPlayerAlive(iPlayer) && GetClientTeam(iPlayer) == 2)
            {
                
float fPlayerOrigin[3];
                
GetClientEyePosition(iPlayerfPlayerOrigin);
                if (
GetVectorDistance(fPlayerOriginfOrigin) <= Healthkit_Radius)
                {
                    
DataPack hData CreateDataPack();
                    
WritePackCell(hDataentity);
                    
WritePackCell(hDataiPlayer);
                    
fOrigin[2] += 32.0;
                    
Handle trace TR_TraceRayFilterEx(fPlayerOriginfOriginMASK_SOLIDRayType_EndPointFilter_ClientSelfhData);
                    
delete hData;
                    if (!
TR_DidHit(trace))
                    {
                        
int iMaxHealth GetEntProp(iPlayerProp_Data"m_iMaxHealth");
                        
int iHealth GetEntProp(iPlayerProp_Data"m_iHealth");
                        if (
iMaxHealth iHealth)
                        {
                            
iHealth += GetRandomInt(Healthkit_Healing_Per_Tick_MinHealthkit_Healing_Per_Tick_Max);
                            if (
iHealth >= iMaxHealth)
                            {
                                
iHealth iMaxHealth;
                                
PrintCenterText(iPlayer"Healed !\n\n \n %d %%\n \n \n \n \n \n \n \n"iMaxHealth);
                            }
                            else 
PrintCenterText(iPlayer"Healing...\n\n \n   %d %%\n \n \n \n \n \n \n \n"iHealth);
                            
SetEntProp(iPlayerProp_Data"m_iHealth"iHealth);
                        }
                    }
                }
            }
        }
    }
}

public 
bool Filter_ClientSelf(int entityint contentsMaskDataPack dp
{
    
dp.Reset();
    
int client dp.ReadCell();
    
int player dp.ReadCell();
    return (
entity != client && entity != player);
}

public 
void RemoveHealthkit(int entity)
{
    if (
entity MaxClients && IsValidEntity(entity))
    {
        
StopSound(entitySNDCHAN_STATIC"Lua_sounds/healthkit_healing.wav");
        
EmitSoundToAll("soundscape/emitters/oneshot/radio_explode.ogg"entitySNDCHAN_STATIC__1.0);
        
int dissolver CreateEntityByName("env_entity_dissolver");
        if (
dissolver != -1)
        {
            
DispatchKeyValue(dissolver"dissolvetype"Healthkit_Remove_Type);
            
DispatchKeyValue(dissolver"magnitude""1");
            
DispatchKeyValue(dissolver"target""!activator");
            
AcceptEntityInput(dissolver"Dissolve"entity);
            
AcceptEntityInput(dissolver"Kill");
        }
    }

Attached Files
File Type: sp Get Plugin or Get Source (ozhealthkit.sp - 158 views - 12.9 KB)
__________________

Last edited by ozrich; 04-26-2019 at 10:21. Reason: Updated code
ozrich 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:09.


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