SA-MP Forums Archive
Multiple strings into one variable? - 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: Multiple strings into one variable? (/showthread.php?tid=414300)



Multiple strings into one variable? - RyanDam - 08.02.2013

Hello,

Im currently scripting a grade system, I defined the diffrent grades. You can give the player a grade now, but I need a way to save each grade.

So far I made this;

Код:
command(givegrade, playerid, params[])
{
	if(Player[playerid][AdminLevel] >= 10 || TempAdmin[playerid][tAdminLevel] >= 10)
	{
	    new id, grade, string[128];
		if(sscanf(params, "ud", id, grade)) return SendClientMessage(playerid, GREY, "Usage: /givegrade [player id or name] [grade id]");
		{
		    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, GREY, NotConnected);
		    EduInfo[playerid][eGrade] = grade;
		    format(string, sizeof(string), "Administrator %s{FFFFFF} has given you a [%s]{FFFFFF}.", RemoveUnderScore(playerid), GetGrades(playerid));
		    SendClientMessage(id, WHITE, string);
		    format(string, sizeof(string), "You have given %s{FFFFFF}, $%s{FFFFFF}.", RemoveUnderScore(id), GetGrades(playerid));
		    SendClientMessage(playerid, WHITE, string);
		}
	}
	else return SendClientMessage(playerid, GREY, AdminOnly);
	return 1;
}
But, how can I save it all into "eGrade", so I can call all the grades back later into a dialog for example?


Thanks in advance!


Re: Multiple strings into one variable? - [MG]Dimi - 08.02.2013

You'll need to use Arrays. Example where you define Variable eGrades you have to chnage it to
pawn Код:
new eGrade[MAX_GRADES]; //or where ever you define it just have [{number of grades}]; after eGrade
then in command you would do something like this:
pawn Код:
EduInfo[playerid][eGrade][grade] = 1;
if you want to check does he have any certain grade use
pawn Код:
if(EduInfo[playerid][eGrade][{grade id}] == 1)
Hope this helps.