yokomo
11-14-2014, 13:23
Hi, in NMRiH (No More Room In Hell) there are no chat info when player has unlocked their achievement, so i wanna recreate that chat info. But when i test in server it doesn't print anything after i unlocked any achievement.
#include <sourcemod>
public Plugin:myinfo =
{
name = "NMRiH Achievement Info",
author = "wbyokomo",
description = "NULL",
version = "0.0.1",
url = "NULL"
}
new String:szAchievement[MAXPLAYERS+1][64]
#define IsPlayer(%0) (1<=%0<=MaxClients)
public OnPluginStart()
{
HookEvent("achievement_event", OnAchievementEventPre, EventHookMode_Pre)
HookEvent("achievement_earned", OnAchievementEarnedPre, EventHookMode_Pre)
}
public Action:OnAchievementEventPre(Handle:event, const String:name[], bool:dontBroadcast)
{
new id = GetClientOfUserId(GetEventInt(event, "userid"))
if(IsPlayer(id) && IsClientInGame(id)) GetEventString(event, "achievement_name", szAchievement[id], sizeof(szAchievement[]));
}
public Action:OnAchievementEarnedPre(Handle:event, const String:name[], bool:dontBroadcast)
{
new id = GetClientOfUserId(GetEventInt(event, "player"))
if(IsPlayer(id) && IsClientInGame(id)) PrintToChatAll("%N has earned the achievement %s", id, szAchievement[id]);
}
What is wrong with my code? or i hooked the wrong event?
Thanks.
#include <sourcemod>
public Plugin:myinfo =
{
name = "NMRiH Achievement Info",
author = "wbyokomo",
description = "NULL",
version = "0.0.1",
url = "NULL"
}
new String:szAchievement[MAXPLAYERS+1][64]
#define IsPlayer(%0) (1<=%0<=MaxClients)
public OnPluginStart()
{
HookEvent("achievement_event", OnAchievementEventPre, EventHookMode_Pre)
HookEvent("achievement_earned", OnAchievementEarnedPre, EventHookMode_Pre)
}
public Action:OnAchievementEventPre(Handle:event, const String:name[], bool:dontBroadcast)
{
new id = GetClientOfUserId(GetEventInt(event, "userid"))
if(IsPlayer(id) && IsClientInGame(id)) GetEventString(event, "achievement_name", szAchievement[id], sizeof(szAchievement[]));
}
public Action:OnAchievementEarnedPre(Handle:event, const String:name[], bool:dontBroadcast)
{
new id = GetClientOfUserId(GetEventInt(event, "player"))
if(IsPlayer(id) && IsClientInGame(id)) PrintToChatAll("%N has earned the achievement %s", id, szAchievement[id]);
}
What is wrong with my code? or i hooked the wrong event?
Thanks.