|
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
|
03-28-2017
, 07:13
Re: [L4D] Event Debugger
|
#3
|
Quote:
Originally Posted by Neon123
[...]
|
There are two options:
Either through door related events:
PHP Code:
HookEvent("door_open", OnDoorOpen); HookEvent("door_close", OnDoorClose);
public Action OnDoorOpen(Event event, const char[] name, bool dontBroadcast) { bool isCheckpoint = event.GetBool("checkpoint"); if (!isCheckpoint) { return Plugin_Continue; } // do stuff here }
public Action OnDoorClose(Event event, const char[] name, bool dontBroadcast) { bool isCheckpoint = event.GetBool("checkpoint"); if (!isCheckpoint) { return Plugin_Continue; } // do stuff here }
Almost accurate but with a minor setback, the bool applies to both kinds of saferoom doors.
Or player_use event:
PHP Code:
bool alreadyDone;
HookEvent("round_start", OnRoundStart); HookEvent("player_use", OnPlayerUse, EventHookMode_Pre);
public Action OnRoundStart(Event event, const char[] name, bool dontBroadcast) { if (!alreadyDone) // prevent bug { return Plugin_Continue; } alreadyDone = false; return Plugin_Continue; }
public Action OnPlayerUse(Event event, const char[] name, bool dontBroadcast) { if (alreadyDone) // in order to prevent spam { return Plugin_Continue; } int usedTarget = event.GetInt("targetid"); if (usedTarget == -1 || !IsValidEntity(usedTarget) || !IsValidEdict(usedTarget)) { return Plugin_Continue; } char targetModel[PLATFORM_MAX_PATH], targetEnt[64]; GetEntPropString(usedTarget, Prop_Data, "m_ModelName", targetModel, sizeof(targetModel)); GetEntityClassname(usedTarget, targetEnt, sizeof(targetEnt)); if (StrContains(targetModel, "checkpoint_door", false) != -1 && StrEqual(targetEnt, "prop_door_rotating_checkpoint", false)) // make sure the model is a checkpoint door and it is a checkpoint entity 'cause some maps have these models but are not real checkpoints and more like props. { alreadyDone = true; if (targetModel[36] == '1' || targetModel[37] == '1') // 'cause some maps use saferoom models with a negative sign before 0. { // do stuff here } else if (targetModel[36] == '2' || targetModel[37] == '2') // same with the end saferoom. { // do stuff here } } return Plugin_Continue; }
By far is much better as this event checks it all - the model, the entity classname, etc. I would recommend this even advise myself when making plugins involving entities.
Last edited by cravenge; 03-28-2017 at 07:20.
|
|
|
|