Checking next unused warning slot.... help please
#1

Hey guys, I'm making a /warn command for admins.... And I need to check the next unused warn slot in the player file.
The player can have up to 5 warnings... but this doesn't work to check:

pawn Код:
dcmd_warn(playerid, params[])
    {
      if(PlayerInfo[playerid][pAdmin] < 1) return 1;
      new id,warn[128], string[128], string2[128];
      if(sscanf(params, "u", id)) return SendHelpMessage(playerid, ".: Usage: /warn [playerid/partofname] [warning] :.");
      if(id == INVALID_PLAYER_ID) return SendErrorMessage(playerid, ".: Info: Player not found :.");
      format(string,sizeof(string),"* %s %s has warned %s [%d/5]. Reason: %s *",AdminRankName(playerid),pName(playerid),pName(id),PlayerInfo[id][pWarnings],warn);
      format(string2,sizeof(string2),"%s %s",date(),string);
      SendClientMessageToAll(COLOR_DARKRED,string);
      new File:Warns = fopen("logs/warns.txt", io_append);
        fwrite(Warns,string2);
        fclose(Warns);
        if(dini_Get(Playerfile(id),"Warn1") == 0)
        {
          dini_Set(Playerfile(id),"Warn1",warn);
          return 1;
        }
        if(dini_Get(Playerfile(id),"Warn2") == 0)
        {
          dini_Set(Playerfile(id),"Warn2",warn);
          return 1;
        }
        if(dini_Get(Playerfile(id),"Warn3") == 0)
        {
          dini_Set(Playerfile(id),"Warn3",warn);
          return 1;
        }
        if(dini_Get(Playerfile(id),"Warn4") == 0)
        {
          dini_Set(Playerfile(id),"Warn4",warn);
          return 1;
        }
        if(dini_Get(Playerfile(id),"Warn5") == 0)
        {
          dini_Set(Playerfile(id),"Warn5",warn);
          return 1;
        }
        return 1;
    }
I get following errors:

Код:
D:\Documents and Settings\IntrozeN.MORSE\Desktop\SAMP Server\gamemodes\Testserver.pwn(642) : error 033: array must be indexed (variable "dini_Get")
D:\Documents and Settings\IntrozeN.MORSE\Desktop\SAMP Server\gamemodes\Testserver.pwn(647) : error 033: array must be indexed (variable "dini_Get")
D:\Documents and Settings\IntrozeN.MORSE\Desktop\SAMP Server\gamemodes\Testserver.pwn(652) : error 033: array must be indexed (variable "dini_Get")
D:\Documents and Settings\IntrozeN.MORSE\Desktop\SAMP Server\gamemodes\Testserver.pwn(657) : error 033: array must be indexed (variable "dini_Get")
D:\Documents and Settings\IntrozeN.MORSE\Desktop\SAMP Server\gamemodes\Testserver.pwn(662) : error 033: array must be indexed (variable "dini_Get")
Can anyone correct this and post the working one or tell me how to do and i'll do it please?

Thank you
Reply
#2

Bymp... Really need help with this.
Reply
#3

Can't you just first move the other warnings by 1 slot, to make first slot empty, then add the new warning to the first slot?

pawn Код:
dini_Set(Playerfile(id), "Warn5", dini_Get(Playerfile(id), "Warn4"));
dini_Set(Playerfile(id), "Warn4", dini_Get(Playerfile(id), "Warn3"));
dini_Set(Playerfile(id), "Warn3", dini_Get(Playerfile(id), "Warn2"));
dini_Set(Playerfile(id), "Warn2", dini_Get(Playerfile(id), "Warn1"));
dini_Set(Playerfile(id), "Warn1", warn);
Reply
#4

You cant do this

pawn Код:
if(dini_Get(Playerfile(id),"Warn2") == 0)
That's the same as

pawn Код:
new String[50] = 'Hello narbs';
if(String == 0) // Just won't work...
You use Strval for this kind of thing.
pawn Код:
if(!strval(dini_Get(Playerfile(id),"Warn1"))
.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)