SA-MP Forums Archive
error 006: must be assigned to an array - 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: error 006: must be assigned to an array (/showthread.php?tid=331489)



error 006: must be assigned to an array - jonathan1358 - 04.04.2012

I don't understand
Код:
{
	new Text:newtext[255], scoretotal, killscore ,deathscore ,ratioscore ,file[128];
	format(file,sizeof(file),"/********/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
	scoretotal = GetPlayerScore(playerid);
	killscore = dini_Get(file, "Kills");//error 006: must be assigned to an array
	deathscore = dini_Get(file, "Deaths");//error 006: must be assigned to an array
	ratioscore = killscore / deathscore;
	format(newtext,sizeof(newtext), "~Y~Score:  ~W~%d  ~R~Deaths:  ~W~%d  ~P~Kills:  ~W~%d  ~G~Ratio: ~W~%d",scoretotal, deathscore, killscore ,ratioscore);
	TextDrawSetString(Textdraw, newtext);
	TextDrawShowForPlayer(playerid, Textdraw);
	return 1;
}



Re: error 006: must be assigned to an array - JaTochNietDan - 05.04.2012

dini_Get returns a string, you need to use dini_IntGet.


Re: error 006: must be assigned to an array - Ballu Miaa - 05.04.2012

First of all why are you reading Player Info from the ini file? Why not call your Player Variables from your PlayerInfo enum.

Most of them look like PlayerInfo[playerid][pKills] or PlayerInfo[playerid][Kills] or similar to this.

These are also used to get the value of the array assigned to it!


Re: error 006: must be assigned to an array - DarkScripter - 05.04.2012

pawn Код:
{
    new Text:newtext[255], scoretotal, killscore ,deathscore ,ratioscore ,file[128];
    format(file,sizeof(file),"/********/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
    scoretotal = GetPlayerScore(playerid);
    killscore = dini_int(file, "Kills");//error 006: must be assigned to an array
    deathscore = dini_int(file, "Deaths");//error 006: must be assigned to an array
    ratioscore = killscore / deathscore;
    format(newtext,sizeof(newtext), "~Y~Score:  ~W~%d  ~R~Deaths:  ~W~%d  ~P~Kills:  ~W~%d  ~G~Ratio: ~W~%d",scoretotal, deathscore, killscore ,ratioscore);
    TextDrawSetString(Textdraw, newtext);
    TextDrawShowForPlayer(playerid, Textdraw);
    return 1;
}



Re: error 006: must be assigned to an array - jonathan1358 - 05.04.2012

Quote:

dini_Get returns a string, you need to use dini_IntGet.

thank but i find dini_Int and with dini_IntGet , I have the error 017: undefined symbol "dini_IntGet"
Quote:

First of all why are you reading Player Info from the ini file? Why not call your Player Variables from your PlayerInfo enum.

Most of them look like PlayerInfo[playerid][pKills] or PlayerInfo[playerid][Kills] or similar to this.

These are also used to get the value of the array assigned to it!

I'm using this with a other FS.

Код:
//Le script est fait par Jonathan1358. Version 1.4
#include <a_samp>
#include <ldudb>
#include <lfuncs>

new Text:Textdraw;
public OnFilterScriptInit()
{
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}
public OnGameModeInit()
{
	Textdraw = TextDrawCreate(350.000000,3.000000,"~Y~Score:  ~W~0  ~R~Deaths:  ~W~0  ~P~Kills:  ~W~0  ~G~TimeScore: ~W~0");
    TextDrawAlignment(Textdraw,0);
    TextDrawBackgroundColor(Textdraw,0x000000ff);
    TextDrawFont(Textdraw,2);
    TextDrawLetterSize(Textdraw,0.188888,1.100000);
    TextDrawColor(Textdraw,0xffffffff);
    TextDrawSetOutline(Textdraw,1);
    TextDrawSetProportional(Textdraw,1);
    TextDrawSetShadow(Textdraw,1);
}

public OnPlayerSpawn(playerid)
{
	new Text:newtext[255], scoretotal, killscore ,deathscore ,timescore ,file[128];
	format(file,sizeof(file),"/*********/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
    scoretotal = GetPlayerScore(playerid);
    killscore = dini_Int(file, "Kills");
    deathscore = dini_Int(file, "Deaths");
    timescore = dini_Int(file, "Hours");;
    format(newtext,sizeof(newtext), "~Y~Score:  ~W~%d  ~R~Deaths:  ~W~%d  ~P~Kills:  ~W~%d  ~G~TimeScore: ~W~%d",scoretotal, deathscore, killscore ,timescore);
    TextDrawSetString(Textdraw, newtext);
    TextDrawShowForPlayer(playerid, Textdraw);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/score", cmdtext, true, 10) == 0)
	{
	new Text:newtext[255], scoretotal, killscore ,deathscore ,timescore ,file[128];
	format(file,sizeof(file),"/********/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
   	scoretotal = GetPlayerScore(playerid);
   	killscore = dini_Int(file, "Kills");
   	deathscore = dini_Int(file, "Deaths");
   	timescore = dini_Int(file, "Hours");;
   	format(newtext,sizeof(newtext), "~Y~Score:  ~W~%d  ~R~Deaths:  ~W~%d  ~P~Kills:  ~W~%d  ~G~TimeScore: ~W~%d",scoretotal, deathscore, killscore ,timescore);
   	TextDrawSetString(Textdraw, newtext);
 	TextDrawShowForPlayer(playerid, Textdraw);
   	GameTextForPlayer(playerid,"~Y~Score Update", 1500, 3);
	return 1;
	}
	return 0;
}



Re: error 006: must be assigned to an array - Ballu Miaa - 05.04.2012

Uhh that ways you will need to do some changes in the script. Will let me give some time to it to fix this!


Re: error 006: must be assigned to an array - Psymetrix - 05.04.2012

It could be that dini is so old, it's losing it's functions?

Update your saving method, yini for example.

Load the players stats into variables when they login and save them when they disconnect.

Now use use those variables in the command to show the stats. Not only is it easier and tidy but it puts less strain on the server.


Re: error 006: must be assigned to an array - Ezay - 05.04.2012

@Psymetrix

+1 on Y_INI created by ******.

Beast Saving Method.