Out of town for my grandmothers b-day so adding may be slow.
public Action:OnTouch(client, door)
{
if (people_number == 5 && door == any)
{
FakeClientCommand(client,"kill")
}
}
( ͡° ͜ʖ ͡°)
Now that i read the actual full source code I see why it was lagging.
What might be a better idea is to only hook the objects themselves and then it will only trigger when an ent touches them and there is always less of them than players. So rather than what every player is touching and then if they are touching a banned item. It would be less cost to hook the restricted item instead. Likewise you could also try to only hook players who are actually restricted.
Second clients needs a validy check before being used in any arrays to ensure that it is indeed a valid client and not some random entity for example which would cause an arrayindex out of bounds error.
Another temp and faster solution may be to check if a user has a restrected item and then force them to drop it. You could run the check every 1 second or something or implement it as a delay after they get the item. For example the plugin already knows when a user gets an item and if that user is supposed to be restricted so if they were restrected you could start a 1 second timer to make the user drop the item. This would then allow an unrestricted user to pick it up.
Ok, so I reworked it so sdkhooks only get attached to banned people and get unhooked when they are unbanned. So this should stop the constant checking which was causing lag. Zero would you take a look at it and tell me what you think?
Hey Zero, heres an unofficial update to the entwatch system, made by an alliedmodder.
https://forums.alliedmods.net/attach...3&d=1406859664
This version allows the use of temporary entity bans, AND prevents items from disappearing on harry potter if a banned person picks up a wand.
Luxina that is mine. ( ͡° ͜ʖ ͡°) I go by drummer1249 on sourcemods.
That version is bad because its sdk checks are messed up. The Tempban thing works though but the sdkhooks causing the lag was the major issue.
Whoops, sorry. What happened was I made the rar and then realized I forgot to put in a line of code and remade the rar and then blanked on putting it in. -.-
Here it is.
Places to note are the code on lines (The lines that deal with SDKhook)
235-257
262-303
835-858
863-888
893-901
975-998
It works on my test server fine. The only problem that has plagued this is the SDKHook_Touch which causes lag. I think that if the SDKHook is only registered to people who are banned, then we should be fine? Or maybe the lines 262-303 could be reworked?
The function is also in efficient in that the order of operations for example is not optimized which is critical for a function that runs constantly.
Note that in this code we are waiting to check if the client is even supposed to be restricted at the very end within a loop! Also any check that can be done outside of a loop needs to for performance.Code:if (G_bConfigLoaded && !G_bRoundTransition && IsValidEdict(trigger)) { for (new index = 0; index < entArraySize; index++) { if (entArray[index][ent_hammerid] == Entity_GetHammerID(trigger)) { if (entArray[index][ent_trigger] == 1) { if (G_bRestricted[client] || G_bTemp[client]) { if (entArray[index][ent_torient] == 0) { CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted"); TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, straight); return Plugin_Handled; } else if (entArray[index][ent_torient] == 1) { CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted"); TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, left); return Plugin_Handled; } else if (entArray[index][ent_torient] == 2) { CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted"); TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, right); return Plugin_Handled; } else if (entArray[index][ent_torient] == 3) { CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted"); TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, back); return Plugin_Handled; } } } } } }