SA-MP Forums Archive
[Help] Saving + Loading Admin Names - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Saving + Loading Admin Names (/showthread.php?tid=476326)



[Help] Saving + Loading Admin Names - BornHuman - 17.11.2013

Recently I made this command:

Код:
CMD:setadminname(playerid, params[])
{
    new file[128], pname[MAX_PLAYER_NAME];
    new id, reason[128];
    new name[MAX_PLAYER_NAME+1];
    
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "USERFILES/%s.ini", pname);
    
    if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_GREY, "USAGE: /setadminname [playerid] [name]");
    else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_NEWBIE,"Player is not connected!");
    else
	{
        new Name[MAX_PLAYER_NAME], KickMessage[128];
        GetPlayerName(playerid, Name, sizeof(Name));
        format(KickMessage, sizeof(KickMessage), "AdmCmd: %s has changed your admin name to %s", Name, reason);
        SendClientMessage(playerid, COLOR_LIGHTRED, KickMessage);
        SetPlayerName(playerid, reason);
        dini_IntSet(file, "AdminName", GetPlayerName(playerid, name, sizeof(name)));
        }
	return 1;
}
Along with this one to go on admin duty:

Код:
CMD:adminduty(playerid, params[])
{
    new file[128], pname[MAX_PLAYER_NAME];
    new adminname;
    
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "USERFILES/%s.ini", pname);

    if(dini_Exists(file))
    {
    adminname = dini_Int(file, "AdminName");
    SetPlayerName(playerid, adminname);
    }
    return 1;
}
But I get these errors:

Код:
C:\Users\TWLeg_000\Desktop\SAMP SERVER\gamemodes\BHRP1.pwn(1098) : error 035: argument type mismatch (argument 2)
C:\Users\TWLeg_000\Desktop\SAMP SERVER\gamemodes\BHRP1.pwn(1097) : warning 204: symbol is assigned a value that is never used: "adminname"
1098 =
Код:
SetPlayerName(playerid, adminname);
1097 =
Код:
adminname = dini_Int(file, "AdminName");
Could someone explain to me how I can fix these errors?


Re: [Help] Saving + Loading Admin Names - HardRock - 17.11.2013

new adminname[MAX_PLAYER_NAME];


Re: [Help] Saving + Loading Admin Names - BornHuman - 17.11.2013

Quote:
Originally Posted by HardRock
Посмотреть сообщение
new adminname[MAX_PLAYER_NAME];
I got this error:
Код:
C:\Users\TWLeg_000\Desktop\SAMP SERVER\gamemodes\BHRP1.pwn(1064) : error 033: array must be indexed (variable "adminname")



Re: [Help] Saving + Loading Admin Names - HardRock - 17.11.2013

adminname = dini_Int(file, "AdminName");

to

format(adminname, MAX_PLAYER_NAME, "%s", dini_Int(file, "AdminName"));


Re: [Help] Saving + Loading Admin Names - BornHuman - 17.11.2013

Quote:
Originally Posted by HardRock
Посмотреть сообщение
adminname = dini_Int(file, "AdminName");

to

format(adminname, MAX_PLAYER_NAME, "%s", dini_Int(file, "AdminName"));
It allows me to compile it, but the line in the player file looks like:

Код:
AdminName=5
When it should look like

Код:
AdminName=Keogh
( My admin name )

And /adminduty doesn't work... doesn't set my name