daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest May 31st, 2017 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void statsTrackRegister(gentity_t *ent, char password, char username[128])
  2. {
  3.     int len = 0;
  4.     fileHandle_t    f;
  5.     //char *buf = (char *)&ent->client->pers.save;
  6.  
  7.     if(ent->client->pers.loggedIn){
  8.         trap_SendServerCommand(ent->s.number, "print\"No need to register. You're already logged in.\n\"");
  9.         return;
  10.     }
  11.     SHA256_Data(&password, strlen(&password), ent->client->pers.save.password);
  12.     strcpy(ent->client->pers.save.username, username);
  13.     trap_SendServerCommand(ent->s.number, "print\"Registering account please wait.\n\"");
  14.     len = trap_FS_FOpenFile(va("servdcc/%s.dcc", username), &f, FS_READ);
  15.     if(!f){ //no file, let's write a new one.
  16.         trap_FS_FCloseFile(f);
  17.         trap_FS_FOpenFile(va("servdcc/%s.dcc", username), &f, FS_WRITE);
  18.         trap_FS_Write(&ent->client->pers.save, sizeof(ent->client->pers.save), f);
  19.         trap_FS_FCloseFile(f);
  20.         ent->client->pers.loggedIn = qtrue;
  21.         trap_SendServerCommand(ent->s.number, va("print\"You are now registered and logged in. Username: %s\nPassword: %s\n\"", username, password));
  22.         G_Printf("Account register: %i", ent->s.number);
  23.     }
  24.     else{ //check the password -- how?
  25.         trap_SendServerCommand(ent->s.number, "print\"An account by that name already exists.\n\"");
  26.         trap_FS_FCloseFile(f);
  27.         return;
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top