Results 1 to 1 of 1

Thread: libcod callback's list

  1. #1
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts

    libcod callback's list

    if it will be useful to someone, I will try to formulate a description for callbacks in libcod
    PlayerCommand
    Call before exec player command, arguments: self - client command executor, args - array of command
    You can use it for make self chat-system, and stop execution command (client->server) or add custom.
    clientCommand() - exec command (if you change args array - command no changed, args array - only for read!)
    https://killtube.org/showthread.php?...=8005#post8005
    PHP Code:
    CodeCallback_PlayerCommand(args)
    {
        
    self endon("disconnect");

        
    args[0];
        
        if (!
    isDefined(r) || (!self.stats["logged"] && != "mr") || == "kill"//players can't suicide (!execute "kill")
            
    return;
        
        if (
    == "score")
        {
            
    self clientCommand();
            return 
    self resetNextReliableTime();
        }
        
        
        
    self.pers["brokeSay"] = false;
        
        if (
    == "say" || == "say_team")
        {
            
    text joinChatText(args);
            
    potential_text skipSpaces(removeColors(text));
            if (
    potential_text.size || !isDefined(args[1][0]) || args[1][0] == "\"")
                return;
            
            if (
    self isMuted())
                
    self.pers["brokeSay"] = true;
                
            
    self playerSay(textargs[0]);
                
            if (
    args[1][0] == "!" && isDefined(args[1][1]))
            {
                
    pCommand tolower(getSubStr(args[1], 1));
                
                if (
    pCommand == "hi")
                {
                    
    iprintlnbold(skipColors(self.name) + ": hi all!");
                    
    self iprintln("hi soldier ;)");
                    
                    return;
                }
            }
        }
        
    self clientCommand();
    }

    joinChatText(args)
    {
        
    message "";
        for (
    1args.sizei++)
            if (
    isDefined(args[i]))
            {
                if (
    1)
                    
    message += " ";
                
                if (
    isDefined(args[i])) 
                    
    message += args[i];
            }
        
        return 
    message;
    }

    playerSay(textcmd)
    {
        
    //text = "daj mne broni pls";
        
    switch (cmd)
        {
            case 
    "say":
            
    /* player say */
            /* check muted etc.*/
                
    break;
                
            case 
    "say_team":
            
    /* say team */
            /* some... */
                
    break;
        }
    }

    skipSpaces(string)
    {
        return 
    /*string without " " (spaces)*/;
    }

    skipColors(string)
    {
        return 
    /*string with only one ^7 (color)*/;
    }

    removeColors(string)
    {
        return 
    /*string without ^123456 (all colors)*/;

    Userinfochanged
    Call after changing clients base
    may on/off renaming, control NULL or standart names.
    clientUserInfoChanged() - accept clients base changing
    https://killtube.org/showthread.php?...t=info+changed
    https://killtube.org/showthread.php?...t=info+changed
    PHP Code:
    CodeCallback_UserInfoChanged(num)
    {
        
        
    //get_userinfo(key) - getting value of key
        //set_userinfo(key, value) - set value for key
        
        
    oldname self.name;
        
    newname self get_userinfo("name");
            
        if (
    oldname != newname && level.renameType != "allow"//broke all renames
            
    return setName(oldname);
            
        if (
    oldname != newname && self scripts\_player::isEmptyName(newname)) //isEmptyName return false if size < 5; Unnamed Player; Unknown Soldier
            
    return setName(oldname);
        
        
    self clientuserinfochanged();
    }

    setName(name//maybe useless :)
    {
        
    self.name name;
        
    self set_userinfo(name);

    Vid_restart
    call after client reload video settings
    Some client data may lose after reload, can repeat here.
    PHP Code:
    CodeCallback_VidRestart(num)
    {
        
    // :)

    FireGrenade
    call after grenade throw
    Anti team killer, or custom functions for nades
    only inform callback, but grenade entity can delete; self - grenade owner; name - weapon name (grenade)
    PHP Code:
    CodeCallback_FireGrenade(grenadename//from voron00
    {
        
    self endon("disconnect");
        
        
    team self.pers["team"];
        
        
    //iprintlnbold(grenade getcooktime());
        //iprintlnbold(self getcooktime());
        /* show leftime before grenade explode */

        
    if (name == "bignade_mp")
            
    self thread scripts\_customNades::bigBoom(grenade); //with getcooktime, and grenade.origin - some magic....
        
        
    while(isDefined(grenade))
            if(
    isDefined(self) && isDefined(grenade) && team != self.pers["team"])
                
    grenade delete();
            else
                
    wait 0.05;

    MeleeButton | UseButton | AttackButton
    meleebuttonPressed() | useButtonPressed() | fireButtonPressed()
    better way to track clicks versus cyclical checks "while(!player usebuttonPressed()) wait .1;"

    PHP Code:
    CodeCallback_MeleeButton()
    {
        if (!
    self.Running)
            
    self thread scripts\_sprint::gogogogo();
    }

    CodeCallback_AttackButton()
    {
        
    iprintlnbold(self.name "pew pew pew");
    }

    CodeCallback_UseButton()
    {
        if (
    self thread scripts\_killstreak::check("artillery"))
            return;
        
        if (
    self thread scripts\_killstreak::check("napalm"))
            return;
        
        if (
    self thread scripts\_killstreak::check("mortar"))
            return;

    RemoteCommands
    call before exec rcon commands
    you may broke changed rcon_password, killserver etc.
    doRcon(from, pointerMSG); - exec rcon comand; arguments: from - ip : port executor, command = "*** rcon <rcon_password> status" | "*** rcon FWLRj3a4n5teaTTW clientkick 14"; pointerMSG - dont touch me pls
    WARNING: between call and doRcon time <= ~4.5 secs (rcon command have lifetime (maybe or may not))
    https://killtube.org/showthread.php?3153-callback-RCON

    ClientSpam (test callback)
    for RateLimiter
    If some "people" want to spam your server (Rcon, status, info) - you can block him, but... if you have more insidious punishment for him, you can send data in callback
    https://killtube.org/showthread.php?...7456#post17456

    Dprintf (test callback)
    all developer printfs move in callback
    you can sort and filter all data in "developer > 0"

    PHP Code:
    codecallback_Dprintf(string)
    {
        if (
    isSubStr(string"useless developer spam"))
            return;
        
        
    printf("%\n"string);

    I could not describe some callbacks properly, if someone has a more correct description or code examples - write
    possible mistakes in sentences

    I will be grateful if administrators can help and correct the wording text from the point of view of the English language
    Last edited by maxdamage99; 14th January 2019 at 06:28.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  2. The Following 3 Users Say Thank You to maxdamage99 For This Useful Post:

    kung foo man (14th January 2019),Ni3ls (15th January 2019),Whiskas (17th January 2019)

Posting Permissions

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