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