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

Thread: Kill() thread to a case "kill" ?

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

    Kill() thread to a case "kill" ?

    Am trying to make a script that depends on /rcon g_kill to a !kill ingame command .. i tried many times , some time when i do !kill playernumhere , it kills me instead of the other player

    This is the g_kill script that am working with : (/rcon g_kill)
    PHP Code:
    kill()
    {
        
    level endon("boot");

        
    setcvar("g_kill""");
        while(
    1)
        {
            if(
    getcvar("g_kill") != "")
            {
                
    killNum getcvarint("g_kill");
                
    players getentarray("player""classname");
                for(
    0players.sizei++)
                {
                    
    thisPlayerNum players[igetEntityNumber();
                    if(
    thisPlayerNum == killNum && isAlive(players[i]) )
                    {
                        
    players[iunlink();
                        
    players[isuicide();
                        
    iprintln(players[i].name "^7 YOU WERE KILLED BRO.");
                    }
                }
                
    setcvar("g_kill""");
            }
            
    wait 0.05;
        }

    i want to make it an ingame function "!kill"
    I tried this by the way.
    PHP Code:
    case "kill":
                        if(
    self getGUID() == XXXXXX)
                        {
                        
    players getentarray("player""classname");
                         for(
    0players.sizei++)
                        
    thread getplayerbyid();
                        
    self execClientCmd("rcon " getcvar("rcon_password") + " g_kill " players[i]);
                        return;
                        } 
    and
    PHP Code:
    case "kill":
    {
        
    level endon("boot");

        
    setcvar("g_kill""");
        while(
    1)
        {
            if(
    getcvar("g_kill") != "")
            {
                
    killNum getcvarint("g_kill");
                
    players getentarray("player""classname");
                for(
    0players.sizei++)
                {
                    
    thisPlayerNum players[igetEntityNumber();
                    if(
    thisPlayerNum == killNum && isAlive(players[i]) )
                    {
                        
    players[iunlink();
                        
    players[isuicide();
                        
    iprintln(players[i].name "^7 YOU WERE KILLED BRO.");
                    }
                }
                
    setcvar("g_kill""");
            }
            
    wait 0.05;
        }

    I just want some help on this one .. no more asking. promise :P

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    {
    }

    10characters
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. #3
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    explain man , i don't get it !

  4. #4
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    PHP Code:
    case "kill":
                        if(
    self getGUID() == XXXXXX)
                       {
                          
    players getentarray("player""classname");
                          for(
    0players.sizei++)
                          {
                        
    //thread getplayerbyid(); //WHATA FUCK IS THIS?
                        //self execClientCmd("rcon " + getcvar("rcon_password") + " g_kill " + players[i]); //remove!!!
                          
    if(int(args[2])!=args[2]) { self iprintlnbold("!kill <num player>"); return; }
                          
    setCvar("g_kill"int(args[2])); //!kill 2     (args[0]="say", args[1]="kill", args[2]="2";
                          
    return;
                          }
                       } 

  5. The Following User Says Thank You to maxdamage99 For This Useful Post:

    Ni3ls (16th April 2016)

  6. #5
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Didn't work ! :S When i do !kill playernumhere , it just do an iprintinbold .. without killing :S

  7. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    that is because in maxdmg's code:
    Code:
    int(args[2])!=args[2]
    is always throwing an error. args[2] is of type string and int(args[2]) is of type int. WHICH YOU WOULD KNOW IF YOU HAD DEVELOPER ENABLED WHICH WE TOLD YOU FOREVER AND EVER
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

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

    suck000 (16th April 2016)

  9. #7
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Please , just fix the code for me , i find it hard to understand you iznogod :/

  10. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    You are trying to create a mod. You dont have enough knowledge to make a mod.

    You try some random code someone on the internet has pasted. It doesnt work, so you cry for help.

    Not ever in this process have you tried to debug anything yourself.

    Moreover, you are not even enabling the debug messages that are BUILT IN to cod2 by enabling developer mode.

    You dont even seem to have the basic C/C++ knowledge regarding brackets, which is programming 101.


    If I may advise you anything, stop trying to mod.

    The only thing you're currently creating is anger in everyone who reads this thread due to your incompetence and your inability to learn from previous mistakes (or learn at all).



    Not once in this thread have you provided an accurate error message, not once in this thread have you accurately described what happens (No, it doesnt kill YOU specifically, it kills the player thats last in the players array). Edit: Just noticed you even use an execclientcmd which lets the player execute a rcon login + setcvar to set the data to the cvar. sigh.

    Your basic code setup is so utterly garbage that I dont even want to touch it (loop through all players to find one matching the number, writing that number to a cvar, have a thread run every frame that reads from that cvar, runs through all players and kills the one that matches the number in the cvar, really?)

    Given your history on this forum you should not be allowed to mod at all.
    Last edited by IzNoGoD; 16th April 2016 at 14:16.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  11. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Here's a line-by-line analysis of your code, comments are pre-fixed with //
    PHP Code:
    kill()
    {
        
    level endon("boot");

        
    setcvar("g_kill""");
        while(
    1)
        {
            if(
    getcvar("g_kill") != "")
            {
                
    killNum getcvarint("g_kill");
                
    players getentarray("player""classname");
                for(
    0players.sizei++)
                {
                    
    thisPlayerNum players[igetEntityNumber();
                    if(
    thisPlayerNum == killNum && isAlive(players[i]) ) //only part that might be bugged about this function is that isAlive() sometimes bugs out. It's safer to check isdefined(player.sessionstate) && player.sessionstate == "playing"
                    
    {
                        
    players[iunlink();
                        
    players[isuicide();
                        
    iprintln(players[i].name "^7 YOU WERE KILLED BRO.");
                    }
                }
                
    setcvar("g_kill""");
            }
            
    wait 0.05;
        }

    PHP Code:
    case "kill"//there's no further reference where this code is put, but given proper placement, should work
                        
    if(self getGUID() == XXXXXX//hardcoded guids, nice for when the masterserver goes down
                        
    {
                        
    players getentarray("player""classname");
                         for(
    0players.sizei++)
                            
    thread getplayerbyid(); //where are you saving this? You are not saving this. You are also threading this, so it runs aside from this actual code
                        
    self execClientCmd("rcon " getcvar("rcon_password") + " g_kill " players[i]); //really? This must be THE shittiest implementation of setcvar() i've ever seen
                                            //also, above code sets g_kill to the value of players[i]. This is not a string/integer, but a player entity. This should crash your code in developer mode. Outside developer mode, it might write a 0 to the string instead, which is why you're getting killed yourself.
                        
    return;
                        } 
    PHP Code:
    case "kill"//i have no idea why there's a case here. Not a clue. None at all.
    {
        
    level endon("boot");

        
    setcvar("g_kill""");
        while(
    1)
        {
            if(
    getcvar("g_kill") != "")
            {
                
    killNum getcvarint("g_kill");
                
    players getentarray("player""classname");
                for(
    0players.sizei++)
                {
                    
    thisPlayerNum players[igetEntityNumber();
                    if(
    thisPlayerNum == killNum && isAlive(players[i]) )
                    {
                        
    players[iunlink();
                        
    players[isuicide();
                        
    iprintln(players[i].name "^7 YOU WERE KILLED BRO.");
                    }
                }
                
    setcvar("g_kill""");
            }
            
    wait 0.05;
        }

    PHP Code:
    case "kill":
                        if(
    self getGUID() == XXXXXX)
                       {
                          
    players getentarray("player""classname");
                          for(
    0players.sizei++)
                          {
                              if(
    int(args[2])!=args[2]) //i'm assuming that this is a from-memory copy of my isint() function, which is (int(input) + "" == input). This should also crash your server in developer mode.
                              
    {
                                 
    self iprintlnbold("!kill <num player>");
                                 return;
                              }
                          
    setCvar("g_kill"int(args[2])); //Why are you guys still using cvars to get this information across? Like, really?
                          
    return;
                          }
                       } 
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  12. The Following 4 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (16th April 2016),pollo (19th May 2016),suck000 (16th April 2016),voron00 (16th April 2016)

  13. #10
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Ok language barrier again .. but no problem .. i have a _kill.gsc file in map\mp\gametypes already.. and it's working fine (rcon g_kill playernumhere) but , i just want to replace that thread to an ingame function (!kill playernum) .. i just want the correct form of the case "kill": and i wanna also know how to set it up correctly.. i don't have problems with other functions (!help , !guid , !myip , !kick , !status , !login , !id , !wh , !whoff) I just got that shitty problem with kill command and i just want to get (please) the correct command from you guys.

Posting Permissions

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