SetVip Command Problem [ NEED HELP ]
#1

Here is the command:
Код:
CMD:setvip( playerid, params[] )
{
	if( pInfo[ playerid ][ Level ] >= 10 || IsPlayerAdmin( playerid ))
	{
		new target, vip, string[124], pName[24];
		if( sscanf( params, "ud", target, vip )) return SCM( playerid, C_RED, "USAGE: /setvip [ playerid ] [ level ]");
		if( !IsPlayerConnected( target )) return SCM( playerid, C_RED, "[ERROR]: {FFFFFF}Player not connected.");
		if( vip < 0 || vip > 4 ) return SCM( playerid, C_RED, "ERROR:Invalid level. (1-4)");
		GetPlayerName( target, pName, sizeof( pName ));
		format( string, sizeof( string ), "%s has been promoted to a vip level %d !", pName, vip);
		SCMToAll( C_WHITE, string);
		pInfo[ playerid ][ Vip ] = vip;
		return ( 1 );
	}  else return SCM( playerid, C_RED, "[ERROR]: {FFFFFF}You need to be a higher level to use this command !");
}
It saves at players disconnect:
Код:
	INI_WriteInt( PlayerFile,           "Vip",     		pInfo[ playerid ][ Vip ]);
And on a player file it appear there if it has or no V.I.P:
Код:
Vip = 3
But, it doesn't saves...i setvip to x, it reconnects and the vip isn't...
Reply
#2

I haven't used y_ini for months, but according to your post that you mentioned that it saves it on the file on the "OnPlayerDisconnect" callback, then the problem is probably on the loading part. It needs to parse the data correctly, otherwise it won't load them.

Just from curiosity, what is this?
Код:
return ( 1 );
Reply
#3

Try it, not tested tbh.

pawn Код:
CMD:setvip(playerid, params[])
{
    if(pInfo[playerid][Level] >= 10 || IsPlayerAdmin(playerid))
    {
        new target, vip, string[124], pName[24];
        if(sscanf(params, "ui", target, vip)) return SCM(playerid, C_RED, "USAGE: /setvip [playerid] [level]");
        if(!IsPlayerConnected(target)) return SCM(playerid, C_RED, "[ERROR]: {FFFFFF}Player not connected.");
        if(vip < 0 || vip > 4) return SCM(playerid, C_RED, "ERROR:Invalid level. (1-4)");
        GetPlayerName(target, pName, sizeof( pName));
        format(string, sizeof(string), "%s has been promoted to a vip level %d !", pName, vip);
        SCMToAll(C_WHITE, string);
        pInfo[playerid][Vip] == vip;
        return 1;
    }
}
Reply
#4

@Logitech90, it will give an error because you have set double '='.
Код:
pInfo[playerid][Vip] == vip;
Also, as I told you RaZzZzoR the problem is on the loading part. Check ******' thread about loading data with y_ini.
Reply
#5

Quote:
Originally Posted by Dwane
Посмотреть сообщение
@Logitech90, it will give an error because you have set double '='.
Код:
pInfo[playerid][Vip] == vip;
Also, as I told you RaZzZzoR the problem is on the loading part. Check ******' thread about loading data with y_ini.
Ah, sorry, small mistake.

For this:

pawn Код:
INI_WriteInt(PlayerFile,"Vip",pInfo[playerid][Vip]);
Are you using:

pawn Код:
new INI:PlayerFile= INI_Open(PlayerPath(playerid));
//PlayerPath or idk where is saved the player account file.

Full code example:

pawn Код:
new INI:PlayerFile= INI_Open(PlayerPath(playerid));
INI_WriteInt(PlayerFile,"Vip",pInfo[playerid][Vip]);
INI_Close(PlayerFile);
Reply
#6

You've used double loops that's why you're receiving the warning.

Remove the double foreach..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)