1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Writing plugins help

Discussion in 'Source SDK / Map developement' started by T95, Sep 6, 2016.

  1. T95
    Offline

    T95 Member
    Mapper

    Joined:
    Apr 18, 2015
    Messages:
    52
    Likes Received:
    33
    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?
     
    #1
  2. Nomy
    Offline

    Nomy Administrator
    Super Admin ]HeLL[ Member

    Joined:
    Oct 11, 2010
    Messages:
    35,883
    Likes Received:
    3,688
    Can you explain what do you mean? What are you trying to do?
     
    #2
  3. T95
    Offline

    T95 Member
    Mapper

    Joined:
    Apr 18, 2015
    Messages:
    52
    Likes Received:
    33
    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);
    }
     
    #3
  4. Nomy
    Offline

    Nomy Administrator
    Super Admin ]HeLL[ Member

    Joined:
    Oct 11, 2010
    Messages:
    35,883
    Likes Received:
    3,688
    No there isnt such event to hook on.
     
    #4
  5. T95
    Offline

    T95 Member
    Mapper

    Joined:
    Apr 18, 2015
    Messages:
    52
    Likes Received:
    33
    #5
  6. Nomy
    Offline

    Nomy Administrator
    Super Admin ]HeLL[ Member

    Joined:
    Oct 11, 2010
    Messages:
    35,883
    Likes Received:
    3,688
    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);
    }
    
     
    #6
    • Like Like x 1
  7. T95
    Offline

    T95 Member
    Mapper

    Joined:
    Apr 18, 2015
    Messages:
    52
    Likes Received:
    33
    Thank you so much,that worked perfectly. Now I can see my mistakes. I have a lot of things to learn...
     
    #7