View Full Version : CoD4: !commands
Mitch
27th October 2014, 22:24
I just got player commands working for CoD4.
Console:
pushing: say
pushing: abc def
PLAYER COMMAND! message: say, abc def,
isPlayer self
Player: Mitch
(i didn't use the fixChatArgs function)
https://github.com/M-itch/libcod/commit/5dbd6e5804e15278df9ace4c2e57e04082e3f162
IzNoGoD
28th October 2014, 00:56
To make it fully compatible with code written for cod2 libcod, it should return the args as a bigger array, for example:
say hello world
would result in
args[0] = "say";
args[1] = "hello";
args[2] = "world";
But then again, this can be done manually if needed. Great work :)
Mitch
28th October 2014, 11:53
To make it fully compatible with code written for cod2 libcod, it should return the args as a bigger array, for example:
I turns out that fixChatArgs fixes this issue.
CodeCallback_PlayerCommand(args)
{
args = fixChatArgs(args);
output = "";
for (i=0; i<args.size; i++)
output += args[i] + ", ";
printf("PLAYER COMMAND! message: " + output + "\n");
if(isPlayer(self))
{
printf("isPlayer self\n");
printf("Player: " + self.name + "\n");
}
else
printf("!isPlayer self\n");
self iprintlnbold("you wrote: " + output);
self ClientCommand();
}
CoD4 1.7: http://znation.nl/libcod/libcod4_1_7.so
CoD4 1.7 (query-limit-test (http://killtube.org/showthread.php?1719-Latest-cod2-linux-binaries-(1-0-1-2-1-3)&p=10615#post10615)): http://znation.nl/libcod/libcod4_1_7_l.so
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.