Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: 2 scripts , one file ?

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

    2 scripts , one file ?

    Hi all , i got a !kick command that is working fine. I wanted to add a !vote command https://killtube.org/showthread.php?2485-Call-a-vote , but both of them uses callbacksetup.

    My question is , how to make !vote command works while there is another command in _callbacksetup.gsc.

    Thanks

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

  3. #3
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Bump (x2) AM NOT SPAMMING
    215 chars.

  4. #4
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    sudo apt-get rekt

  5. #5
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    did not understand anything. Explain me how to do this.

  6. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Step 1: Dont bump your own thread twice in 30 minutes, it will NOT help. The only thing you did was bump it OVER your other thread, which was last replied to by... you.

    Step 2: learn how to code. Seriously.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. #7
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Am trying man! I just need a help. How to do this. Please

  8. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    This is everything you need.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. #9
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    I tried to understand , i made everything in tutorials. I did not understand anything Please am fucking rekt ! fffffffffffffffssssssssssssssssssssssss
    Kick command :
    PHP 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)
        {

    // -- Added by DaMole --
            
    svr\bash::init();
    // --        
            

            
    [[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(eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset)
    {
        
    self endon("disconnect");
        [[
    level.callbackPlayerDamage]](eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset);
    }

    /*================
    Called when a player has been killed.
    self is the player that was killed.
    ================*/
    CodeCallback_PlayerKilled(eInflictoreAttackeriDamagesMeansOfDeathsWeaponvDirsHitLoctimeOffsetdeathAnimDuration)
    {
        
    self endon("disconnect");
        [[
    level.callbackPlayerKilled]](eInflictoreAttackeriDamagesMeansOfDeathsWeaponvDirsHitLoctimeOffsetdeathAnimDuration);
    }

    //=============================================================================

    /*================
    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=0i<newArgs.sizei++) 
                    
    args[1+i] = newArgs[i]; 
            } 
        } 
        return 
    args



    checkIfExist(number)
    {
        
    players getentarray("player""classname");
        for(
    0players.sizei++) 
        {
            if(
    players[igetentitynumber() == Int(number))
                return 
    true;
        }
        return 
    false;    
    }

    thirdArgument(args)
    {
        
    text "";
        for(
    i=3i<args.sizei++)
            
    text += args[i] + " ";
        return 
    text;
    }

    getPlayerNameById(number)
    {
        
    players getentarray("player""classname");
        for(
    0players.sizei++) 
        {
            if(
    players[igetentitynumber() == Int(number))
                return 
    players[i].name;
        }
        return 
    false;
    }

    getPlayerById(number)
    {
        
    players getentarray("player""classname");
        for(
    0players.sizei++) 
        {
            if(
    players[igetEntityNumber() == 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=0i<args.sizei++) 
            
    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() == 706687)
                {
                    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(); 

    Vote command :
    PHP Code:
    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)
            {
                
    //std\io::print("delete bad ascii code: " + std\utils::getAscii(args[1][0]) + "\n"); 
                
    args[1] = getSubStr(args[1], 1);
                
    newArgs strTok(args[1], " ");
                for (
    0newArgs.sizei++)
                    
    args[i] = newArgs[i];
            }
        }
        return 
    args;
    }
    CodeCallback_PlayerCommand(args)
    {
        
    command "";
        
    output "";
        for (
    0args.sizei++)
            
    output += args[i] + ", ";

        
    //std\io::print("PLAYER COMMAND! message: " + output + "\n"); 
        
    args fixChatArgs(args);

        if (
    args[0] == "say" && isDefined(args[1]) && args[1][0] == "!" || args[0] == "say_team" && isDefined(args[1]) && args[1][0] == "!")
        {
            switch (
    getSubStr(args[1], 1))
            {
                       case 
    "vote"
                        if(
    isdefined(level.pers["voted"]) && level.pers["voted"] == 1)
                        {
                            
    self iprintlnbold("Already a vote running");
                            return;
                        }
                        
    time =0;
                        
    level.pers["voted"] = 1;
                        
    level.pers["votesyes"]=0;
                        
    level.pers["votesno"]=0;
                        if(
    isint(args[args.size-1]))
                        {
                            
    time int(args[args.size-1]);
                            
    level.definetime 1
                            
    //iprintlnbold("time: "+time);
                        
    }
                        else
                        {
                                
    //iprintlnbold("no time, time set to 20");
                                
    time =20;
                                
    level.definetime 0
                        }
                        
    question "";
                        if(
    isdefined(level.definetime) && level.definetime == 1)
                        {
                                            for (
    2args.size-1i++)
                                                
    question += args[i] + " ";
                        }
                        else
                        {
                                            for (
    2args.sizei++)
                                                
    question += args[i] + " ";
                        }    
                        
                        
    iprintlnbold("^1Question^7: "+question);
                        
    iprintlnbold("Use !yes and !no to vote");

                        
    thread maketimer(time);
                        
    wait time;
                        
    iprintlnbold("Counting Votes");
                        
    wait 1;
                        
    iprintlnbold("Votes ^2Yes^7: "level.pers["votesyes"]);
                        
    iprintlnbold("Votes ^1No^7: "level.pers["votesno"]);
                        
                        
    level.pers["voted"] = 0;
                        
    players getentarray("player""classname");
                        for (
    0players.sizei++)
                        {
                            
    players[i].pers["hasvoted"]=0;
                        }

                        return;  
                        
                       case 
    "yes"
                        if(!
    isdefined(level.pers["voted"]) || level.pers["voted"] == 0)
                        {
                            
    self iprintlnbold("No vote running");
                            return;
                        }
                        if(
    isdefined(self.pers["hasvoted"]) && self.pers["hasvoted"] == 1)
                        {
                            
    self iprintlnbold("Already voted");
                            return;
                        }
                        
    level.pers["votesyes"] ++;
                        
    self.pers["hasvoted"]=1;
                        
    self iprintlnbold("You voted:  ^2Yes");
                        return;  
                        
                       case 
    "no"
                        if(!
    isdefined(level.pers["voted"]) || level.pers["voted"] == 0)
                        {
                            
    self iprintlnbold("No vote running");
                            return;
                        }
                        if(
    isdefined(self.pers["hasvoted"]) && self.pers["hasvoted"] == 1)
                        {
                            
    self iprintlnbold("Already voted");
                            return;
                        }
                        
    level.pers["votesno"] ++;
                        
    self iprintlnbold("You voted: ^1No");
                        return; 
            }    
        }

        
    self ClientCommand();




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

Posting Permissions

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