Monday, 24.07.2017, 07:42
Приветствую Вас Гость
Register | Login | RSS
Jedi Academy Server Security
[ New messages · Users · Forum rules · Search · RSS ]
Page 1 of 11
Forum » JASS » English forum » Clientnamefromstirng
Clientnamefromstirng
ThedtDate: Saturday, 19.01.2013, 10:43 | Message # 1
Group: User
Messages: 6
Reputation: 0
Status: Offline
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 smile


Message edited by Thedt - Saturday, 19.01.2013, 10:45
 
BufferOverflowDate: Saturday, 19.01.2013, 14:22 | Message # 2
Group: Developer
Messages: 47
Reputation: 0
Status: Offline
I couldn't say something just by looking at code. Hadn't you tried to debug it?
 
ThedtDate: Tuesday, 22.01.2013, 00:20 | Message # 3
Group: User
Messages: 6
Reputation: 0
Status: Offline
fixed


Код
int ClientNumberFromString( gentity_t *to, char *s ) {   gclient_t       *cl;   int                     idnum;   char        s2[MAX_STRING_CHARS];   char      n2[MAX_STRING_CHARS];   int maxclients = JASS_GETINTCVAR("sv_maxclients");   //int         clients;   //serverState_t server;   // numeric values are just slot numbers   if (s[0] >= '0' && s[0] <= '9') {      idnum = atoi( s );      if ( idnum < 0 || idnum >= maxclients ) {         g_syscall(G_SEND_SERVER_COMMAND, NUM_FROM_ENT(to),JASS_VARARGS("print \"Bad client slot: %i\n\"", idnum));         return -1;      }      //clients = atoi(Info_ValueForKey(info, "clients"));      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   SanitizeString( s, s2 );   for ( idnum = 0;idnum < maxclients; idnum++) {      cl = CLIENT_FROM_NUM(idnum);      if ( cl->pers.connected != CON_CONNECTED ) {         continue;      }      SanitizeString( cl->pers.netname, n2 );      if ( !strcmp( n2, s2 ) ) {         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/VcKDB0Bc

it was in the loop the ; and ,


Message edited by Thedt - Tuesday, 22.01.2013, 00:20
 
Forum » JASS » English forum » Clientnamefromstirng
Page 1 of 11
Search: