Hello i am working on this code and i wanted to see if you would help.
Top part works in the example code i did /tell 0 and it did link to the other player but the second part doesn't. Where it finds the number by the player name.
Код
ClientNumberFromString( gentity_t *to, char *s ) { gclient_t *cl; int idnum; char cleanName[MAX_STRING_CHARS]; char info[MAX_STRING_CHARS]; //this part works -> // numeric values are just slot numbers if (s[0] >= '0' && s[0] <= '9') { idnum = atoi( s ); if ( idnum < 0 || idnum >= JASS_GETINTCVAR("sv_maxclients") ) { g_syscall(G_SEND_SERVER_COMMAND, NUM_FROM_ENT(to),JASS_VARARGS("print \"Bad client slot: %i\n\"", idnum)); return -1; }// <- cl = CLIENT_FROM_NUM(idnum); if ( cl->pers.connected != CON_CONNECTED ) { g_syscall(G_SEND_SERVER_COMMAND, NUM_FROM_ENT(to), JASS_VARARGS("print \"Client %i is not active\n\"", idnum)); return -1; } return idnum; } // check for a name match //this part don't work -> int clients = atoi(Info_ValueForKey(info, "clients")); int maxclients = JASS_GETINTCVAR("sv_maxclients"); for ( idnum = 0,idnum < maxclients; idnum++; ) { cl = CLIENT_FROM_NUM(clients); if ( cl->pers.connected != CON_CONNECTED ) { continue; } strncpy(cleanName, cl->pers.netname, sizeof(cleanName)); Q_CleanStr(cleanName); if ( !stricmp( cleanName, s ) ) { return idnum; } }// <- g_syscall(G_SEND_SERVER_COMMAND, NUM_FROM_ENT(to), JASS_VARARGS("print \"User %s is not on the server\n\"", s)); return -1;}
http://pastebin.com/VHhphv3f
Q_Cleanstr
Код
char *Q_CleanStr( char *string ) { char* d; char* s; int c;
s = string; d = string; while ((c = *s) != 0 ) { if ( Q_IsColorString( s ) ) { s++; } else if ( c >= 0x20 && c <= 0x7E ) { *d++ = c; } s++; } *d = '\0';
return string;}
http://pastebin.com/LdHu7RqV
example code
Код
if (cmd == GAME_CLIENT_COMMAND){ int argc = g_syscall(G_ARGC); char command[16]; gentity_t *ent = ENT_FROM_NUM(arg0); g_syscall(G_ARGV, 0, command, sizeof(command)); if (argc>1&&!strcasecmp(command,"tell")){ g_syscall(G_ARGV, 1, command, sizeof(command)); if (!strcasecmp(command,command)){ int targetNum; gentity_t *target; char *p; char arg[MAX_TOKEN_CHARS];
if (ClientNumberFromString(ent, command) == -1) JASS_RET_SUPERCEDE(1); target = ENT_FROM_NUM(ClientNumberFromString(ent, command));
g_syscall(G_SEND_SERVER_COMMAND,-1,JASS_VARARGS("chat \"%s linked to %s^7!\"",ent->client->pers.netname,target->client->per s .netname));
JASS_RET_SUPERCEDE(1); } } }
http://pastebin.com/CgvN45E4
if the code looks broken up please use the pastebin links
thank you so much