PDA

View Full Version : What's wrong


saffierr
18/02/2016, 09:27 PM
What's wrong, I want to read a file from 'Banned'.

CMD:ewa(playerid, params[])
{
INI:UserPath(playerid)[](name[], value[])
{
INI_String("Banned", PlayerInfo[playerid][Banned]);
}
INI_Load("UserPath.ini");
return 1;
}

error 029: invalid expression, assumed zero
error 017: undefined symbol "@INI_UserPath"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

xXRevolverXx
19/02/2016, 12:51 AM
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

Add this in your script

saffierr
19/02/2016, 01:28 AM
I've got this already.

UserPath(playerid)
{
new string[75], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "/Users/%s.txt", pName);
return string;
}

saffierr
19/02/2016, 12:26 PM
Anyone ?

illuminati2
19/02/2016, 01:11 PM
Solution:-

CMD:ewa(playerid, params[])
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Banned", PlayerInfo[playerid][Banned]);
INI_Close(File);
return 1;
}

saffierr
19/02/2016, 02:11 PM
I think you didn't quite understand the question.
My question is, How can I read the variable from "Banned"?
I mean if "Banned" is 0, I want to check that and return a message "player is not banned".

illuminati2
19/02/2016, 02:25 PM
CMD:ewa(playerid, params[])
{
if(PlayerInfo[playerid][Banned] == 1)
{
SendClientMessage(playerid, -1, "{FF0000}You're banned!");
}
else if(PlayerInfo[playerid][Banned] == 0)
{
SendClientMessage(playerid, -1, "{FF0000}You're not banned!");
}
return 1;
}


Just do this.

saffierr
19/02/2016, 02:28 PM
Lol, I appreciate it that you're trying to help me, but yet again, I mean if someone is offline. You can't unban a online player

illuminati2
19/02/2016, 02:29 PM
Lol, I appreciate it that you're trying to help me, but yet again, I mean if someone is offline. You can't unban a online player

I don't understand what you want exactly please explain more.

saffierr
19/02/2016, 04:22 PM
How to read from the file 'Banned' to check wether the variable is (1 = banned) (0 = not banned).

CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return 0;
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
new string[75], user[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /unban [playername]");
format(string, sizeof string, "/Users/%s.txt", user);
if(fexist(string))
{
new INI:File = INI_Open(string);
// if(INI_WriteInt(File, "Banned", PlayerInfo[string][Banned]) == 0) return SendClientMessage(playerid, COLOR_RED, "Error: The player is not banned!");
printf("Userfile opened");
INI_SetTag(File, "PlayerData");
INI_WriteInt(File, "Banned", 0);
printf("User unbanned");
INI_Close(File);
printf("File closed");
format(string, sizeof string, "You have succesfully unbanned the player.");
SendClientMessage(playerid, COLOR_YELLOW, string);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: The user is not found in the database!");
}
return 1;
}

The // line is incorrect, that's why I ask it

saffierr
19/02/2016, 04:27 PM
Accidentally posted twice.