Results 1 to 10 of 10

Thread: I need help ! :D

  1. #1
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts

    I need help ! :D

    Hello Killtube.

    I have some problems and I need some of your help.
    Okay, since I have libcod running on my server, how can I use it's functions?

    by adding them to gametype.gsc? or should i make new gsc files?

    also, sometimes i see someone writes a code like this


    someThing()
    [...]




    then he writes a PHP code start with

    case "something": etc


    My question here is: Where should I add this code?


    many thanks

  2. The Following User Says Thank You to nerdiiii For This Useful Post:

    kung foo man (27th May 2019)

  3. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    you can use libcod functions from anywhere in scripts.

    do you mean PHP /PHP tags? in these tags, the code looks more attractive and readable

    code like this
    PHP Code:
    /* hello guys */

    spawnPlayer()
    {


    put your code in [php] [ /php] (without first space in last tag)
    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

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

    kung foo man (27th May 2019)

  5. #3
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts
    I actually want to kick fakeplayers (bots) from my server, so I took a look at this thread [ https://killtube.org/showthread.php?...ke-clients-fix ]

    Now, whenever I try to put the script in sd.gsc, I got bad syntax, pls help me!!

    PHP Code:
    notifyConnecting()
    {
        
    self endon("disconnect");

        
    waittillframeend;

        if(
    isDefined(self))
        {
            
    level notify("connecting",self);
            
    setQ3Fix(); //Add this line
        
    }
        
        
    }
    setQ3Fix()
    {
        if(!
    isDefined(level.q3_fix))
            
    level.q3_fix = [];
            
        
    my_ip getIP(self);
        
        if(
    isDefined(level.q3_fix[my_ip]) && !self.data["bot"])
        {
            
    self setClientCvar("com_errorTitle""Error"); //Maybe somehow system will fail (it should'nt but we should always assume that can happens) and a real client can be kicked.
            
    self setClientCvar("com_errorMessage""IP duplicate detected"); //So let him know, what went wrong.
            
    self.kicked true;
            
    println("Warning: Kicking client with IP duplicate: "+my_ip);
            
    kick(self getEntityNumber());
            return 
    true;
        }
        
        if(!
    self.data["bot"])
            
    level.q3_fix[my_ip] = true;
            
        return 
    false;
    }
    getIP(client

        return 
    closer(430client getEntityNumber()); 
    }
    println(msg)
    {
        
    closer(200msg "\n");
    }
    Callback_PlayerDisconnect()
    {
      if(!
    isDefined(self.kicked))
          
    level.q3_fix[getIP(self)] = undefined;
      [...]

    Last edited by nerdiiii; 27th May 2019 at 10:17.

  6. #4
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    1.
    PHP Code:
    my_ip self getIP(); 
    2. Remove this and all libcod functions (made using "closer") from your .gsc scripts
    PHP Code:
    getIP(client)
    {
        return 
    closer(430/* ... */);

    ALL LIBCOD FUNCTIONS WORK WITHOUT "CLOSER"!
    Use them as normal (standard) functions like: isPlayer, getEntityNumber(), setClientCvar etc.

    This has already been explained many times on the forum.
    Use the latest version of libcod.
    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

  7. #5
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Okay, I've done this so far right now

    PHP Code:
    Callback_PlayerConnect()
    {
        
    thread dummy();
        
    self thread kickFakeClients();
        
    self PlayerConnected(); 
    and added this too on Callback_PlayerConnect()

    PHP Code:
    kickFakeClients()
    {
        
    self endon("begin");
        
    self endon("disconnect");

        if(
    self getGuid() != 0)
            return; 
    // cd key can only be used once

        
    wait 0.05;

        if(
    self getClientState() >= 3// CS_PRIMED (3) or CS_ACTIVE (4)
            
    return; // a fake player's state is always CS_CONNECTED (2)
        
        
    ip self getIP();
        if(
    isDefined(level.lastfakeplayerip) && level.lastfakeplayerip == ip
            
    wait 1.5;
        else 
    // more time when IP isn't the same as previous ip 
            
    wait 5;
        
        if(
    self getClientState() == 2)
        {
            
    lastconnect self getLastConnectTime();
            
    lastmsg self getLastMSG();
            if(
    lastconnect == lastmsg)
            {
                
    level.lastfakeplayerip ip// store ip from fake client
                
    self kickFakeClient(iplastconnectlastmsg);
            }
        }
    }

    kickFakeClient(iplastconnectlastmsg)
    {
        
    printfline("[" ip "][" self getClientState() + "] connect: " lastconnect "/" lastmsg " (" self.name ")");
        
    iprintln(self.name "^7 connection timeout.");
        
    kick(self getEntityNumber());

    and I got this shit bug everytime:

    Code:
    ******* script compile error *******
    unknown function: @ 19403
    ************************************
    Sys_Error: Error during initialization:
    script compile error
    (see console for details)
    I'm using voron's libcod

  8. #6
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by nerdiiii View Post
    Okay, I've done this so far right now

    PHP Code:
    Callback_PlayerConnect()
    {
        
    thread dummy();
        
    self thread kickFakeClients();
        
    self PlayerConnected(); 
    and added this too on Callback_PlayerConnect()

    PHP Code:
    kickFakeClients()
    {
        
    self endon("begin");
        
    self endon("disconnect");

        if(
    self getGuid() != 0)
            return; 
    // cd key can only be used once

        
    wait 0.05;

        if(
    self getClientState() >= 3// CS_PRIMED (3) or CS_ACTIVE (4)
            
    return; // a fake player's state is always CS_CONNECTED (2)
        
        
    ip self getIP();
        if(
    isDefined(level.lastfakeplayerip) && level.lastfakeplayerip == ip
            
    wait 1.5;
        else 
    // more time when IP isn't the same as previous ip 
            
    wait 5;
        
        if(
    self getClientState() == 2)
        {
            
    lastconnect self getLastConnectTime();
            
    lastmsg self getLastMSG();
            if(
    lastconnect == lastmsg)
            {
                
    level.lastfakeplayerip ip// store ip from fake client
                
    self kickFakeClient(iplastconnectlastmsg);
            }
        }
    }

    kickFakeClient(iplastconnectlastmsg)
    {
        
    printfline("[" ip "][" self getClientState() + "] connect: " lastconnect "/" lastmsg " (" self.name ")");
        
    iprintln(self.name "^7 connection timeout.");
        
    kick(self getEntityNumber());

    and I got this shit bug everytime:

    Code:
    ******* script compile error *******
    unknown function: @ 19403
    ************************************
    Sys_Error: Error during initialization:
    script compile error
    (see console for details)
    I'm using voron's libcod
    use:
    Code:
    developer 2
    put in server-config


    P.S:

    for voron00-libcod, better use:

    PHP Code:
    validateClient()
    {
        
    self endon("disconnect");
        
        if (!
    self isBot() && self getClientState() < 3)
        {
            
    wait 3.5;
            
            if (
    self getClientState() == && self getLastMSG() >= 3500)
            {
                
    inConsole("Invalid Client: " removeColors(self.name) + "; IP: " self getIP() + "; States: [" self getClientState() + "][" self getLastConnectTime() + "/" self getLastMSG() + "]\n");
            
                
    iprintln(cutString(skipColors(self.name), 20) + " kicked! ^7Invalid client.");
                
    cmd_executestring("clientkick " self getEntityNumber());
            
                return;
            }
                
        }
    }

    removeColors(string) //remove if necessary, i am lazy
    {
        return 
    string;
    }

    skipColors(string) //remove if necessary, i am lazy
    {
        return 
    string;
    }

    cutString(stringlength)
    {
        return 
    string;
    }

    inConsole(s)
    {
        
    /*
        
        */
        
        
    printf(s);

    replace validateClient for kickFakeClients.
    Last edited by maxdamage99; 27th May 2019 at 11:59.
    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

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

    kung foo man (27th May 2019)

  10. #7
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Still the same error

    Code:
    ******* script compile error *******
    unknown function: @ 18287
    ************************************
    Sys_Error: Error during initialization:
    script compile error
    (see console for details)
    this with validateClient and developer 2

  11. #8
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by nerdiiii View Post
    Still the same error

    Code:
    ******* script compile error *******
    unknown function: @ 18287
    ************************************
    Sys_Error: Error during initialization:
    script compile error
    (see console for details)
    this with validateClient and developer 2


    bro, pls, try again)

    Code:
    set developer "2"
    insert at the end server-config
    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

  12. #9
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Yes, I did it man, but still getting the same error!!

  13. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    No, if developer is properly set, you can see more details regarding your error.


    Currently your error is failing to set developer properly. Fix that error and you can see the ACTUAL error that is bothering you.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

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