[Help] Adding +1 (OffLine) (INI_WriteInt)
#1

Hello, can someone explain me how to add +1 on Warn, if user have 3 warns, i want to make function u type /offwarn Nickname, and then script add +1

I tryed this but gives me error

Short code for CMD
Код:
YCMD:offwarn(playerid, params[],help)
{
        #pragma unused help
	new player[64],yinifile[64];
	if(sscanf(params,"s[64]", player)) return SCM(playerid,-1,"/offwarn [NICK]");
	format(yinifile, sizeof(yinifile),USER_PATH,player);
	new INI:iniFile = INI_Open(yinifile);
	INI_WriteInt(iniFile,"Warn",PlayerInfo[player][pWarns]++); // "player" is wrong... 
	INI_Close(iniFile);
  	return 1;
}
error 033: array must be indexed (variable "player")
Reply
#2

PHP код:
player string
INI_WriteInt
(iniFile,"Warn",PlayerInfo[player][pWarns]++); //<--player must be integer 
Reply
#3

I'm confused, dont get it how to put it.
Reply
#4

pawn Код:
#define USER_PATH   "/Users/%s.ini"
new off_warn;

forward OfflineWarn(name[], value[]);
public OfflineWarn(name[], value[])
{
    INI_Int("Warn",off_warn);
    return 1;
}

YCMD:offwarn(playerid, params[],help)
{
        #pragma unused help
    if(isnull(params)) SCM(playerid,-1,"/offwarn [NICK]");
    else if(!(2 < strlen(params) < MAX_PLAYER_NAME)) SendClientMessage(playerid,-1,"Error: Incorrect name lenght.");
    else
    {
        new str[60];
        off_warn = 0;
        format(str, sizeof(str),USER_PATH,params);
        if(!INI_ParseFile(str, "OfflineWarn")) SendClientMessage(playerid,-1,"Error: Account doesn't exists.");
        else
        {
            new INI:iniFile = INI_Open(str);
            INI_SetTag(iniFile,"data");
            INI_WriteInt(iniFile,"Warn",off_warn + 1);
            INI_Close(iniFile);
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
#define USER_PATH   "/Users/%s.ini"
new off_warn;

forward OfflineWarn(name[], value[]);
public OfflineWarn(name[], value[])
{
    INI_Int("Warn",off_warn);
    return 1;
}

YCMD:offwarn(playerid, params[],help)
{
        #pragma unused help
    if(isnull(params)) SCM(playerid,-1,"/offwarn [NICK]");
    else if(!(2 < strlen(params) < MAX_PLAYER_NAME)) SendClientMessage(playerid,-1,"Error: Incorrect name lenght.");
    else
    {
        new str[60];
        off_warn = 0;
        format(str, sizeof(str),USER_PATH,params);
        if(!INI_ParseFile(str, "OfflineWarn")) SendClientMessage(playerid,-1,"Error: Account doesn't exists.");
        else
        {
            new INI:iniFile = INI_Open(str);
            INI_SetTag(iniFile,"data");
            INI_WriteInt(iniFile,"Warn",off_warn + 1);
            INI_Close(iniFile);
        }
    }
    return 1;
}
I believe its working, thanks for good path, REP+ to you, thank you very much!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)