SA-MP Forums Archive
File with password - 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: File with password (/showthread.php?tid=161469)



[SOLVED]File with password - DRIFT_HUNTER - 20.07.2010

Grrrrrrrrr i trying get it working almost 1h and can not make it !
so i ned one example if someone can help

Well what i need is to load and create file with command
/createfile [NAME][PASS] is working but i ned /loadfile [NAME][PASS] - I just can not make it...i dont get how the fuck i can check for password is it correct without getting some error
Here is my create file cmd and i using zcmd,sscanf and DJSON
Код:
CMD:createfile(playerid, params[])
{
    new string[64];
    new file_name[128], pass[128];
    if(sscanf(params, "ss", file_name, pass)) return SendClientMessage(playerid, 0x00FF00AA, "USAGE: /Createfile [File name] [File password]");
    format(file_name, sizeof(file_name), "%s.test", file_name);
    if(!djIsSet(file_name,"Password"))
    {
        djCreateFile(file_name);
        djSet(file_name, "Password", pass);
       	format(string, sizeof(string), "You created file %s with password %f do not forget it", file_name, pass);
	    SendClientMessage(playerid, 0x00FF00AA, string);
	}
	else
    {
    SendClientMessage(playerid, 0x00FF00AA, "That file alredy exist");
    }
	return 1;
}
NOTE:These command is working perfect i need /loadfile COMMAND that is working


Re: File with password - Scenario - 20.07.2010

Okay, so from the look of your note, your /createfile command works, now you need /loadfile. Hm


Re: File with password - DRIFT_HUNTER - 20.07.2010

Yep thats what i ned
And here is where im stuck with: error 035: argument type mismatch (argument 1)
on line if(strcmp(djInt(file_name, "Password"), pass, true))
Код:
CMD:loadfile(playerid, params[])
{
    new file_name[128], pass[128];
    if(sscanf(params, "ss", file_name, pass)) return SendClientMessage(playerid, 0x00FF00AA, "USAGE: /Loadfile [File name] [File password]");
    format(file_name, sizeof(file_name), "%s.test", file_name);
    if(djIsSet(file_name,"Password"))
    {
        if(strcmp(djInt(file_name, "Password"), pass, true))
        {
	    SendClientMessage(playerid, 0x00FF00AA, "File loaded");
        }
        else
        {
        SendClientMessage(playerid, 0xFF0000AA, "SERVER: Wrong password!");
        }
	}
	else
    {
    SendClientMessage(playerid, 0x00FF00AA, "That file alredy exist");
    }
	return 1;
}



Re: File with password - DRIFT_HUNTER - 20.07.2010

anyone can help? (sorry for bump within 12h)


Re: File with password - straco - 20.07.2010

I don't test and using this but I think you try to get Integer and password is saved as String.

If I'm wrong sorry for spam


Re: File with password - DRIFT_HUNTER - 20.07.2010

Well i just trying to get /loadfile cmd to work so if you have some other way just show me pls


Re: File with password - Jefff - 20.07.2010

Try
pawn Код:
CMD:loadfile(playerid, params[])
{
    new file_name[128], pass[128], str[32];
    if(sscanf(params, "ss", file_name, pass)) return SendClientMessage(playerid, 0x00FF00AA, "USAGE: /Loadfile [File name] [File password]");
    format(file_name, sizeof(file_name), "%s.test", file_name);
    if(fexist(file_name))
    {
        valstr(str,djInt(file_name, "Password"));
        if(!strcmp(str, pass, true))
        {
            SendClientMessage(playerid, 0x00FF00AA, "File loaded");
        }else SendClientMessage(playerid, 0xFF0000AA, "SERVER: Wrong password!");
    }else SendClientMessage(playerid, 0x00FF00AA, "That file not exist");
    return 1;
}



Re: File with password - MadeMan - 20.07.2010

djInt is for numbers, dj is for strings

pawn Код:
if(strcmp(dj(file_name, "Password"), pass, true))



Re: File with password - DRIFT_HUNTER - 21.07.2010

Thx!!! Its working !!!