[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 !!!