Veteran Member
Join Date: Jan 2015
Location: Cat
|
04-26-2019
, 01:43
Re: Property not found
|
#2
|
It literally tells you why...
Spoiler
PHP Code:
HasEntProp(entity, Prop_Send, "m_vecOrigin");
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_Tickrate, Healthkit, hDatapack, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);// you really sure you want it to be a repeat timer? WritePackCell(hDatapack, EntIndexToEntRef(entity)); WritePackFloat(hDatapack, GetGameTime()+Healthkit_Timer_Timeout); g_fLastHeight[entity] = -9999.0; g_iTimeCheckHeight[entity] = -9999.0; SDKHook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck); CreateTimer(0.1, HealthkitGroundCheckTimer, EntIndexToEntRef(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 timer, any 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(entity, Prop_Send, "m_vecOrigin", fOrigin); //int iRoundHeight = RoundFloat(fOrigin[2]); int iRoundHeight = RoundFloat(fOrigin[2]); if (iRoundHeight == g_iTimeCheckHeight[entity]) { g_fTimeCheck[entity] = GetGameTime(); SDKUnhook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck); SDKHook(entity, SDKHook_VPhysicsUpdate, OnEntityPhysicsUpdate); } } 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 timer, Handle 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(entity, Prop_Send, "m_vecOrigin", fOrigin); if (g_fLastHeight[entity] == -9999.0) { g_fLastHeight[entity] = 0.0; EmitSoundToAll("Lua_sounds/healthkit_healing.wav", entity, SNDCHAN_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(fOrigin, 15.0, Healthkit_Radius*0.55, g_iBeaconBeam, g_iBeaconHalo, 0, 5, 1.0, 1.0, 2.0, {0, 204, 100, 255},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(entity, Prop_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(entity, fOrigin, fAng, view_as<float>({0.0, 0.0, 0.0})); fOrigin[2] += 6.0; EmitSoundToAll("ui/sfx/cl_click.wav", entity, SNDCHAN_STATIC, _, _, 1.0); } } for (int iPlayer = 1;iPlayer <= MaxClients;iPlayer++) { if (IsClientInGame(iPlayer) && IsPlayerAlive(iPlayer) && GetClientTeam(iPlayer) == 2) { float fPlayerOrigin[3]; GetClientEyePosition(iPlayer, fPlayerOrigin); if (GetVectorDistance(fPlayerOrigin, fOrigin) <= Healthkit_Radius) { DataPack hData = CreateDataPack(); WritePackCell(hData, entity); WritePackCell(hData, iPlayer); fOrigin[2] += 32.0; Handle trace = TR_TraceRayFilterEx(fPlayerOrigin, fOrigin, MASK_SOLID, RayType_EndPoint, Filter_ClientSelf, hData); delete hData; if (!TR_DidHit(trace)) { int iMaxHealth = GetEntProp(iPlayer, Prop_Data, "m_iMaxHealth"); int iHealth = GetEntProp(iPlayer, Prop_Data, "m_iHealth"); if (iMaxHealth > iHealth) { iHealth += GetRandomInt(Healthkit_Healing_Per_Tick_Min, Healthkit_Healing_Per_Tick_Max); if (iHealth >= iMaxHealth) { EmitSoundToAll("Lua_sounds/healthkit_complete.wav", iPlayer, SNDCHAN_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(iPlayer, Prop_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.
__________________
Last edited by Lux; 04-26-2019 at 03:21.
Reason: Being more helpful
|
|