Results 1 to 10 of 15

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    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

  2. 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)

Posting Permissions

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