How to Add Custom Commands - GuckTubeYT/GTProxy GitHub Wiki
In this page will tell you how to add custom commands
- to make custom commands, you must goto events/eventClient.c file
- after you goto events/eventClient.c file, add
else ifat the end ofelse ifblocks
if (isStr(command[0], "/proxyhelp")) {
sendPacket(3, "action|log\nmsg|>> Commands: /helloworld", clientPeer);
}
else if (isStr(command[0], "/helloworld")) {
sendPacket(3, "action|log\nmsg|`2Hello World", clientPeer);
}
else if (isStr(command[0], "/testarg")) {
if (!command[1]) {
sendPacket(3, "action|log\nmsg|Please input argument", clientPeer);
free(command); // prevent memleak
break;
}
sendPacket(3, CatchMessage("action|log\nmsg|%s", command[1]), clientPeer);
}
// add else if here
else enet_peerSend(event.packet, serverPeer);
- to make your own custom commands, make code like this
- If you want to make custom commands without arguments
else if (isStr(command[0], "/yourcommand")) {
// your code here
}
- If you want to make custom commands with arguments
else if (isStr(command[0], "/yourcommandwithargs")) {
if (!command[1]) {
sendPacket(3, "action|log\nmsg|your warning message here", clientPeer);
free(command); // prevent memleak
break;
}
// your code here
}
and then, the result code is like this
if (isStr(command[0], "/proxyhelp")) {
sendPacket(3, "action|log\nmsg|>> Commands: /helloworld", clientPeer);
}
else if (isStr(command[0], "/helloworld")) {
sendPacket(3, "action|log\nmsg|`2Hello World", clientPeer);
}
else if (isStr(command[0], "/testarg")) {
if (!command[1]) {
sendPacket(3, "action|log\nmsg|Please input argument", clientPeer);
free(command); // prevent memleak
break;
}
sendPacket(3, CatchMessage("action|log\nmsg|%s", command[1]), clientPeer);
}
else if (isStr(command[0], "/yourcommand")) {
// your code here
}
else if (isStr(command[0], "/yourcommandwithargs")) {
if (!command[1]) {
sendPacket(3, "action|log\nmsg|your warning message here", clientPeer);
free(command); // prevent memleak
break;
}
// your code here
}
else enet_peerSend(event.packet, serverPeer);