/changename
#1

pawn Код:
if(strcmp(cmd, "/changename", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
                return 1;
            }
            new player[24];
            giveplayerid = ReturnUser(tmp);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string4, sizeof(string4), "/Accounts/%s.ini", player);
            if (PlayerInfo[playerid][pAdmin] >= 1337)
            {
              if(IsPlayerConnected(giveplayerid))
              {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                        /*if(!fexist(string4))
                        {
                            SendClientMessage(playerid, COLOR_YELLOW, "Info: That name is allready registered with the server.");
                            return 1;
                    }*/

                    new length = strlen(cmdtext);
                        while ((idx < length) && (cmdtext[idx] <= ' '))
                        {
                            idx++;
                        }
                        new offset = idx;
                        new result[64];
                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                        {
                            result[idx - offset] = cmdtext[idx];
                            idx++;
                        }
                        result[idx - offset] = EOS;
                        if(!strlen(result))
                        {
                            SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
                            return 1;
                        }
                    GetPlayerName(playerid, player, 50);
                    SetPlayerName(giveplayerid, (result));
                    format(string, sizeof(string), "%s changed %s name to %s",sendername,giveplayer,(result));
                        ChangeNameLog(string);
                        return 1;
                    }
                }
            }
        }
        return 1;
    }
I dont know the code to change the file name.
Reply
#2

why you dont use a frename(oldname[],newname[]) form dutils.inc, like that
pawn Код:
if(!strcmp("/changename", cmd, true)) {
    if (PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GRAD2, "You arent allowed to use this cmd");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
    giveplayerid = ReturnUser(tmp);
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GRAD2, "Invalid Playerid!");
    new str[128],gpname[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid, gpname, MAX_PLAYER_NAME);
    format(str, 128, "/Accounts/%s.ini", gpname);
    if(!fexist(str)) return SendClientMessage(playerid, COLOR_YELLOW, "The person havent an account on this server");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
    new str2[128];
    format(str2,128,"/Accounts/%s.ini",tmp);
    frename(str,str2);
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    SetPlayerName(giveplayerid,tmp);
    format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\"",pname,gpname,tmp);
    ChangeNameLog(string);
    return 1;
}
dunno if that works
Reply
#3

Quote:
Originally Posted by ♣ ⓐⓢⓢ
why you dont use a frename(oldname[],newname[]) form dutils.inc, like that
pawn Код:
if(!strcmp("/changename", cmd, true)) {
    if (PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GRAD2, "You arent allowed to use this cmd");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
    giveplayerid = ReturnUser(tmp);
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GRAD2, "Invalid Playerid!");
    new str[128],gpname[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid, gpname, MAX_PLAYER_NAME);
    format(str, 128, "/Accounts/%s.ini", gpname);
    if(!fexist(str)) return SendClientMessage(playerid, COLOR_YELLOW, "The person havent an account on this server");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
    new str2[128];
    format(str2,128,"/Accounts/%s.ini",tmp);
    frename(str,str2);
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    SetPlayerName(giveplayerid,tmp);
    format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\"",pname,gpname,tmp);
    ChangeNameLog(string);
    return 1;
}
dunno if that works
i get these errors
Код:
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(12015) : error 021: symbol already defined: "strtok"
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(12030) : error 047: array sizes do not match, or destination array is too small
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(13197) : error 017: undefined symbol "ChangeNameLog"
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(16202) : warning 219: local variable "mod" shadows a variable at a preceding level
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(37180) : warning 203: symbol is never used: "GetPointDistanceToPointExMorph"
C:\DOCUME~1\k\MYDOCU~1\Server\SAMP03~1\GAMEMO~1\ERP-Bug.PWN(37180) : warning 203: symbol is never used: "ret_memcpy"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)