1. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Client only chat command output.

Discussion in 'Modding Help' started by SnIcKeRs, Aug 7, 2013.

  1. SnIcKeRs

    SnIcKeRs Bison Rider

    Messages:
    148
    Is it possible?
     
  2. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,580
    Yes.
    Let me find me back what is the function.

    Edit :
    Code:
    client_AddToChat( text, SColor);
    To place in
    Code:
    bool onServerProcessChat()
    , i believe it is what you want to do ( Chat processing )
     
  3. SnIcKeRs

    SnIcKeRs Bison Rider

    Messages:
    148
    I want to make individual command output for each player
     
  4. nkChehov

    nkChehov Ballista Bolt Thrower
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    172
    This function that trigger on chating
    bool onServerProcessChat( CRules@ this, const string& in text_in, string& out text_out, CPlayer@ player )

    it uses for script <ChatCommands.as> as so. If watch carefully, you may see here <text_in>, its text that you may analyze and also we have here <player>, so we know, who exactly wrote <text_in> lines.

    Just make condition in this function that check <text_in> and <player.username> to do something you wanna to.
     
  5. SnIcKeRs

    SnIcKeRs Bison Rider

    Messages:
    148
    My problem that other people can see output.
    </br>--- merged: Aug 10, 2013 at 10:36 AM ---</br>
    I found solution:
    Code:
    int TIME = 400;
    int showTime = 0;
    
    array<CPlayer@> arr;
    
    bool onClientProcessChat( CRules@ this, const string& in text_in, string& out text_out, CPlayer@ player ) {
            if (text_in == "/test") {
                    showTime = TIME;
                    addToGUI(player);
                    return false;
            }
            return true;
    }
    
    void onRender( CRules@ this )
    {
        if (g_videorecording)
            return;
        CPlayer@ player = getLocalPlayer();
        if (player is null || !player.isMyPlayer()  || !isGUI(player)) { return; }
    
        if (showTime > 0)
        {
            showTime--;
    
            const f32 screenDist = 400.0f;
            Vec2f mouse = getControls().getMouseScreenPos();
    
            CBlob@ playerBlob = player.getBlob();
            if(playerBlob is null) {return;}
            Vec2f pos2d = playerBlob.getScreenPos();
                          pos2d.y -= 190.0f + 6.0f*Maths::Sin( 1 / 5.5f );
                          const f32 distance = (playerBlob.getPosition()).getLength();
                          const bool isOnScreen = distance < screenDist;
                          Vec2f upperleft = pos2d + Vec2f(-70.0f, -16.0f);
                          Vec2f lowerright = pos2d + Vec2f(70.0f, 16.0f);
                          const bool mouseHover = (mouse.x > upperleft.x && mouse.x < lowerright.x && mouse.y > upperleft.y && mouse.y < lowerright.y);
    
                          string text = "Your local GUI " + player.getUsername();
                     
            Vec2f right(getScreenWidth(), 400);
        GUI::DrawText( text,
            upperleft, lowerright, color_black, true, true, !mouseHover );
        }else{
            removeFromGUI(player);
        }
    }
    
    void addToGUI(CPlayer@ player){
        if(!isGUI(player) ){
            arr.insertLast(player);
        }
    }
    void removeFromGUI(CPlayer@ player){
        int index = arr.find(player);
        if(index>0){
        arr.removeAt(index);
        }
    }
    bool isGUI(CPlayer@ player){
        for(uint i = 0; i < arr.length(); i++){
            if(arr[i] is player) return true;
        }
        return false;
    }
     
    Asu likes this.