Re: Script Request Thread #3

I need to someone that can make me automatic login.

pawn Код:
#include <a_samp>
#include <dutils>
#include <dudb>
#include <dini>
#include <core>
#include <float>

////////////////////////////////////////////////////////////////////////////////

#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

////////////////////////////////////////////////////////////////////////////////

forward UpdateStats();
forward OnPlayerRegister(playerid);
forward OnPlayerLogin(playerid);

////////////////////////////////////////////////////////////////////////////////

enum player_account_info
{
    logged,
    name[MAX_PLAYER_NAME],
    money,
    score,
    perfect,
    level,
}

new pInfo[MAX_PLAYERS][player_account_info];
new Kills[MAX_PLAYERS];

////////////////////////////////////////////////////////////////////////////////

public OnPlayerConnect(playerid)
{
  pInfo[playerid][logged] = 0;
  pInfo[playerid][level] = 0;
  pInfo[playerid][money] = 0;
  pInfo[playerid][score] = 0;
  pInfo[playerid][perfect] = 0;
    GetPlayerName(playerid,pInfo[playerid][name],128);
}
////////////////////////////////////////////////////////////////////////////////

public OnPlayerDisconnect(playerid, reason)
{


  pInfo[playerid][logged] = 0;
  pInfo[playerid][level] = 0;
  pInfo[playerid][money] = 0;
  pInfo[playerid][score] = 0;
  pInfo[playerid][perfect] = 0;

}
////////////////////////////////////////////////////////////////////////////////

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(login,5,cmdtext);
    dcmd(REGISTER,8,cmdtext);

////////////////////////////////////////////////////////////////////////////////

dcmd_login(playerid,params[])
{
    new string[265];
    new tmp[265];

    if(pInfo[playerid][logged] == 1)return SendMsg(playerid, 5000, "~r~Information: ~w~You are already ~r~logged~w~ in!");

  if(!strlen(params))return SendMsg(playerid, 5000, "~b~USAGE: ~w~/login [password]");

  if (dini_Exists(udb_encode(pInfo[playerid][name])))
  {
      tmp = dini_Get(udb_encode(pInfo[playerid][name]), "password");
    if (udb_hash(params) != strval(tmp))
    {
      SendMsg(playerid, 5000, "~r~Information: ~w~Wrong password!");
    }
    else
    {
        OnPlayerLogin(playerid);
    }
    }
    else
    {
    format(string, sizeof(string), "The Account %s does not exist in our Database yet, use /register password to register it!", pInfo[playerid][name]);
    SendMsg(playerid, 5000, string);
  }

  return 1;
}

dcmd_REGISTER(playerid,params[])
{
    new string[128];

    if(pInfo[playerid][logged] == 1)return SendMsg(playerid, 5000, "~r~Information: ~w~You are already logged in");
    if(!strlen(params))return SendMsg(playerid, 5000, "~r~Information:~w~ Use /register password");

  if (!dini_Exists(udb_encode(pInfo[playerid][name])))
  {
        format(string, sizeof(string), "The Account %s has been Succesfully registered! You have been automaticly logged in - Password: %s]", pInfo[playerid][name], params);
        SendClientMessage(playerid, COLOR_NOTICE, string);
        dini_Create(udb_encode(pInfo[playerid][name]));
        dini_IntSet(udb_encode(pInfo[playerid][name]), "password", udb_hash(params));
    OnPlayerRegister(playerid);
    OnPlayerLogin(playerid);
  }
  else
  {
    format(string, sizeof(string), "~r~Information: ~w~%s is already registered!", pInfo[playerid][name]);
    SendMsg(playerid, 5000, string);
  }

  return 1;
}

public OnPlayerLogin(playerid)
{
    new string[265];

    pInfo[playerid][logged] = 1;
    pInfo[playerid][money] = dini_Int(udb_encode(pInfo[playerid][name]), "money");
    pInfo[playerid][score] = dini_Int(udb_encode(pInfo[playerid][name]), "score");
    pInfo[playerid][level] = dini_Int(udb_encode(pInfo[playerid][name]), "level");
    pInfo[playerid][perfect] = dini_Int(udb_encode(pInfo[playerid][name]), "perfect");

  format(string, sizeof(string), "~r~Information: ~w~your now logged in! [~r~Score: ~w~%d] [~r~Admin Level: ~w~%d] [~r~Premium Member:~w~ %d] [~r~Money: ~w~%d]", pInfo[playerid][score], pInfo[playerid][level], pInfo[playerid][perfect], pInfo[playerid][money]);
    SendMsg(playerid, 5000, string);

    GivePlayerMoney(playerid,pInfo[playerid][money]);
    SetPlayerScore(playerid,pInfo[playerid][score]+GetPlayerScore(playerid));
}

////////////////////////////////////////////////////////////////////////////////

public OnPlayerRegister(playerid)
{
    dini_IntSet(udb_encode(pInfo[playerid][name]), "money", pInfo[playerid][money]);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "score", pInfo[playerid][score]);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "level", 0);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "perfect", 0);
}

////////////////////////////////////////////////////////////////////////////////

public UpdateStats()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      pInfo[i][money] = GetPlayerMoney(i);
        pInfo[i][score] = GetPlayerScore(i);

      if(pInfo[i][logged] == 1)
      {
        dini_IntSet(udb_encode(pInfo[i][name]), "perfect", pInfo[i][perfect]);
        dini_IntSet(udb_encode(pInfo[i][name]), "money", pInfo[i][money]);
        dini_IntSet(udb_encode(pInfo[i][name]), "score", pInfo[i][score]);
        dini_IntSet(udb_encode(pInfo[i][name]), "level", pInfo[i][level]);
        }
    }
}
Reply


Messages In This Thread
Re: Script Request Thread #3 - by clean180ollie - 28.07.2009, 10:14
Re: Script Request Thread #3 - by Dj_maryo1993 - 28.07.2009, 12:30
Re: Script Request Thread #3 - by refshal - 28.07.2009, 16:25
Re: Script Request Thread #3 - by Cio-Rap - 28.07.2009, 17:49
Re: Script Request Thread #3 - by user226 - 28.07.2009, 18:56
Re: Script Request Thread #3 - by refshal - 28.07.2009, 19:02
Re: Script Request Thread #3 - by arnutisz - 28.07.2009, 20:34
Re: Script Request Thread #3 - by [Sk]Noob - 28.07.2009, 21:41
Re: Script Request Thread #3 - by Dj_maryo1993 - 28.07.2009, 21:48
Re: Script Request Thread #3 - by Correlli - 29.07.2009, 00:36
Re: Script Request Thread #3 - by adi360 - 01.08.2009, 09:43
Re: Script Request Thread #3 - by Martin_Smith - 01.08.2009, 13:57
Re: Script Request Thread #3 - by Geekzor - 01.08.2009, 16:10
Re: Script Request Thread #3 - by Mowgli - 01.08.2009, 16:15
Re: Script Request Thread #3 - by Geekzor - 01.08.2009, 16:20
Re: Script Request Thread #3 - by Mowgli - 01.08.2009, 17:20
Re: Script Request Thread #3 - by Correlli - 01.08.2009, 19:39
Re: Script Request Thread #3 - by slip733 - 01.08.2009, 20:35
Re: Script Request Thread #3 - by sora_watson - 01.08.2009, 21:26
Re: Script Request Thread #3 - by Anarkien - 01.08.2009, 21:28
Re: Script Request Thread #3 - by sora_watson - 01.08.2009, 21:57
Re: Script Request Thread #3 - by Anarkien - 01.08.2009, 21:58
Re: Script Request Thread #3 - by Geekzor - 01.08.2009, 23:35
Re: Script Request Thread #3 - by Fabio11 - 01.08.2009, 23:56
Re: Script Request Thread #3 - by UberSocks - 02.08.2009, 00:16
Re: Script Request Thread #3 - by user226 - 02.08.2009, 04:49
Re: Script Request Thread #3 - by Abernethy - 02.08.2009, 04:55
Re: Script Request Thread #3 - by Backwardsman97 - 02.08.2009, 09:53
Re: Script Request Thread #3 - by Paradise671 - 02.08.2009, 13:56
Re: Script Request Thread #3 - by Geekzor - 02.08.2009, 18:39
Re: Script Request Thread #3 - by Yanzl - 16.08.2009, 21:15
Re: Script Request Thread #3 - by Googles - 16.08.2009, 21:44
Re: Script Request Thread #3 - by Backwardsman97 - 17.08.2009, 04:20
Re: Script Request Thread #3 - by illli illlil - 17.08.2009, 08:15
Re: Re: Script Request Thread #3 - by snoob - 17.08.2009, 13:11
Re: Script Request Thread #3 - by Yanzl - 17.08.2009, 15:21
Re: Script Request Thread #3 - by snoob - 17.08.2009, 16:17
Re: Script Request Thread #3 - by Yanzl - 17.08.2009, 17:39
Re: Script Request Thread #3 - by snoob - 17.08.2009, 18:16
Re: Script Request Thread #3 - by Yanzl - 17.08.2009, 19:13
Re: Script Request Thread #3 - by snoob - 17.08.2009, 19:23
Re: Script Request Thread #3 - by Ben_Gale - 18.08.2009, 14:13
Re: Script Request Thread #3 - by Mowgli - 18.08.2009, 16:16
Re: Script Request Thread #3 - by Ben_Gale - 18.08.2009, 16:22
Re: Script Request Thread #3 - by CJ101 - 18.08.2009, 19:39
Gun command - by Benc19 - 19.08.2009, 01:28
Basic admin script.. - by _Vortex - 19.08.2009, 11:36
Re: Basic admin script.. - by refshal - 19.08.2009, 11:57
Re: Basic admin script.. - by _Vortex - 19.08.2009, 12:00
Re: Script Request Thread #3 - by refshal - 19.08.2009, 12:09
Re: Script Request Thread #3 - by _Vortex - 19.08.2009, 12:15
Re: Script Request Thread #3 - by snoob - 19.08.2009, 13:24
Re: Script Request Thread #3 - by _Vortex - 19.08.2009, 15:33
I need a scripter - by _Vortex - 20.08.2009, 10:41
Re: Script Request Thread #3 - by klavins - 20.08.2009, 14:12
Re: Script Request Thread #3 - by _Vortex - 20.08.2009, 15:22
Re: Script Request Thread #3 - by checho322 - 21.08.2009, 04:30
Re: Script Request Thread #3 - by Abernethy - 21.08.2009, 05:55
Re: Script Request Thread #3 - by refshal - 21.08.2009, 08:32
Re: Script Request Thread #3 - by lollie123 - 21.08.2009, 12:18
Re: Script Request Thread #3 - by kman - 11.10.2009, 18:35
Re: Script Request Thread #3 - by Sal_Kings - 11.10.2009, 19:35
Re: Script Request Thread #3 - by Lajko1 - 12.10.2009, 16:13
Re: Script Request Thread #3 - by klavins - 13.10.2009, 18:16
Re: Script Request Thread #3 - by Ritchie999 - 14.10.2009, 21:22
Re: Script Request Thread #3 - by DeltaAirlines12 - 14.10.2009, 23:36
Re: Script Request Thread #3 - by Ritchie999 - 14.10.2009, 23:38
Re: Script Request Thread #3 - by Devine - 14.10.2009, 23:58
Re: Script Request Thread #3 - by DeltaAirlines12 - 14.10.2009, 23:59
Re: Script Request Thread #3 - by Quest123 - 16.10.2009, 08:04
Re: Script Request Thread #3 - by anazhd - 19.10.2009, 20:36
Re: Script Request Thread #3 - by Ritchie999 - 19.10.2009, 20:37
Re: Script Request Thread #3 - by [03]Garsino - 19.10.2009, 20:44
Re: Script Request Thread #3 - by anazhd - 19.10.2009, 20:47
Re: Script Request Thread #3 - by Luka P. - 19.10.2009, 21:14
Re: Script Request Thread #3 - by anazhd - 19.10.2009, 21:23
Re: Script Request Thread #3 - by [ATC]eRaZoR - 19.10.2009, 22:36
Re: Script Request Thread #3 - by Danikov - 20.10.2009, 12:02
Re: Script Request Thread #3 - by MB@ - 20.10.2009, 12:03
Re: Script Request Thread #3 - by Luka P. - 20.10.2009, 12:10
Re: Script Request Thread #3 - by zeli - 24.10.2009, 08:50
Re: Script Request Thread #3 - by Vialpando - 25.10.2009, 09:41
Re: Script Request Thread #3 - by bhuvanesh - 25.10.2009, 13:20
Re: Script Request Thread #3 - by bhuvanesh - 25.10.2009, 13:22
Re: Script Request Thread #3 - by Danikov - 25.10.2009, 13:44
Re: Script Request Thread #3 - by Freddy_Manchez - 25.10.2009, 17:35
My Game Mode Idea , Esacape the Prison - by Anddos - 25.10.2009, 20:14
Re: My Game Mode Idea , Esacape the Prison - by [03]Garsino - 25.10.2009, 20:19
Re: Script Request Thread #3 - by Anddos - 25.10.2009, 20:24
Re: Script Request Thread #3 - by dcgm19 - 27.10.2009, 03:41
Re: Script Request Thread #3 - by DarkClone - 27.10.2009, 09:53
Re: Script Request Thread #3 - by CaHbKo - 27.10.2009, 18:07
Re: Script Request Thread #3 - by Luka P. - 27.10.2009, 18:46
Re: Script Request Thread #3 - by Luka P. - 27.10.2009, 19:06
Re: Script Request Thread #3 - by Scoots - 27.10.2009, 19:09
Re: Script Request Thread #3 - by Camacorn - 28.10.2009, 13:07
Re: Script Request Thread #3 - by [03]Garsino - 28.10.2009, 16:57
Re: Script Request Thread #3 - by Luka P. - 28.10.2009, 17:13
Re: Script Request Thread #3 - by [03]Garsino - 28.10.2009, 17:17
Re: Script Request Thread #3 - by Luka P. - 28.10.2009, 17:23
Re: Script Request Thread #3 - by harryb125 - 31.10.2009, 23:38
Re: Script Request Thread #3 - by Luka P. - 31.10.2009, 23:52
Re: Script Request Thread #3 - by harryb125 - 01.11.2009, 00:29
Re: Script Request Thread #3 - by Luka P. - 01.11.2009, 00:33
Re: Script Request Thread #3 - by harryb125 - 01.11.2009, 01:15
Re: Script Request Thread #3 - by harryb125 - 01.11.2009, 01:21
Re: Script Request Thread #3 - by harryb125 - 01.11.2009, 02:36
Re: Script Request Thread #3 - by kennyist - 01.11.2009, 08:44
Re: Script Request Thread #3 - by blokienl - 01.11.2009, 14:36
Re: Script Request Thread #3 - by blokienl - 01.11.2009, 14:36
Re: Script Request Thread #3 - by Nameless303 - 01.11.2009, 23:27
Script Request Thread #3 - by Veinara - 02.11.2009, 04:48
Re: Script Request Thread #3 - by harryb125 - 02.11.2009, 08:32
Re: Script Request Thread #3 - by Ritchie999 - 02.11.2009, 14:16
Re: Script Request Thread #3 - by Luka P. - 02.11.2009, 15:00
Re: Script Request Thread #3 - by Ritchie999 - 02.11.2009, 15:05
Re: Script Request Thread #3 - by SaYrOn - 02.11.2009, 15:53
Re: Script Request Thread #3 - by MenaceX^ - 02.11.2009, 16:07
Re: Script Request Thread #3 - by Ritchie999 - 02.11.2009, 16:14
Re: Script Request Thread #3 - by WardenCS - 02.11.2009, 17:29
Re: Script Request Thread #3 - by MenaceX^ - 07.11.2009, 15:59
Re: Script Request Thread #3 - by W1nsToN - 07.11.2009, 17:04
Re: Script Request Thread #3 - by killer98p - 07.11.2009, 18:49
Re: Script Request Thread #3 - by Redgie - 07.11.2009, 20:05
Re: Script Request Thread #3 - by W1nsToN - 08.11.2009, 11:36
Re: Script Request Thread #3 - by mehmoodali - 09.11.2009, 07:39
Re: Script Request Thread #3 - by Luka P. - 09.11.2009, 17:19
Re: Script Request Thread #3 - by kintama - 09.11.2009, 20:07
Re: Script Request Thread #3 - by mehmoodali - 10.11.2009, 03:21
Re: Script Request Thread #3 - by retart441 - 10.11.2009, 03:36
Re: Script Request Thread #3 - by kintama - 10.11.2009, 10:16
Re: Script Request Thread #3 - by Camacorn - 10.11.2009, 10:19
Re: Script Request Thread #3 - by Gangsta50 - 10.11.2009, 12:53
Re: Script Request Thread #3 - by Correlli - 10.11.2009, 13:03
Re: Script Request Thread #3 - by (.Aztec); - 10.11.2009, 16:01
Re: Script Request Thread #3 - by Camacorn - 10.11.2009, 18:32
Re: Script Request Thread #3 - by (.Aztec); - 11.11.2009, 21:06
Re: Script Request Thread #3 - by Camacorn - 12.11.2009, 00:55
Re: Re: Script Request Thread #3 - by LarzI - 12.11.2009, 01:34
Re: Script Request Thread #3 - by Ironboy500 - 12.11.2009, 05:31
Re: Script Request Thread #3 - by Lynax - 12.11.2009, 12:05
Re: Script Request Thread #3 - by Jakku - 12.11.2009, 12:07
Re: Script Request Thread #3 - by Lajko1 - 12.11.2009, 12:56
Re: Script Request Thread #3 - by Camacorn - 12.11.2009, 13:02
Re: Script Request Thread #3 - by Lilcuete - 12.11.2009, 20:09
Re: Script Request Thread #3 - by Gangsta50 - 13.11.2009, 06:09
Re: Script Request Thread #3 - by Luka P. - 13.11.2009, 13:19
Re: Script Request Thread #3 - by Lajko1 - 13.11.2009, 13:46
Re: Script Request Thread #3 - by Backwardsman97 - 13.11.2009, 20:44
Re: Script Request Thread #3 - by Luka P. - 14.11.2009, 11:42
Re: Script Request Thread #3 - by jameskmonger - 14.11.2009, 11:48
Re: Script Request Thread #3 - by Lynax - 14.11.2009, 16:35
Re: Script Request Thread #3 - by Peter_Corneile - 14.11.2009, 16:39
Re: Script Request Thread #3 - by Jofi - 16.11.2009, 13:01
Re: Script Request Thread #3 - by killer98p - 16.11.2009, 13:10
Re: Script Request Thread #3 - by [03]Garsino - 16.11.2009, 13:14
Re: Script Request Thread #3 - by Ritchie999 - 16.11.2009, 13:19
Re: Script Request Thread #3 - by killer98p - 16.11.2009, 13:38
Re: Script Request Thread #3 - by Ritchie999 - 16.11.2009, 13:55
Re: Script Request Thread #3 - by killer98p - 16.11.2009, 16:37
Re: Script Request Thread #3 - by Correlli - 30.12.2009, 17:12
Re: Script Request Thread #3 - by Luka P. - 30.12.2009, 17:13
Re: Script Request Thread #3 - by snabbo - 31.12.2009, 09:56
Re: Re: Script Request Thread #3 - by ded - 31.12.2009, 10:43
Re: Script Request Thread #3 - by Hijolion - 01.01.2010, 03:25
Re: Script Request Thread #3 - by [03]Garsino - 01.01.2010, 03:27
Re: Script Request Thread #3 - by Hijolion - 01.01.2010, 03:28
Re: Re: Script Request Thread #3 - by LarzI - 01.01.2010, 03:47
Re: Script Request Thread #3 - by Vialpando - 01.01.2010, 12:02
Re: Script Request Thread #3 - by ~Dangun! - 01.01.2010, 20:54
Re: Re: Script Request Thread #3 - by Hijolion - 04.01.2010, 20:38
Re: Script Request Thread #3 - by Zimon95 - 04.01.2010, 20:53
Re: Script Request Thread #3 - by Hijolion - 04.01.2010, 23:17
Re: Script Request Thread #3 - by Guso - 05.01.2010, 05:09
Re: Script Request Thread #3 - by Correlli - 05.01.2010, 05:16
Re: Script Request Thread #3 - by [03]Garsino - 05.01.2010, 15:27
Re: Re: Script Request Thread #3 - by dugi - 05.01.2010, 16:08

Forum Jump:


Users browsing this thread: 11 Guest(s)