Question
#1

OK. I am a Scripter. Im a Good Scripter. Im just not good with DINI. Im doing my Enterance Test to a Script team. The pereson that im doing the test for says i can ask for help. Heres What He says to do:

/* This includes a simple register system to load the co ords. This should show you where to go. */
//Now, this is a base. Do the rest, make it so it saves the co rds, and when they log in, they spawn where
//They left off.

As i said before. Im not that great with DINI. Heres what i haz.

Код:
/* This includes a simple register system to load the co ords. This should show you where to go. */
//Now, this is a base. Do the rest, make it so it saves the co rds, and when they log in, they spawn where
//They left off.

#include <a_samp>
#include <dutils>
#include <dudb>
#include <dini>

#define FILTERSCRIPT
#define COLOR_RED 0xAA3333AA
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#pragma unused ret_memcpy

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Spawn at Disconnect Filterscript By Brant");
	print("--------------------------------------\n");
	return 1;
}

new logged[MAX_PLAYERS];
new file[120];
enum pInfo
{
	pLevel,
	pCoords
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	if(dini_Exists(file))
	{
		if(logged[playerid] == 0)
		{
	  	SendClientMessage(playerid, COLOR_RED, "You need to log in!");
		}
	}
	else
	{
	  SendClientMessage(playerid, COLOR_RED, "you need to register to play. Please /register [password]");
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(logged[playerid] == 0)
	{
	  SetPlayerHealth(playerid, 0.0);
	  SendClientMessage(playerid, COLOR_RED, "You need to log in!");
	}
	else if(logged[playerid] == 1)
	{
	SetPlayerPos(playerid,828.3, -1216, 27);

	  //Let the coding begin
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(login,5,cmdtext);
	dcmd(register,8,cmdtext);
	return 0;
}

dcmd_login(playerid, params[])
{
  //new file[120];
  new string[120], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(string), "%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "It's /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered! /register [pass]");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
  new tmp[256];
  tmp = dini_Get(file, "hash");
  if(udb_hash(params) != strval(tmp))
  {
    format(string, 128, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, COLOR_RED, string);
  }
  else
  {
    logged[playerid] = 1;
    PlayerInfo[playerid][pLevel] = dini_Int(file, "level");
		SendClientMessage(playerid, COLOR_RED, "LOGGED IN?!?");
  }
  return 1;
}

dcmd_register(playerid, params[])
{
	new string[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "It's /register [password]");
  if(dini_Exists(string)) return SendClientMessage(playerid, COLOR_RED, "You are already registered!");
  dini_Create(string);
  dini_IntSet(string, "hash", udb_hash(params));
  dini_Set(string, "password", params);
  dini_IntSet(string, "level", 1);
  dini_IntSet(string, "money", GetPlayerMoney(playerid));
  SendClientMessage(playerid, COLOR_RED, "You've been registered!");
  return 1;
}
#endif
Im lost xD so can you all help me?
Reply
#2

Defines should be above #if defined FILTERSCRIPT
You need to close the if-clause after OnFilterScriptExit (and remove it at the bottom)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)