Sorry if the thread is in wrong place, I couldn't find a better place for it. I just started coding plugins and Im having some problems. So I was wondering is there a good coder that can help me and other people like me in writing plugins and answer my stupid questions. For example, how do I get targets name from event silencer_on?
Yes. I was studing scripting and I was trying to use event which is named "silencer_off" in events list like . In documentation they say, that it has "userid" option. So I tried to use this userid for exctracting players name and writing in chat for example:"%username% really? Taking off silencer in 2k16?" This is my code but reading compile log makes me feel that its completly wrong. #include <sourcemod> public Plugin myinfo = { name = "Blabla", author = "blalba", description = "blabla", version = "1.0", url = "http://natribu.org/" }; public void OnPluginStart() { HookEvent("silencer_off", Event_Silencer); } public void Event_Silencer(Event event,new char:name[],bool dontBroadcast) { char name[64]; int guysid = event.GetInt("userid"); int guy = GetClientOfUserId(guysid); GetClientName(guy, name, sizeof(name)); PrintToChatAll("%s just removed silencer!",name); }
I forgot notice,that im writing for CS:GO and using online sourcemod compiler. And in this list I can clearly see it (num.47) https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events . Thanks anyway (no sarcasm)
I didn't realise it was for CS:GO. Try this: Code: #include <sourcemod> public Plugin myinfo = { name = "Blabla", author = "blalba", description = "blabla", version = "1.0", url = "http://natribu.org/" }; public void OnPluginStart() { HookEvent("silencer_on", Event_SilencerOn); HookEvent("silencer_off", Event_SilencerOff); } public Event_SilencerOn(Handle:event, const String:name[],bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); PrintToChatAll("%N just added silencer!", client); } public Event_SilencerOff(Handle:event, const String:name[],bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); PrintToChatAll("%N just removed silencer!", client); }
Thank you so much,that worked perfectly. Now I can see my mistakes. I have a lot of things to learn...