/setadmin
#1

Help, I are wanting to create basic /setadmin command, I make it but it not working correctly.
pawn Код:
if(!strcmp(cmdtext, "/setadmin")){
        new name[MAX_PLAYER_NAME], player, level, file[256];
        GetPlayerName(player, name, sizeof(name));
        sscanf(params, "dd", player);
        format(file, sizeof(file), SERVER_USER_FILE, name);
        PlayerInfo[playerid][pAdminLevel] = level;
        return 1;
    }
I am not very good at sscanf or .dini so please tell me what to do to change value inside file.
Sorry for English, it's not too well.
Reply
#2

I've created it with ZCMD you have to put this INC's: Zcmd, sscanf
pawn Код:
COMMAND:setadmin(playerid, params[])
{
    new name[MAX_PLAYER_NAME], ID, level, file[256];
    if(sscanf(params, "ud", ID, level)) SendClientMessage(playerid, 0x21DD00FF, "USAGE: /setlevel [id] [level]");
    else if(ID == INVALID_PLAYER_ID) SendClientMessage(playerid, 0x21DD00FF, "Player is not connected!");
    else
    {
    GetPlayerName(ID, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    PlayerInfo[ID][pAdminLevel] = level;
    SendClientMessage(ID, 0x21DD00FF, "The RCON Admin promoted you to an admin!");
    }
    return 1;
}
Reply
#3

Can you make that without ZCMD please? Sorry, I don't want use Zcmd if possible, too much confusion in script if I use different command types.
Reply
#4

I see a problem with
pawn Код:
format(file, sizeof(file), SERVER_USER_FILE, name);
It should be used like these examples:
pawn Код:
format(string, sizof(string), "%s", name);
format(string, sizof(string), name);
Go check this page for more info:
https://sampwiki.blast.hk/wiki/Format
Reply
#5

Nevermind, dis are working.
Ty for the support!

Will this same setup be working for other commands when I are changing value in file?
Reply
#6

Quote:
Originally Posted by Clive
Посмотреть сообщение
I've created it with ZCMD you have to put this INC's: Zcmd, sscanf
pawn Код:
COMMAND:setadmin(playerid, params[])
{
    new name[MAX_PLAYER_NAME], ID, level, file[256];
    if(sscanf(params, "ud", ID, level)) SendClientMessage(playerid, 0x21DD00FF, "USAGE: /setlevel [id] [level]");
    else if(ID == INVALID_PLAYER_ID) SendClientMessage(playerid, 0x21DD00FF, "Player is not connected!");
    else
    {
    GetPlayerName(ID, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    PlayerInfo[ID][pAdminLevel] = level;
    SendClientMessage(ID, 0x21DD00FF, "The RCON Admin promoted you to an admin!");
    }
    return 1;
}
I thought this line:
pawn Код:
else if(ID == INVALID_PLAYER_ID) SendClientMessage(playerid, 0x21DD00FF, "Player is not connected!");
Means that you can't choose yourself?
Reply
#7

Quote:
Originally Posted by bartje01
Посмотреть сообщение
I thought this line:
pawn Код:
else if(ID == INVALID_PLAYER_ID) SendClientMessage(playerid, 0x21DD00FF, "Player is not connected!");
Means that you can't choose yourself?
You can change it if you are a good scripter.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)