For changing bot names;
PHP Code:
void PlayerCmd_renamebot(int a1) {
char* key = Script_GetString(0);
char userinfo[MAX_STRING_CHARS];
getuserinfo(a1, userinfo, sizeof(userinfo));
/*char* value = Info_ValueForKey(userinfo, key);
if(value == NULL)
Script_AddString("");
else
Script_AddString(value);*/
Info_SetValueForKey(userinfo, "name", key);
setuserinfo(a1, userinfo);
client_t* cl = getclient(a1);
if(cl) {
memcpy(&cl->name[0], key, 32);
cl->name[31] = '\0';
}
printf("name = %s\n", cl->name);
}
I didn't check if it only works with cl->name or userinfo so I set both and I really don't care to find out.
As for name changing instantly, just call *_UserinfoChanged (harder way for non-libcod people)
For convience I held on to the q3/wolf SDK name conventions so you can look it up yourself what it does and all.
Easier way is just to use the builtin script function
UpdateClientNames()
Module: Level
MP Only
Summary:
Update all of the client names: only works in 'manual_change' mode
Usage:
PHP Code:
newname = "harry you're a wizard";
players=getentarray("player","classname");
for(i=0;i<players.size;i++){
if(players[i] isbot()) {
players[i] renamebot(newname);
}
updateclientnames(); //calling it for every bot name change in a loop is not recommended except when you're only changing one bot name
//since it's a loop let's call it at the end
//it will notify in a iprintln with "bot<number> changed name to <newname>"
//so find the UserinfoChanged or set the start of that string (hex edit) to \0
}
PHP Code:
void PlayerCmd_isbot(int a1) {
client_t* cl = getclient(a1);
if(cl) {
if(cl->remoteAddress.type == NA_BOT)
Script_AddBool(true);
else
Script_AddBool(false);
} else {
Script_AddBool(false);
}
}
As for the CoDExtended functions if you'd like to convert them to libcod, just look up the Q3/WOLF SDK
a1 = entityNumber
getclient = function gets client_t pointer for number