Help with reading files. - 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: Help with reading files. (
/showthread.php?tid=568712)
Help with reading files. -
$Marco$ - 24.03.2015
Hey there,
I'm trying to improve my knowledge and I was wondering how to do something.
I'm trying to create a system where you can "speak" to it and it does things for you, for example I tried making a door open and close using this.
But even if I write "door" in game it says "You have entered an invalid door code."
Whats wrong

?
pawn Код:
if(dialogid ==DIALOG_DOOR)
{
if(!response)return 1;
if(response)
{
if(!strval(inputtext))
{
SendClientMessage(playerid, GREY, "You have entered an invalid door code.");
}
else
{
if(strcmp(inputtext, "door", true))
{
new value[10];
new File:lFile = fopen("Server/code1.txt", io_append);
if(lFile)
{
while(fread(lFile, value))
fclose(lFile);
}
if(strcmp(value, "1", true))
{
SendClientMessage(playerid, WHITE, "Value was 1, changing to 0.");
fremove("code1.txt");
new File:nFile = fopen("Server/code1.txt", io_append);
fwrite(nFile, "0");
fclose(nFile);
}
SendClientMessage(playerid, WHITE, "You are correct!");
}
else
{
SendClientMessage(playerid, GREY, "You have entered an invalid door code.");
}
}
}
}
Re: Help with reading files. -
$Marco$ - 24.03.2015
Quote:
Originally Posted by ******
"strval" gets a string as a number - "door" is not a number.
|
Wow, thanks.