Jump to content

Home

/register


Astelraid

Recommended Posts

for that, you would need a LOT of code...

 

and judging by the way you asked, I don't think you really understand how to program that well, so much of it wont make sense.

 

anyway, here is some code from my mod, if you need help with it contact me at the forums I share: bwap.pipobona.com, If you register, you get access to the c++ help area, where ive allready posted some code (a lugormod-like /place command, and a /playerscale command so far, I post more as its requested)

 

 

to save a nick file you will need somthing like

 

qboolean SaveNickFile(char FileName[MAX_STRING_CHARS], char FileSaveData[MAX_STRING_CHARS]){

char TempFileName[MAX_STRING_CHARS];

if(strlen(FileSaveData) <= 0) return qfalse;

if(!FileName || !FileName[0]) return qfalse;

strcpy(TempFileName, "nicks\\");

strcat(TempFileName, FileName);

TheFile = fopen(TempFileName, "w");

if(!TheFile) return qfalse;

fwrite(FileSaveData, sizeof( char ), strlen(FileSaveData) , TheFile);

fclose( TheFile );

strcpy(FileSaveData, "");

NextNickSave = level.time + NICKNAME_SAVE_RATE;

return qtrue;

}

 

for the profession system, you will need a way of keeping track of the player login

 

struct PlayerStruc_s{

char Name[MAX_NAME_CHARS];

char Pass[MAX_NAME_CHARS];

};

 

you will also need to add:

PlayerStruc_s Nickname;

to the typedef

gclient_t

 

for actualy formatting the names to save them, we could use somthing like:

{

Player Name

Pass

}

 

so to format it (im making this code as i think of it, so it most likely will have a few bugs, the code I use for formatting the nickname saves is too complex for an example):

qboolean SaveNicks( void ){
     int i = 0;
     gclient_t *Client
    char SaveData[MAX_STRING_CHARS]; //this WILL be too small for a large database, if you use this code than change it
     for(i = 0;i<MAX_CLIENTS;i++){
           Client = level.clients[i];
           if(Client->Nickname){
                  strcat(SaveData, va({\n%s\n%s\n}\n", Client->Nickname->Name, Client->Nickname->Pass));

           }
     }
     return SaveNickFile("nicknames.txt", SaveData); 
}

 

urg, typing that in a forum window was almost as bad as that compiler they have at school...

 

anyway, that is probably the bare minimum you could get away with for making a nickname saving system... I highly sugust that you learn c++ first, you should be able to make somthing like that no problem once you learn the basics

Link to comment
Share on other sites

if you dont crypt the password ppl wont care to write down the password. they just ask you to look what it was and tell to them.

 

also lugormod 1.2 has crypted passwords. since u got the source you could check how he did it :)

Link to comment
Share on other sites

  • 4 months later...

I have a problem while using it...

 

void Cmd_SaveNicks_f ( gentity_t *ent ) {

int i;

gclient_t *Client;

for(i = 0;i<MAX_CLIENTS;i++){

Client = level.clients;

if(Client->Name.Name){

WritePlayerStats(Client->Name.Name,2,2,1,5);

}

}

}

 

I have an error at the line Client = level.clients;

Unable to convert from 'gclient_s' to 'gclient_t'...

 

Can anyone help me please ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...