Need help about strings
#1

So I need a little help about storing strings. My code:

Код:
if(dialogid == DIALOG_FORM_3)
	{
		if(response)
		{
	    	if(!IsNumeric(inputtext))
	    	{
				new sl = strlen(inputtext);
	        	if(sl >= 3)
				{
					PlayerData[playerid][NewPlayer] = 0;
			    	strpack(origin[playerid][20],inputtext);
			    	ShowPlayerDialog(playerid,DIALOG_FORM_4,DIALOG_STYLE_MSGBOX,"Thank you!","That was all the information that was useful to us!\nYou can now play!","OK","");
				}
				else
				{
			    	ShowPlayerDialog(playerid,DIALOG_FORM_3,DIALOG_STYLE_INPUT,"Where are you from?","(Error: Invalid country - too short)\nPlease, enter a countrys' name you're from: ","OK","");
			    	Kick(playerid);
				}
			}
			else
			{
	    		ShowPlayerDialog(playerid,DIALOG_FORM_3,DIALOG_STYLE_INPUT,"Where are you from?","(Error: Invalid country - numbers not allowed)\nPlease, enter a countrys' name you're from: ","OK","");
			}
		}
	}
So I tested with the command below:

Код:
COMMAND:test(playerid, params[])
{
	new string[128];
	format(string,sizeof(string), "age %d, origin %s", PlayerData[playerid][Age],PlayerData[playerid][Origin]);
	SendClientMessage(playerid, 0xfffffff,string);
	return 1;
}
The age shows correct, but origin is blank... So how do I store strings correctly?
Reply
#2

wheres the origin dialog? Please list that
Reply
#3

It's in the code above... sorry, I just put Age dialog instead of origin.. first post edited!
Reply
#4

pawn Код:
strmid(origin[playerid][20], inputtext,0, 20, 20);// one solution
format(origin[playerid][20], sizeof(origin[playerid][20]), "%s", inputtext);
try either one of those and post me your result
Reply
#5

I tried both, it shows array ''origin'' out of bounds, but I have this above:

Код:
 new origin[MAX_PLAYERS][20];
Reply
#6

pawn Код:
strmid(origin[playerid], inputtext,0, 20, 20);// one solution
format(origin[playerid], sizeof(origin[playerid]), "%s", inputtext);
Try that

if that wont work remove that array you got already and replace with
pawn Код:
new origin[MAX_PLAYERS];
Reply
#7

Thanks, it worked!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)