Admin Duty
#1

Alright so I got this script but half of the commands wont work so I am trying to fix it because It is a really good script. So this command in particular is pissing me right off. /setadminname. this is when you go on /aduty it sets your name to that.... But the /setadminname isnt working so we cant go on /aduty and half the admin commands you need to be on duty to use...so can anyone help?

pawn Код:
CMD:setadminname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        /*if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
        {
            SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
            return 1;
        }*/


        new giveplayerid, name[32];
        if(sscanf(params, "us[32]", giveplayerid, name))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadminname [playerid/partofname] [name]");
            return 1;
        }

        if(PlayerInfo[giveplayerid][pAdmin] < 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "The player is not an admin.");
            return 1;
        }

        if(AdminDuty[giveplayerid] != 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, "That admin is currently on-duty. They must go off-duty in order for you to set their admin name.");
            return 1;
        }

        new length = strlen(name);
        if(length < 3 || length > 20)
        {
            SendClientMessage(playerid, COLOR_WHITE, "The name can't less than 3 characters or more than 20 characters.");
            return 1;
        }

        if(strfind(name, "_", true) != -1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "The admin name must be one name. There can't be an underscore in the name.");
            return 1;
        }

        new string[128];
        format(string, sizeof(string), "AdmCmd: %s has set %s's admin name to '%s'.", GetPlayerNameEx(playerid),  GetPlayerNameEx(giveplayerid), name);
        ABroadCast(COLOR_LIGHTRED, string, 1);

        format(PlayerInfo[giveplayerid][pAdminName], 32, name);
    }
    else SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
    return 1;
}
EDIT: Never Mind I changed the /setadminname to a new command but now I am getting error :/

Quote:

warning 217: loose indentation
warning 217: loose indentation
error 012: invalid function call, not a valid address
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

This is the CMD line

pawn Код:
CMD:aname(playerid, params[])
{
    new string[128], file[32], text[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aname [name]");
    if(AdminDuty(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
    // Start of detecting space in name
    new end, temp[32], temp2[32];
    end = strfind(text, " ",true);
    if(end != -1)
    {
        strmid(temp, text, 0, end);
        format(temp, sizeof(temp), "%s_", temp);
        strdel(text, 0, end);
        strmid(temp2, text, 1, strlen(text));
        format(text, 24, "");
        strcat(text, temp, sizeof(temp));
        strcat(text, temp2, sizeof(temp2));
    }
    // End of detecting space in name
    format(file, sizeof(file), "users/%s.ini", text);
    if(dini_Exists(file))
    {
        format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        if(strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
        {
            SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
            return 1;
        }
    }
    format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string, sizeof(string), "%s has changed their admin name to %s.", RPN(playerid), text);
    Log("logs/aname.log", string);
    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
    format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
    if(dini_Exists(file)) dini_Remove(file);
    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
    dini_Set(file, "AdminName", text);
    format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
    dini_Create(file);
    dini_Set(file, "OldName", RPNU(playerid));
    dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
    dini_IntSet(file, "AdminAccount", 1);
    dini_IntSet(file, "Age", 25);
    dini_IntSet(file, "Gender", 1);
    dini_IntSet(file, "Tutorial", 1);
    dini_Set(file, "IP", PlayerInfo[playerid][pIP]);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)