Creating /name command

Results 1 to 3 of 3
  1. #1
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Creating /name command

    Code:
     else if (strcmp(command, "name")==0)
    if(Config.Command_Ban > thisclient->Session->accesslevel) //*Works on acceslevel of Go so no need to edit headers.
               return true;
            
                     char newcharname[65];
                     strcpy (newcharname,"[GM]");  
                     strcat (newcharname, thisclient->CharInfo->charname);
                      GServer->DB->QExecute(" UPDATE characters SET char_name = '%s' WHERE id = '%i' ",newcharname, thisclient->CharInfo->charid);

    THat's what I've got so far, now the only thing I need to know is how to set the name to what you've typed, for example /name newb.


    So I need to change [NAME] in
    Code:
    strcpy (newcharname,"[GM]");
    I think this might be an usefull command for GMs.



    Thanks in advance.


  2. #2
    Account Upgraded | Title Enabled! perrin9028 is offline
    MemberRank
    Nov 2007 Join Date
    806Posts

    Re: Creating /name command

    Take a gander at the ban command.
    Code:
    if ((tmp = strtok(NULL, " "))==NULL) return true; char* name=tmp;
    The strtok(NULL, " ") defines anything after a space is data, temporary data at that, but data. After that, the temporary data is assigned to the char value name.
    So, in your case, it would be something like
    Code:
    if ((tmp = strtok(NULL, " "))==NULL) return true;
    char* newcharname=tmp;
    strcpy (newcharname,"[GM]");
    strat (newcharname, thisclient->CharInfo->charname);
    
    etc.

  3. #3
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Creating /name command

    Code:
    else if (strcmp(command, "name")==0)
    {
    if(Config.Command_Ban > thisclient->Session->accesslevel) //*Works on acceslevel of ban so you don't have to change headers
               return true;
    if ((tmp = strtok(NULL, " "))==NULL)
     return true;
    
    char* newcharname=tmp;
    strcpy (newcharname=tmp);
    strat (newcharname, thisclient->CharInfo->charname);
    GServer->DB->QExecute(" UPDATE characters SET char_name = tmp WHERE id = '%i' ",newcharname, thisclient->CharInfo->charid); 
    }
    This is the result, is there something wrong with the brackets or else?

    It says so when rebuilding.



Advertisement