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

Solved Problem with Hook


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 12-05-2020 , 08:44   Problem with Hook
Reply With Quote #1

Hi,

Marttt made a plugin that changes the color of common infected, so I thought it would be nice to have some more variety on prob_physics and prob_dynamic cars.

So i threw together this poc for this but am struggeling on the hook to change the cars colors.

When I hook player_death (just for testing... ) the cars change colors everytime the player_death occurs. When I hook round_freeze_end nothing happens. Does anyone have an idea how to hook that right?

HookEvent("player_death", event_round_freeze_end, EventHookMode_PostNoCopy);
//HookEvent("round_freeze_end", event_round_freeze_end, EventHookMode_PostNoCopy);

Just start no mercy map and check those cars.

Thx
Attached Files
File Type: sp Get Plugin or Get Source (l4d1_colorful_cars.sp - 146 views - 10.5 KB)
__________________

Last edited by finishlast; 12-07-2020 at 03:26.
finishlast is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-05-2020 , 15:26   Re: Problem with Hook
Reply With Quote #2

I did several experiments recently related to car colors.
Cars entity (and/or its properties) has some specific of initialization in a way that even "round_freeze_end" event is not enough to wait for.
I noticed this is somehow related to the existence of at least 1 live player to be fully in-game and be spawned.

You can receive the minimal safe delay to do that after the map start by hooking for "player_first_spawn" with additional checks (see this plugin).
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 12-06-2020 , 04:32   Re: Problem with Hook
Reply With Quote #3

Due to my stupidity it didn't work.

My other problems were caused by the hook, I used EventHookMode_PostNoCopy which broke the detection of bots and humans...

int client = GetClientOfUserId(event.GetInt("userid"));
if( client && IsClientInGame(client) && !IsFakeClient(client) )


It does work with "player_first_spawn" and I only use 1 timer.

One problem left, it only changed the car on first team, when next team round its not changed.
Is player_first_spawn only fired on first round in versus and not in 2nd?

So I replaced player_first_spawn with player_spawn now and made a bool after use that seems to do the trick now.

Thanks a lot man!!!

I attached the working version for now.
Attached Files
File Type: sp Get Plugin or Get Source (l4d1_colorful_cars.sp - 139 views - 10.5 KB)
__________________

Last edited by finishlast; 12-07-2020 at 03:26.
finishlast is offline
Reply



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 07:55.


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