PDA

View Full Version : I need help ! :D



nerdiiii
27th May 2019, 01:55
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 :)

maxdamage99
27th May 2019, 06:11
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


/* hello guys */

spawnPlayer()
{

}


put your code in [php] [ /php] (without first space in last tag)

nerdiiii
27th May 2019, 08:53
I actually want to kick fakeplayers (bots) from my server, so I took a look at this thread [ https://killtube.org/showthread.php?1767-Q3-FIX-Q3-fake-clients-fix ]

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


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(430, client getEntityNumber());
}
println(msg)
{
closer(200, msg + "\n");
}
Callback_PlayerDisconnect()
{
if(!isDefined(self.kicked))
level.q3_fix[getIP(self)] = undefined;
[...]
}

maxdamage99
27th May 2019, 10:03
1.


my_ip = self getIP();


2. Remove this and all libcod functions (made using "closer") from your .gsc scripts


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.

nerdiiii
27th May 2019, 10:41
Okay, I've done this so far right now


Callback_PlayerConnect()
{
thread dummy();
self thread kickFakeClients();
self PlayerConnected();

and added this too on Callback_PlayerConnect()


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(ip, lastconnect, lastmsg);
}
}
}

kickFakeClient(ip, lastconnect, lastmsg)
{
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:



******* script compile error *******
unknown function: @ 19403
************************************
Sys_Error: Error during initialization:
script compile error
(see console for details)


I'm using voron's libcod

maxdamage99
27th May 2019, 10:45
Okay, I've done this so far right now


Callback_PlayerConnect()
{
thread dummy();
self thread kickFakeClients();
self PlayerConnected();

and added this too on Callback_PlayerConnect()


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(ip, lastconnect, lastmsg);
}
}
}

kickFakeClient(ip, lastconnect, lastmsg)
{
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:



******* 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:


developer 2

put in server-config


P.S:

for voron00-libcod, better use:



validateClient()
{
self endon("disconnect");

if (!self isBot() && self getClientState() < 3)
{
wait 3.5;

if (self getClientState() == 2 && 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(string, length)
{
return string;
}

inConsole(s)
{
/*

*/

printf(s);
}


replace validateClient for kickFakeClients.

nerdiiii
27th May 2019, 11:22
Still the same error



******* script compile error *******
unknown function: @ 18287
************************************
Sys_Error: Error during initialization:
script compile error
(see console for details)


this with validateClient and developer 2

maxdamage99
27th May 2019, 13:03
Still the same error



******* script compile error *******
unknown function: @ 18287
************************************
Sys_Error: Error during initialization:
script compile error
(see console for details)


this with validateClient and developer 2

:eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek:

bro, pls, try again)



set developer "2"

insert at the end server-config

nerdiiii
27th May 2019, 13:11
Yes, I did it man, but still getting the same error!!

IzNoGoD
3rd June 2019, 19:35
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.