Dini error
#1

I am trying to get a giveadmin command to work exept it comes up with this error

Код:
D:\Downloads\Copy of samp03aasvr_R3_win32\gamemodes\UGFREEDM.pwn(762) : error 035: argument type mismatch (argument 3)
the command is

pawn Код:
dcmd_giveadmin(playerid, cmdtext[])
{
    new idx;
    new tmp[256];
        new string[256];
    tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /giveadmin [playerid/PartOfName] [level(1-4)]");
            return 1;
        }
        new sendername[MAX_PLAYER_NAME];
        new giveplayer[MAX_PLAYER_NAME];
        new para1;
        new admlvl;
        if(IsStringAName(tmp))
        {
            para1 = GetPlayerID(tmp);
        }
        else
        {
            para1 = strval(tmp);
        }
        tmp = strtok(cmdtext, idx);
        admlvl = strval(tmp);
        if(level[playerid] >= 4)
        {
          new file[256];
            GetPlayerName(para1, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            dini_Set(file, "level", admlvl);
            printf("AdmCmd: %s has promoted %s to a level %d admin.", sendername, giveplayer, admlvl);
            format(string, sizeof(string), "  You have been promoted to a level %d admin by %s", admlvl, sendername);
            SendClientMessage(para1, COLOR_RED, string);
            format(string, sizeof(string), "  You have promoted %s to a level %d admin.", giveplayer,admlvl);
            SendClientMessage(playerid, COLOR_RED, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "  you are not authorized to use that command!");
        }
return 1;
}
and if i set
Код:
dini_Set(file, "level", admlvl);
to
Код:
dini_IntSet(file, "level", admlvl);
It compile but does not set the level when i change it
Reply
#2

Yes, you have to use dini_IntSet since it's an integer what you are trying to set.
And it isn't setting anything because you aren't providing a file name:

Код:
new file[256];
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
dini_Set(file, "level", admlvl);
the string/array variable named 'file' should be containing the file name, but it's empty.
Reply
#3

how do i link 'file' to the file??
Reply
#4

Just write there the name of the file you want to save to.
Reply
#5

ye but how do i get it to save the name of the file of the user
Reply
#6

pawn Код:
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "%s", name);
dini_Create(%s);
Put that when the player registeres.
Reply
#7

i already got summin that saves the file when they register

i ment how do i link it to it?
Reply
#8

Quote:
Originally Posted by teddyman
i already got summin that saves the file when they register

i ment how do i link it to it?
Can you explain what you are trying to do exactly? I'm not following you.
Reply
#9

I am trying to make it so that when i /giveadmin a account it saves it in there user file, but i cant seem to link the command to the user file

i tried putting in

pawn Код:
new file[256];
          new pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(file, sizeof(string), "\\Users\\%s.ini", pname);
            dini_IntSet(file, "level", admlvl);
like in the register and login but thats not working, it doesnt change the admin level of the player when i do it

full command i got so far is

pawn Код:
dcmd_giveadmin(playerid, cmdtext[])
{
    new idx;
    new tmp[256];
        new string[256];
    tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /giveadmin [playerid/PartOfName] [level(1-4)]");
            return 1;
        }
        new sendername[MAX_PLAYER_NAME];
        new giveplayer[MAX_PLAYER_NAME];
        new para1;
        new admlvl;
        if(IsStringAName(tmp))
        {
            para1 = GetPlayerID(tmp);
        }
        else
        {
            para1 = strval(tmp);
        }
        tmp = strtok(cmdtext, idx);
        admlvl = strval(tmp);
        if(level[playerid] >= 4)
        {
          new file[256];
          new pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(file, sizeof(string), "\\Users\\%s.ini", pname);
            dini_IntSet(file, "level", admlvl);
            GetPlayerName(para1, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            printf("AdmCmd: %s has promoted %s to a level %d admin.", sendername, giveplayer, admlvl);
            format(string, sizeof(string), "  You have been promoted to a level %d admin by %s", admlvl, sendername);
            SendClientMessage(para1, COLOR_RED, string);
            format(string, sizeof(string), "  You have promoted %s to a level %d admin.", giveplayer,admlvl);
            SendClientMessage(playerid, COLOR_RED, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "  you are not authorized to use that command!");
        }
return 1;
}
Reply
#10

Try this command instead. Your command had a few problems with it.
pawn Код:
if(strcmp(cmd, "/giveadmin", true) == 0)
{
  new tmp[256], tmpp[256];
  if(IsPlayerAdmin(playerid) || level[playerid] >= 4)
  {
   tmp = strtok(cmdtext, idx);
   if(!strlen(tmp)) return SendClientMessage(playerid, color, "Usage: /giveadmin <id> <level (1-4)>");
   new targetid = strval(tmp); if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, color, "Invalid Player ID");
   tmpp = strtok(cmdtext, idx);
   if(!strlen(tmpp)) return SendClientMessage(playerid, color, "Usage: /giveadmin <id> <level (1-4)>");
   new admlevel = strval(tmpp);
   new str[128], name[24];
   GetPlayerName(playerid, name, sizeof name);
   format(str, sizeof str, "\\Users\\%s.ini", name);
   dini_IntSet(str, admlevel);
   return 1;
  }
  else return SendClientMessage(playerid, color, "You're not allowed to use this command!");
}
EDIT:

Sorry, just realized you are using dcmd. Also, I think your command problem is that you are making the "admlevel" variable carry the selected playerid amount. (which if you are testing by yourself, would always be zero).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)