Giving a variable problem
#1

Ok, i got my /register and /login, and it gives one cookie (my variable) on register. and i got a edited money command to /givecookie, and i give myself 50 cookies, but it doesnt save? but everything else does.
Код:
dcmd_login(playerid, params[])
{
  new file[128];
  new string[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
  new tmp;
  tmp = dini_Int(file, "hashPW");
  if(udb_hash(params) != tmp)
  {
    format(string, 256, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, COLOR_RED, string);
  }
  else
  {
    logged[playerid] = 1;
    level[playerid] = dini_Int(file, "level");
		SetPlayerScore(playerid, dini_Int(file, "score"));
		SetPVarInt(playerid,"Cookies", dini_Int(file, "Cookies"));
		GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
    SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!");
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
Код:
dcmd_setcookies(playerid, params[])
{
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecookie [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else
	{
		SetPVarInt(giveplayerid,"Cookies",amount);
		SendClientMessage(playerid, 0x00FF00AA, "Cookies sent!");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Cookies received!");
	}
	return 1;
}
Reply
#2

dont look like you are writing the cookies to a file Dini_IntSet(blah........ your just setting it as a pvar
Reply
#3

OMG LOL "facepalm"
Reply
#4

Fixed i guess lol
Reply
#5

Nope. nothings saving now.

Reply
#6

wheres the bit where ya save asr you doing the cookies first and returning a value? that will stop it
Reply
#7

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new file[128];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file,sizeof(file),"/Users/%s.ini",name);
	if(!dini_Exists(file))
	{
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
	dini_IntSet(file, "Cookies",GetPVarInt(playerid,"Cookies"));
	}
	logged[playerid] = 0;
	dm[playerid] =0;
	God[playerid] =0;
	return 1;
}
^^
Is how i save.

Код:
dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/register [password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are already registered!");
  dini_Create(file);
  dini_IntSet(file, "hashPW", udb_hash(params));
  dini_Set(file, "password", params);
  dini_IntSet(file, "level", 0);
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
	dini_IntSet(file, "Cookies",GetPVarInt(playerid,"Cookies")+1);
  new string[128];
  format(string, 128, "You succesfully registered the nickname %s with password %s", pname, params);
  SendClientMessage(playerid, COLOR_YELLOW, string);
  logged[playerid] = 1;
  SendClientMessage(playerid, COLOR_YELLOW, "You have been automatically logged in!");
  return 1;}
///////////////////////////L O G I N//////////////////////////
dcmd_login(playerid, params[])
{
  new file[128];
  new string[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
  new tmp;
  tmp = dini_Int(file, "hashPW");
  if(udb_hash(params) != tmp)
  {
    format(string, 256, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, COLOR_RED, string);
  }
  else
  {
    logged[playerid] = 1;
    level[playerid] = dini_Int(file, "level");
		SetPlayerScore(playerid, dini_Int(file, "score"));
		SetPVarInt(playerid,"Cookies", dini_Int(file, "Cookies"));
		GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
    SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!");
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
Reply
#8

if(!dini_Exists(file)) //save it?

if the file dont exist save it?
[me=(SF)Noobanatior]cues "facepalm"[/me]
Reply
#9

Im not following. What do i do lol.
Reply
#10

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"/Users/%s.ini",name);
    if(dini_Exists(file))
    {
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
    dini_IntSet(file, "Cookies",GetPVarInt(playerid,"Cookies"));
    }
    logged[playerid] = 0;
    dm[playerid] =0;
    God[playerid] =0;
    return 1;
}
no ! in if(Dini_Exists
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)