SA-MP Forums Archive
Saving strings from inputtext to PVars - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving strings from inputtext to PVars (/showthread.php?tid=273315)



Saving strings from inputtext to PVars - Arturo226 - 01.08.2011

Hello.
I've recently been making my /createhouse command for my upcoming server. Everything works fine except for the description part, it doesn't save at all. And that is entered in a dialog box. The inputtext is then being stored inside the PVar, which it doesn't seem to do. Some of stuff there is in Polish, but I'll translate anything necessary.

Here's the dialog box code:

Код:
		case 17:
		{
		    if(response) ShowPlayerDialog(playerid, 16, DIALOG_STYLE_INPUT, "Cena domu", "Wprowadź cenę domu:", ">>", ""); //this is because the layout of my buttons for this dialog is "<<" and "Finish".
		    else
		    {
		        new opis[96];
		        format(opis, sizeof(opis), "%s", inputtext);
		        SetPVarString(playerid, "HouseDesc", opis);
		        CreateHouse(playerid);
			}
		}
And the CreateHouse function:

Код:
CreateHouse(playerid)
{
	new plik[24], opis[96], info[256];
	format(plik, sizeof(plik), "settings.ini");
	dini_IntSet(plik, "Domy", DomCount + 1);
	DomCount = dini_Int(plik, "Domy");
	format(plik, sizeof(plik), "Domy/Dom%d.ini", DomCount);
	dini_Create(plik);
	dini_IntSet(plik, "ID", DomCount);
	dini_IntSet(plik, "Owned", 0);
	dini_Set(plik, "Wlasciciel", "Nikt");
	dini_FloatSet(plik, "WejscieX", GetPVarFloat(playerid, "DomWejscieX"));
	dini_FloatSet(plik, "WejscieY", GetPVarFloat(playerid, "DomWejscieY"));
	dini_FloatSet(plik, "WejscieZ", GetPVarFloat(playerid, "DomWejscieZ"));
	dini_FloatSet(plik, "WyjscieX", GetPVarFloat(playerid, "DomWyjscieX"));
	dini_FloatSet(plik, "WyjscieY", GetPVarFloat(playerid, "DomWyjscieY"));
	dini_FloatSet(plik, "WyjscieZ", GetPVarFloat(playerid, "DomWyjscieZ"));
	dini_IntSet(plik, "Interior", GetPVarInt(playerid, "DomInterior"));
	dini_IntSet(plik, "Locked", 1);
	dini_IntSet(plik, "Cena", GetPVarInt(playerid, "DomCena"));
	GetPVarString(playerid, "HouseDesc", opis, strlen(opis)); // <---------------------
	dini_Set(plik, "Opis", opis);
	dini_IntSet(plik, "Sejf", 10);
	dini_IntSet(plik, "Marihuana", 0);
	dini_IntSet(plik, "Kokaina", 0);
	dini_IntSet(plik, "Bron1", 0);
	dini_IntSet(plik, "Bron2", 0);
	dini_IntSet(plik, "Bron3", 0);
	dini_IntSet(plik, "VirtualWorld", dini_Int(plik, "ID"));
	format(info, sizeof(info), "Dom nr. %d\nOpis: %s\nCena: $%d\nWpisz /kupdom żeby zakupić!", DomCount, dini_Get(plik, "Opis"), dini_Int(plik, "Cena"));
	CreateDynamicPickup(1273, 1, dini_Float(plik, "WejscieX"), dini_Float(plik, "WejscieY"), dini_Float(plik, "WejscieZ"));
	CreateDynamicPickup(1274, 1, dini_Float(plik, "WejscieX"), dini_Float(plik, "WejscieY"), dini_Float(plik, "WejscieZ"));
	DomInfo[DomCount] = Create3DTextLabel(info, COLOR_DARKGREEN, dini_Float(plik, "WejscieX"), dini_Float(plik, "WejscieY"), dini_Float(plik, "WejscieZ"), 50, 0, 0);
	printf("[SYSTEM] Dom %d zostal stworzony przez %s!", DomCount, PlayerName(playerid));
	SendClientMessage(playerid, ZIELONY, "KOMENDA: Dom został pomyślnie stworzony!");
	DeletePVar(playerid, "DomWejscieX"); DeletePVar(playerid, "DomWejscieY"); DeletePVar(playerid, "DomWejscieZ");
	DeletePVar(playerid, "DomWyjscieX"); DeletePVar(playerid, "DomWyjscieY"); DeletePVar(playerid, "DomWyjscieZ");
	DeletePVar(playerid, "DomInterior");
	DeletePVar(playerid, "DomCena");
	DeletePVar(playerid, "DomOpis");
	return 1;
}
If you have any difficulties reading the code, then just let me know and I'll translate everything...


Re: Saving strings from inputtext to PVars - Basicz - 01.08.2011

Try to change this
pawn Код:
GetPVarString(playerid, "HouseDesc", opis, strlen(opis)); // <---------------------
strlen?

pawn Код:
GetPVarString( playerid, "HouseDesc", opis, sizeof opis );
Should be sizeof, because opis doesn't even have a strlen.


Re: Saving strings from inputtext to PVars - Arturo226 - 01.08.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
Try to change this
pawn Код:
GetPVarString(playerid, "HouseDesc", opis, strlen(opis)); // <---------------------
strlen?

pawn Код:
GetPVarString( playerid, "HouseDesc", opis, sizeof opis );
Should be sizeof, because opis doesn't even have a strlen.
Thank you very much! Everything works now.