SA-MP Forums Archive
INI Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: INI Bug (/showthread.php?tid=389641)



INI Bug - AzTeCaS - 02.11.2012

http://i50.tinypic.com/214a0k5.png

i have been coded something (click player) and it shows me wrong stats of that player look this picture it shows 11kils and 9deaths and level 10 even that player has 0 in all of them here's the picture and the code P.S: there is no error's/warning on the script

http://i50.tinypic.com/214a0k5.png

Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{

   PlayerInfo[playerid][pLevel] = INI_ReadInt("level");
   PlayerInfo[playerid][pKills] = INI_ReadInt("kills");
   PlayerInfo[playerid][pDeaths] = INI_ReadInt("Deaths");

    INI_Close();

  new PName[MAX_PLAYER_NAME],strg [190];
 GetPlayerName(clickedplayerid, PName, sizeof (PName));
  format(strg,sizeof(strg),"{F81414} you are viewing {FFFFFF} %s stats \n {00CED1} Kills : {FFFFFF} %d \n {00CED1} Deaths : {FFFFFF} %d \n {00CED1} Level : {FFFFFF} %d  ",PName,pKills,pDeaths,pLevel);
  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{00FF04}Player Stats",strg,"Close","Done");
  

	return 1;
}
here's player file in scriptfiles

Kills=0
Deaths=0
Level=0


Re: INI Bug - tyler12 - 02.11.2012

Shouldn't playerid be clickedplayerid?

Also, you need a file to read from and close.


Re: INI Bug - AzTeCaS - 02.11.2012

i have a file already ofc


AW: INI Bug - Skimmer - 02.11.2012

Try this

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    PlayerInfo[clickedplayerid][pLevel] = INI_ReadInt("level");
    PlayerInfo[clickedplayerid][pKills] = INI_ReadInt("kills");
    PlayerInfo[clickedplayerid][pDeaths] = INI_ReadInt("Deaths");

    INI_Close();

    new PName[MAX_PLAYER_NAME],strg [190];
    GetPlayerName(clickedplayerid, PName, sizeof (PName));
    format(strg,sizeof(strg),"{F81414} you are viewing {FFFFFF} %s stats \n {00CED1} Kills : {FFFFFF} %d \n {00CED1} Deaths : {FFFFFF} %d \n {00CED1} Level : {FFFFFF} %d  ",PName,pKills,pDeaths,pLevel);
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{00FF04}Player Stats",strg,"Close","Done");
    return 1;
}



Re: INI Bug - AzTeCaS - 03.11.2012

still the same bug.


AW: INI Bug - tyler12 - 03.11.2012

You need to open a file...

new INI:File = INI_Open("SomeFile.ini");


Re: INI Bug - Stu1 - 03.11.2012

Try this
PHP код:
public OnPlayerClickPlayer(playeridclickedplayeridsource)
{
   new 
INI:File INI_Open(YOUR INI PATH(playerid));
   
PlayerInfo[playerid][pLevel] = INI_ReadInt("level");
   
PlayerInfo[playerid][pKills] = INI_ReadInt("kills");
   
PlayerInfo[playerid][pDeaths] = INI_ReadInt("Deaths");

    
INI_Close();

  new 
PName[MAX_PLAYER_NAME],strg [190];
 
GetPlayerName(clickedplayeridPNamesizeof (PName));
  
format(strg,sizeof(strg),"{F81414} you are viewing {FFFFFF} %s stats \n {00CED1} Kills : {FFFFFF} %d \n {00CED1} Deaths : {FFFFFF} %d \n {00CED1} Level : {FFFFFF} %d  ",PName,pKills,pDeaths,pLevel);
  
ShowPlayerDialog(playerid1DIALOG_STYLE_MSGBOX"{00FF04}Player Stats",strg,"Close","Done");
  

    return 
1;




Re: AW: INI Bug - admantis - 03.11.2012

Quote:
Originally Posted by tyler12
Посмотреть сообщение
You need to open a file...

new INI:File = INI_Open("SomeFile.ini");
How do you know he is using y_ini? He could be as well using fIini (or bIni).

Instead of accessing an enum index and setting the playerid variables, you should create variables to use as reference.
pawn Код:
new level, kills, deaths;


level = INI_ReadInt("level");
kills = INI_ReadInt("kills");
deaths = INI_ReadInt("Deaths");

INI_Close();

new PName[MAX_PLAYER_NAME],strg [190];
GetPlayerName(clickedplayerid, PName, sizeof (PName));
format(strg,sizeof(strg),"{F81414} you are viewing {FFFFFF} %s stats \n {00CED1} Kills : {FFFFFF} %d \n {00CED1} Deaths : {FFFFFF} %d \n {00CED1} Level : {FFFFFF} %d  ",PName,kills,deaths,level);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{00FF04}Player Stats",strg,"Close","Done");



Re: AW: INI Bug - AzTeCaS - 03.11.2012

Quote:
Originally Posted by tyler12
Посмотреть сообщение
You need to open a file...

new INI:File = INI_Open("SomeFile.ini");

Код:
D:\script\gamemodes\DeathMatchADD.pwn(454) : warning 204: symbol is assigned a value that is never used: "File"
D:\script\gamemodes\DeathMatchADD.pwn(454) : warning 213: tag mismatch



Re: INI Bug - AzTeCaS - 03.11.2012

here's the full code P.S: i'm using Y_INI

Код:
stock getINI(playerid)
{
  new account[64];
  format(account,30,"Users/%s.ini",gPlayerName[playerid]);
  return account;
}
Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
   PlayerInfo[playerid][pLevel] = INI_ReadInt("level");
   PlayerInfo[playerid][pKills] = INI_ReadInt("kills");
   PlayerInfo[playerid][pDeaths] = INI_ReadInt("Deaths");

    INI_Close();

  new PName[MAX_PLAYER_NAME],strg [190];
 GetPlayerName(clickedplayerid, PName, sizeof (PName));
  format(strg,sizeof(strg),"{F81414} you are viewing {FFFFFF} %s stats \n {00CED1} Kills : {FFFFFF} %d \n {00CED1} Deaths : {FFFFFF} %d \n {00CED1} Level : {FFFFFF} %d  ",PName,pKills,pDeaths,pLevel);
  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{00FF04}Player Stats",strg,"Close","Done");


    return 1;
}