/changename +REP
#1

I'm Using SATDM_v9 Gamemode...
SATDM_v9 is using Dini Include

how to create Commands changename with Dini



I'll give you some +REP if you can help me !!
*Note:Sorry For My Little English*
Reply
#2

This May Work :P

For Players...
pawn Код:
CMD:changename(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changename [new name]");
    if(strlen(length) < 3 || strlen(length) > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
    new string[128];
    SetPlayerHealth(playerid, 100);
    SetPlayerName(playerid, params);
    ForceClassSelection(playerid);
    OnPlayerConnect(playerid);
    format(string, sizeof(string),"ACCOUNT: You have successfully changed your name to \"%s\"",params);
    SendClientMessage(playerid,yellow,string);
    return 1;
}

For Admins
pawn Код:
CMD:setname(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
        new player1 = strval(tmp), length = strlen(tmp2), string[128];
        if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            CMDMessageToAdmins(playerid,"SETNAME");
            format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(player1), tmp2); SendClientMessage(playerid,blue,string);
            if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" ", pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
            SetPlayerHealth(player1, 100);
            SetPlayerName(player1, tmp2);
            return OnPlayerConnect(player1);
        } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#3

pawn Код:
CMD:changename(playerid, params[])
{
    new id, newname[MAX_PLAYER_NAME];
    if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, -1, "USAGE: /changename [playerid] [new name]");

    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not admin!"); //Change it to your admin enum or whatever
    if(IsPlayerConnected(id))
    {
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(id, pname, MAX_PLAYER_NAME);
        if(strcmp(pname, newname))
        {
            SetPlayerName(id, newname);

            new string[64];
            format(string, sizeof(string), "users/%s.ini", pname); // Your user data folder
            fremove(string);
            //Then re-save the player
        }
        else return SendClientMessage(playerid, -1, "Oldname & Newname cannot same!");
    }
    else return SendClientMessage(playerid, -1, "Player not connected!");
        return 1;
}
Reply
#4

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
pawn Код:
CMD:changename(playerid, params[])
{
    new id, newname[MAX_PLAYER_NAME];
    if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, -1, "USAGE: /changename [playerid] [new name]");

    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not admin!"); //Change it to your admin enum or whatever
    if(IsPlayerConnected(id))
    {
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(id, pname, MAX_PLAYER_NAME);
        if(strcmp(pname, newname))
        {
            SetPlayerName(id, newname);

            new string[64];
            format(string, sizeof(string), "users/%s.ini", pname); // Your user data folder
            fremove(string);
            //Then re-save the player
        }
        else return SendClientMessage(playerid, -1, "Oldname & Newname cannot same!");
    }
    else return SendClientMessage(playerid, -1, "Player not connected!");
        return 1;
}
Why the changename isn't saving ??when i logout , and login back with the new name why i must register ?? I'm Checking in the Scriptfiles/User/%s.sav the name isn't change to the new name.
Reply
#5

is it just me or is my posts invisible
Reply
#6

Quote:
Originally Posted by forgottenkings
Посмотреть сообщение
This May Work :P

For Players...
pawn Код:
CMD:changename(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changename [new name]");
    if(strlen(length) < 3 || strlen(length) > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
    new string[128];
    SetPlayerHealth(playerid, 100);
    SetPlayerName(playerid, params);
    ForceClassSelection(playerid);
    OnPlayerConnect(playerid);
    format(string, sizeof(string),"ACCOUNT: You have successfully changed your name to \"%s\"",params);
    SendClientMessage(playerid,yellow,string);
    return 1;
}

For Admins
pawn Код:
CMD:setname(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
        new player1 = strval(tmp), length = strlen(tmp2), string[128];
        if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            CMDMessageToAdmins(playerid,"SETNAME");
            format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(player1), tmp2); SendClientMessage(playerid,blue,string);
            if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" ", pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
            SetPlayerHealth(player1, 100);
            SetPlayerName(player1, tmp2);
            return OnPlayerConnect(player1);
        } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
it isn't saved when login back.
i want the /changename is saved when login back

if Somebody can help me ??
Reply
#7

(NOTE: you english sucks :P)


and after you get the new name you are redirected to OnPlayerConnect where you can register and login and then your account will get saved.. :P
Reply
#8

Quote:
Originally Posted by forgottenkings
Посмотреть сообщение
(NOTE: you english sucks :P)


and after you get the new name you are redirected to OnPlayerConnect where you can register and login and then your account will get saved.. :P
hahaha...sorry for my little english
Reply
#9

What do you use? Y_INI, SQLite..?
Reply
#10

well SATDM uses dudb,dini :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)