[HELP] How to save file into a folder
#1

How can i change my register command so it saves all the users files into a folder instead of straight into the scriptfiles folder?


Код:
dcmd_register(playerid,params[]) {

  new plrip[128]; // The varyable
  GetPlayerIp(playerid,plrip,sizeof(plrip));
  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are already logged into your account");

  // The command shouldn't work if an account with this
  // nick already exists
  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");

  if (RegisterLoginDisabled == 1337) return SystemMsg(playerid,"New Account Registrations are Disabled. This is due to maintenance");
  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Use: /register password to create a new account");

  // We save the money to the accstate
  if (udb_Create(PlayerName(playerid),params)) {

  dUserSetINT(PlayerName(playerid)).("money",7500);
  dUserSetINT(PlayerName(playerid)).("bankcash",5000);
  dUserSetINT(PlayerName(playerid)).("loancash",0);
  dUserSetINT(PlayerName(playerid)).("cashinsured",0);
  dUserSetINT(PlayerName(playerid)).("autobahnowner",0);
  dUserSetINT(PlayerName(playerid)).("regplayer",0);
	dUserSetINT(PlayerName(playerid)).("score",0);
  dUserSetINT(PlayerName(playerid)).("team",0);
  dUserSetINT(PlayerName(playerid)).("skin",0);
  dUserSetINT(PlayerName(playerid)).("jailtime",0);
  dUserSetINT(PlayerName(playerid)).("wallet",0);
  dUserSetINT(PlayerName(playerid)).("cork",0);
  dUserSetINT(PlayerName(playerid)).("drugs",0);
  dUserSetINT(PlayerName(playerid)).("drugbagy",0);
  dUserSetINT(PlayerName(playerid)).("adminlevel",0);
  dUserSetINT(PlayerName(playerid)).("teamkills",0);
  dUserSetINT(PlayerName(playerid)).("innocentkills",0);
  dUserSetINT(PlayerName(playerid)).("lowwantedkills",0);
  dUserSetINT(PlayerName(playerid)).("coprank",0);
  dUserSetINT(PlayerName(playerid)).("robrank",0);
  dUserSetINT(PlayerName(playerid)).("rpabusewar",0);
  dUserSetINT(PlayerName(playerid)).("deaths",0);
  dUserSetINT(PlayerName(playerid)).("casinorob",0);
  dUserSetINT(PlayerName(playerid)).("cashfromcasninorob",0);
  dUserSetINT(PlayerName(playerid)).("atmsrobbed",0);
  dUserSetINT(PlayerName(playerid)).("cashfromatmsrobbed",0);
  dUserSetINT(PlayerName(playerid)).("totaljailtime",0);
  dUserSetINT(PlayerName(playerid)).("finesissued",0);
  dUserSetINT(PlayerName(playerid)).("finespaid",0);
  dUserSetINT(PlayerName(playerid)).("nameban",0);
  dUserSetINT(PlayerName(playerid)).("timesinfected",0);
  dUserSetINT(PlayerName(playerid)).("timesraped",0);
  dUserSetINT(PlayerName(playerid)).("timesrobbed",0);
  dUserSetINT(PlayerName(playerid)).("timeshealed",0);
  dUserSetINT(PlayerName(playerid)).("timescured",0);
  dUserSetINT(PlayerName(playerid)).("hitsplaced",0);
  dUserSetINT(PlayerName(playerid)).("hitsplacedonyou",0);
  dUserSetINT(PlayerName(playerid)).("timessearched",0);
  dUserSetINT(PlayerName(playerid)).("drugssiezedbycops",0);
  dUserSetINT(PlayerName(playerid)).("canusearmy",0);
  dUserSetINT(PlayerName(playerid)).("connectedminute",0);
  dUserSetINT(PlayerName(playerid)).("connectedhour",0);
  dUserSetINT(PlayerName(playerid)).("timesfuckedoff",0);
  dUserSetINT(PlayerName(playerid)).("RegularPlayer",0);
  dUserSet(PlayerName(playerid)).("ipaddress",plrip);


	return SystemMsg(playerid,"Your Account has been created. Login with /login password now to log in (Before Spawn)");

   }
	return true;

 }
Thats my register command
Reply
#2

anyway, i think it should be something like this:

dini_Set("folder/players.cfg", tmp, PlayerName)

i'm not sure, sry if it don't work.
Reply
#3

Quote:
Originally Posted by pmk1
anyway, i think it should be something like this:

dini_Set("folder/players.cfg", tmp, PlayerName)

i'm not sure, sry if it don't work.
.


That didn't work...


it gives me warnings, but Heres the line i think should be edited

Код:
if (udb_Create(PlayerName(playerid),params)) {
Reply
#4

Somethin like this?

pawn Код:
new userfile[256];
format(userfile, sizeof(userfile), "/Folder/players/%s.cfg", PlayerName(playerid));

if (udb_Exists(userfile)) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");
Reply
#5

I took your code and tried to make it so it works the way i want it too.....I'm having so many problems with it tho...


Heres what i did:

Код:
new userfile[256];
if (udb_Create (format(userfile, sizeof(userfile)), "/Folder/players/%s.cfg", PlayerName(playerid)));{

I get the following errors all on the same line

Код:
number of arguments does not match definition
argument type mismatch (argument 1)
empty statement
warning 225: unreachable code
Reply
#6

i thin you have 1 closing ) that you should delete.
try this:
Код:
new userfile[256];
if (udb_Create (format(userfile, sizeof(userfile)), "/Folder/players/%s.cfg", PlayerName(playerid));
Reply
#7

Quote:
Originally Posted by pmk1
i thin you have 1 closing ) that you should delete.
try this:
Код:
new userfile[256];
if (udb_Create (format(userfile, sizeof(userfile)), "/Folder/players/%s.cfg", PlayerName(playerid));
If i use exactly what you gave me, I get these errors:

Код:
 warning 202: number of arguments does not match definition
 error 035: argument type mismatch (argument 1)
 error 001: expected token: ")", but found ";"
 error 036: empty statement
 fatal error 107: too many error messages on one line
Reply
#8

Anyone?
Reply
#9

Quote:
Originally Posted by [___
PotH3Ad ]
Somethin like this?

pawn Код:
new userfile[256];
format(userfile, sizeof(userfile), "/Folder/players/%s.cfg", PlayerName(playerid));

if (udb_Exists(userfile)) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");
Try this.
pawn Код:
dcmd_register(playerid,params[]) {

    new userfile[256];
    format(userfile, sizeof(userfile), "/Folder/players/%s.cfg", PlayerName(playerid));

  new plrip[128]; // The varyable
  GetPlayerIp(playerid,plrip,sizeof(plrip));
  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are already logged into your account");

  // The command shouldn't work if an account with this
  // nick already exists
  if (udb_Exists(userfile)) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");

  if (RegisterLoginDisabled == 1337) return SystemMsg(playerid,"New Account Registrations are Disabled. This is due to maintenance");
  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Use: /register password to create a new account");

  // We save the money to the accstate
  if(udb_Create(userfile)) {

  dUserSetINT(userfile).("money",7500);
  dUserSetINT(userfile).("bankcash",5000);
  dUserSetINT(userfile).("loancash",0);
  dUserSetINT(userfile).("cashinsured",0);
  dUserSetINT(userfile).("autobahnowner",0);
  dUserSetINT(userfile).("regplayer",0);
    dUserSetINT(userfile).("score",0);
  dUserSetINT(userfile).("team",0);
  dUserSetINT(userfile).("skin",0);
  dUserSetINT(userfile).("jailtime",0);
  dUserSetINT(userfile).("wallet",0);
  dUserSetINT(userfile).("cork",0);
  dUserSetINT(userfile).("drugs",0);
  dUserSetINT(userfile).("drugbagy",0);
  dUserSetINT(userfile).("adminlevel",0);
  dUserSetINT(userfile).("teamkills",0);
  dUserSetINT(userfile).("innocentkills",0);
  dUserSetINT(userfile).("lowwantedkills",0);
  dUserSetINT(userfile).("coprank",0);
  dUserSetINT(userfile).("robrank",0);
  dUserSetINT(userfile).("rpabusewar",0);
  dUserSetINT(userfile).("deaths",0);
  dUserSetINT(userfile).("casinorob",0);
  dUserSetINT(userfile).("cashfromcasninorob",0);
  dUserSetINT(userfile).("atmsrobbed",0);
  dUserSetINT(userfile).("cashfromatmsrobbed",0);
  dUserSetINT(userfile).("totaljailtime",0);
  dUserSetINT(userfile).("finesissued",0);
  dUserSetINT(userfile).("finespaid",0);
  dUserSetINT(userfile).("nameban",0);
  dUserSetINT(userfile).("timesinfected",0);
  dUserSetINT(userfile).("timesraped",0);
  dUserSetINT(userfile).("timesrobbed",0);
  dUserSetINT(userfile).("timeshealed",0);
  dUserSetINT(userfile).("timescured",0);
  dUserSetINT(userfile).("hitsplaced",0);
  dUserSetINT(userfile).("hitsplacedonyou",0);
  dUserSetINT(userfile).("timessearched",0);
  dUserSetINT(userfile).("drugssiezedbycops",0);
  dUserSetINT(userfile).("canusearmy",0);
  dUserSetINT(userfile).("connectedminute",0);
  dUserSetINT(userfile).("connectedhour",0);
  dUserSetINT(userfile).("timesfuckedoff",0);
  dUserSetINT(userfile).("RegularPlayer",0);
  dUserSet(userfile).("ipaddress",plrip);
    return SystemMsg(playerid,"Your Account has been created. Login with /login password now to log in (Before Spawn)");
    }
    return true;
}
Reply
#10

It didn't work i get the following warning


Код:
number of arguments does not match definition
On line

Код:
if(udb_Create(userfile)) {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)