Multiple strings into one variable?
#1

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!
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)