Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50

Thread: CodeCallback_PlayerCommand(args) does not work

  1. #1
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts

    Question CodeCallback_PlayerCommand(args) does not work

    Hi , i was trying to add !kick command but it didn't work , i placed the .gsc file at moddirectory/maps/mp/gametypes , i restarted server to apply the changes but when am ingame , i do !kick but nothing appears :/ help me
    Code:
    //    Callback Setup 
    //    This script provides the hooks from code into script for the gametype callback functions. 
    
    //============================================================================= 
    // Code Callback functions 
    
    /*================ 
    Called by code after the level's main script function has run. 
    ================*/ 
    CodeCallback_StartGameType() 
    { 
        // If the gametype has not beed started, run the startup 
        if(!isDefined(level.gametypestarted) || !level.gametypestarted) 
        { 
            [[level.callbackStartGameType]](); 
            level.gametypestarted = true; // so we know that the gametype has been started up     
        } 
    } 
    
    /*================ 
    Called when a player begins connecting to the server. 
    Called again for every map change or tournement restart. 
    
    Return undefined if the client should be allowed, otherwise return 
    a string with the reason for denial. 
    
    Otherwise, the client will be sent the current gamestate 
    and will eventually get to ClientBegin. 
    
    firstTime will be qtrue the very first time a client connects 
    to the server machine, but qfalse on map changes and tournement 
    restarts. 
    ================*/ 
    
    CodeCallback_PlayerConnect() 
    {   
        self endon("disconnect");  
        [[level.callbackPlayerConnect]]();
    } 
    
    /*================ 
    Called when a player drops from the server. 
    Will not be called between levels. 
    self is the player that is disconnecting. 
    ================*/ 
    CodeCallback_PlayerDisconnect() 
    { 
        self notify("disconnect"); 
        [[level.callbackPlayerDisconnect]](); 
    } 
    
    /*================ 
    Called when a player has taken damage. 
    self is the player that took damage. 
    ================*/ 
    CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset) 
    { 
        self endon("disconnect"); 
        [[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset); 
    } 
    
    /*================ 
    Called when a player has been killed. 
    self is the player that was killed. 
    ================*/ 
    CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration) 
    { 
        self endon("disconnect"); 
        [[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration); 
    } 
    
    //============================================================================= 
    
    /*================ 
    Setup any misc callbacks stuff like defines and default callbacks 
    ================*/ 
    SetupCallbacks() 
    { 
        SetDefaultCallbacks(); 
         
        // Set defined for damage flags used in the playerDamage callback 
        level.iDFLAGS_RADIUS            = 1; 
        level.iDFLAGS_NO_ARMOR            = 2; 
        level.iDFLAGS_NO_KNOCKBACK        = 4; 
        level.iDFLAGS_NO_TEAM_PROTECTION    = 8; 
        level.iDFLAGS_NO_PROTECTION        = 16; 
        level.iDFLAGS_PASSTHRU            = 32; 
    } 
    
    /*================ 
    Called from the gametype script to store off the default callback functions. 
    This allows the callbacks to be overridden by level script, but not lost. 
    ================*/ 
    SetDefaultCallbacks() 
    { 
        level.default_CallbackStartGameType = level.callbackStartGameType; 
        level.default_CallbackPlayerConnect = level.callbackPlayerConnect; 
        level.default_CallbackPlayerDisconnect = level.callbackPlayerDisconnect; 
        level.default_CallbackPlayerDamage = level.callbackPlayerDamage; 
        level.default_CallbackPlayerKilled = level.callbackPlayerKilled; 
    } 
    
    /*================ 
    Called when a gametype is not supported. 
    ================*/ 
    AbortLevel() 
    { 
        println("Aborting level - gametype is not supported"); 
    
        level.callbackStartGameType = ::callbackVoid; 
        level.callbackPlayerConnect = ::callbackVoid; 
        level.callbackPlayerDisconnect = ::callbackVoid; 
        level.callbackPlayerDamage = ::callbackVoid; 
        level.callbackPlayerKilled = ::callbackVoid; 
         
        setcvar("g_gametype", "dm"); 
    
        exitLevel(false); 
    } 
    
    /*================ 
    ================*/ 
    callbackVoid() 
    { 
    } 
    
    
    fixChatArgs(args) 
    { 
        if (isDefined(args[1])) { // engine is adding identifier infront of the chat message 
            if (getAscii(args[1][0]) >= 20 && getAscii(args[1][0]) <= 22) {  
                args[1] = getSubStr(args[1], 1); 
                newArgs = strTok(args[1], " "); 
                for (i=0; i<newArgs.size; i++) 
                    args[1+i] = newArgs[i]; 
            } 
        } 
        return args; 
    } 
    
    
    checkIfExist(number)
    {
        players = getentarray("player", "classname");
        for(i = 0; i < players.size; i++) 
        {
            if(players[i] getentitynumber() == Int(number))
                return true;
        }
        return false;    
    }
    
    thirdArgument(args)
    {
        text = "";
        for(i=3; i<args.size; i++)
            text += args[i] + " ";
        return text;
    }
    
    getPlayerNameById(number)
    {
        players = getentarray("player", "classname");
        for(i = 0; i < players.size; i++) 
        {
            if(players[i] getentitynumber() == Int(number))
                return players[i].name;
        }
        return false;
    }
    
    getPlayerById(number)
    {
        players = getentarray("player", "classname");
        for(i = 0; i < players.size; i++) 
        {
            if(players[i] getEntityNumber() == Int(number))
                return players[i];
        }
        return false;
    }  
    
    tellMessage(message)
    {
        sendgameservercommand(self getentitynumber(), "h \"^7console: ^7" + message + "\"");
    }
    
    
    tellMessageWorld(message)
    {
        sendgameservercommand(-1, "h \"^7console: ^7" + message + "\"");
    }
    
    isint(string)
    {
         return ((int(string) + "") == string + "");
    } 
    
    
    CodeCallback_PlayerCommand(args) 
    { 
        output = ""; 
        for (i=0; i<args.size; i++) 
            output += args[i] + ", "; 
         
        args = fixChatArgs(args); 
    
         
        if (args[0] == "say" && isDefined(args[1]) && args[1][0] == "!")     
        { 
            switch (getSubStr(args[1], 1)) 
            { 
            case "kick":
                if(self getGUID() == "707051")
                {
                    if (isDefined(args[2]) && isint(args[2]) && isDefined(args[3])) 
                    {                       
                        args[2] = int(args[2]);
                        if(!checkIfExist(args[2]))
                        {
                            self thread tellMessage("Couldn\'t find a player with this number.");
                            return;
                        }
                        args[3] = thirdArgument(args);
                        kickmsg = "You were kicked, because of reason: " + args[3];
                        tokickname = getPlayerNameById(args[2]);
                        thread tellMessageWorld(tokickname + " ^7was kicked. Reason: " + args[3]);
                        kick2(args[2], kickmsg);
                        return;                    
                    }
                    else 
                    {                    
                        self thread tellMessage("Noone to kick, or no reason typed ._.");
                        return;
                    }
                }
                else 
                {
                    self thread tellMessage("You are not an admin.");
                    return; 
                }       
            } 
        }      
         
        self ClientCommand(); 
    }
    Last edited by suck000; 19th March 2016 at 06:46.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    How did you install libcod?

    Renamed from "How to do this ?" to "CodeCallback_PlayerCommand(args) does not work"
    timescale 0.01

  3. #3
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    It is not installed , idk how i install it , i just got the code from a friend , and he told me to put it in that directory and kick command will work. But server crash when i put it.

    Any help ?

  4. #4
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    My server is hosted on linux ubtunu , i got End map vote , and it is working fine , but this script won't work ... I really want to learn how to install " libcod " and how to make a script working because am tired for asking ppl how & how & how .. + ppl never help me , none has done since i came atleast

  5. #5
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    See ? i reply someone with my problem , and he never answers again.
    GG

  6. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Install howto: https://github.com/kungfooman/libcod/

    The world doesn't rotate around you, even if your spoiled brain might think that.
    timescale 0.01

  7. The Following User Says Thank You to kung foo man For This Useful Post:

    YuriJurek (19th March 2016)

  8. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Could be you got another mod installed, with a _callbacksetup in an iwd file, which will overwrite the one outside the iwd file (the one you made the modifications to)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. The Following User Says Thank You to IzNoGoD For This Useful Post:

    suck000 (19th March 2016)

  10. #8
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Well , i have 2 iwd mods placed on main , they could affect ?

  11. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    You are giving very little information to begin with

    All you're basically saying is: i painted the fence red and the dog doesnt like it.

    This doesnt give us information about
    1) wether or not your dog can see colors
    2) if the paint is still wet
    3) if the paint still smells
    4) if there's a bear behind the fence which the dog might be afraid of
    5) anything vacuum-cleaner related

    To translate the above into your question, could you confirm that
    1) you have libcod installed properly
    2) which version of libcod you have installed
    3) does your libcod version match your cod version
    4) which mods you are running
    5) what script files are inside those mods
    6) what error your server crashes with
    etcetera.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  12. The Following User Says Thank You to IzNoGoD For This Useful Post:

    YuriJurek (19th March 2016)

  13. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by kung foo man View Post
    Install howto: https://github.com/kungfooman/libcod/

    The world doesn't rotate around you, even if your spoiled brain might think that.
    What kung is saying: You posted 3 comments within 10 minutes, expecting IMMEDIATE help WITHOUT providing ANY details about your problem AT ALL.

    "ye someone else installed it idk" does NOT answer any question (aside from questions about your capabilities), and then go on to bash EVERYONE on this forum that happened to not respond to your question in the beforementioned 10 minutes.

    This. isnt. facebook.

    This is a forum, where people occasionally come, check for new posts, and where they might reply in case they would like to do so.
    Giving people shit for not instantly responding is not going to help your case, and neither is showing the greatest amount of ignorance towards stuff you installed.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  14. The Following User Says Thank You to IzNoGoD For This Useful Post:

    YuriJurek (19th March 2016)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •