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

Solved [L4D2] How to implement starting event?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
desire worker
Junior Member
Join Date: Dec 2018
Location: Umbrella Corporation
Old 12-09-2018 , 10:27   [L4D2] How to implement starting event?
Reply With Quote #1

Hi, I am noob in here and currently making custom plugin.

but don`t know how to implement starting event.

for example

suppose that I wanna get Axe in game starting(I know there is the mod for that kind of thins in this site i.e. ItemGiver. but this is just for study)

first, I have to hook the starting event. went Aliedmod wiki and find start event name.

there was 2 candidates; "round_start_pre_entity" and "round_start_post_nav".

Code:
public OnPluginStart()
{
     HookEvent("round_start_pre_entity", show_me_the_axe);
     HookEvent("round_start_post_nav", show_me_the_axe);
}

public Action:show_me_the_axe(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
        for (new i = 1; i <= MaxClients; i++)
	{
	        if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) == 2)
		{
			FakeClientCommand(i, "give axe");
			GivePlayerItem(i, "weapon_axe");
		}
	}
}
and I also found using OnMapStart() can be alternative way. so I made below

Code:
public  OnMapStart(){
        for (new i = 1; i <= MaxClients; i++)
	{
	        if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) == 2)
		{
			FakeClientCommand(i, "give axe");
			GivePlayerItem(i, "weapon_axe");
		}
	}
}
and tested all on left4dead2 singleplayer(in -insecure option)

and both of them never works. nothing happend.

what I have to use for game starting event?

and why aboves are not working

Last edited by desire worker; 12-11-2018 at 08:05.
desire worker is offline
 



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 19:28.


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