File with password
#1

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

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

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;
}
Reply
#4

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

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
Reply
#6

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

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;
}
Reply
#8

djInt is for numbers, dj is for strings

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

Thx!!! Its working !!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)