Oh wrong forum thread. I'm sorry. Must be
Scripting.
Need some help.
I want to lock the saferoom doors in the round start for some time. To prevent players from leaving the saferoom ahead of time.
I use this code. But the doors are locked not always. Approximately 50 \ 50.
Is there a better way to lock the door?
Code:
public OnPluginStart()
{
HookEvent("player_use", OnPlayerUse);
}
public Action:OnPlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(IsClientInGame(client) && GetClientTeam(client) == 2)
{
new entity = GetEventInt(event, "targetid");
AcceptEntityInput(entity, "Close");
AcceptEntityInput(entity, "Lock");
AcceptEntityInput(entity, "forceclosed");
}
return Plugin_Continue;
}
For unlock saferoom door i use this code and timer:
Code:
OpenDoor()
{
decl String:sClassname[] = "prop_door_rotating_checkpoint";
new index = -1;
while((index = FindEntityByClassname(index, sClassname)) != -1)
{
if(GetEntProp(index, Prop_Data, "m_bLocked") > 0)
{
AcceptEntityInput(index, "Unlock");
}
}
}
Unlock always works. No problem with it.