Hello & Welcome to our community. Is this your first visit? Register

Results 1 to 5 of 5
  1. #1
    Evil Scottish Overlord Junkers's Avatar

    Rank
    Super Mod
    Join Date
    May 2007
    Location
    Scotland
    Posts
    8,233

    [Release] [SA:MP] [FS] Register - Login System

    Adapted directly from the SA:MP Forums. I take no credit for this, I am only sharing this script with the community. All credit goes to Catastroph from the SA:MP Forums

    Quote Originally Posted by Catastroph on the SA:MP Forums
    I saw many members have trouble about creating their own login/register system. To be honest, here DracoBlue has explained much things about how to keep score&money but as I understand, still many beginner people cannot exactly understand what he explains. That is why I have just wanted to share my filterscript I use on my server to save scores and money.

    Here is the source code of my filterscript, actually you don't get any error or warning but if you get any of it, or if you don't know how to compile a PWN file, can download either PWN and AMX file though:

    Download here

    Here's the source code:

    Code:
    // Register / Login Filterscript //
    
    #include <a_samp>
    #include <dudb>
    #include <dutils>
    #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
    
    //Colors//
    #define COLOR_SYSTEM 0xEFEFF7AA
    #define green 0x33FF33AA
    #define blue 0x00FFFFAA
    
    new PLAYERLIST_authed[MAX_PLAYERS];
    
    #if defined FILTERSCRIPT
    
    public OnFilterScriptInit()
    {
    	print("\n--------------------------------------");
    	print("Register / Login System");
    	print("--------------------------------------\n");
    	return 1;
    }
    
    public OnFilterScriptExit()
    {
    	return 1;
    }
    
    #else
    
    main()
    {
    	print("\n----------------------------------");
    	print("Register / Login System");
    	print("----------------------------------\n");
    }
    
    #endif
    
    public OnPlayerRequestSpawn(playerid)
    {
    if (udb_Exists(PlayerName(playerid))){
    if (!PLAYERLIST_authed[playerid]){
    SendClientMessage(playerid,green,"You have already registered, use /login to log into your account.");
    return 0;
    }
    }
    return 1;
    }
    
    public OnPlayerDisconnect(playerid) {
      if (PLAYERLIST_authed[playerid]) {
         // If someone has logged in, it saves money and score.
        dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
        dUserSetINT(PlayerName(playerid)).("score",GetPlayerScore(playerid));
      }
      PLAYERLIST_authed[playerid]=false;
      return 1;
    }
    
    public OnPlayerConnect(playerid)
    {
    
     	if (PLAYERLIST_authed[playerid]==0){
    if (udb_Exists(PlayerName(playerid))){
    SystemMsg(playerid,"You have already registered, please /login [password] to login.");
    }
    else{ SystemMsg(playerid,"You do not have an account, use /register [password] to register then /login [password] to login.");
    }
    
    return 0;
    }
    	return 1;
    }
    
    public OnPlayerCommandText(playerid, cmdtext[])
    {
      dcmd(login,5,cmdtext);
      dcmd(register,8,cmdtext);
      return 0;
    }
    
    stock SystemMsg(playerid,msg[]) {
       if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
           SendClientMessage(playerid,COLOR_SYSTEM,msg);
       }
       return 1;
    }
    
    stock PlayerName(playerid) {
      new name[255];
      GetPlayerName(playerid, name, 255);
      return name;
    }
    
      dcmd_register(playerid,params[]) {
    
        if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You have already had an account.");
        if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"You have already created an account, /login [password] to login.");
        if (strlen(params)==0) return SystemMsg(playerid,"USAGE: /register [password]");
        if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"You have successfully created your account, now use /login [password] to login.");
        return true;
    
     }
    
      dcmd_login(playerid,params[]) {
    
        if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You have already logined.");
        if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"You do not have an account, please /register [password]");
        if (strlen(params)==0) return SystemMsg(playerid,"USAGE: /login [password]");
        if (udb_CheckLogin(PlayerName(playerid),params)) {
           SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("score"));
      	   SetPlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money"));
           PLAYERLIST_authed[playerid]=true;
           return SystemMsg(playerid,"You have successfully logined.");
        }
        return SystemMsg(playerid,"Wrong password or nickname!");
    }

    So all credits go to Catastroph and I hope this helps anyone who's making a gamemode and wants to use a register function.

  2. # ADS
    HyperFilter
    RaGEZONE Sponsor

    Rank
      Sponsor  
    Join Date
    Sep 2013
    Posts
    9000


     

  3. #2
    Rofl lewis-smiffy's Avatar

    Rank
    True Member
    Join Date
    Aug 2007
    Location
    Perv much ?
    Posts
    425

    Re: [FS] Register - Login System

    Thanks ill just quickly put it in the game mode im currently usin


  4. #3
    Member

    Rank
    Member
    Join Date
    Jan 2008
    Posts
    50
    Lol, this might have been helpful BEFORE I spent a week trying to filter out the stuff Pawno CANT do, and use what it CAN do to write my own login/register/save. Pawno is like a programming language equivalant of a retarded midget XD. Nice release dude.

  5. #4
    Is back with HABBO HOTEL! KingAmir's Avatar

    Rank
    True Member
    Join Date
    Feb 2008
    Location
    Malaysia ?
    Posts
    407

    Re: [Release] [FS] Register - Login System

    nice :))

    HABBO - GTA:SA-MP - RaGEZONE


    Quote Originally Posted by pro_habbo View Post
    Sorry but - Link 21 : Go to http://localhost, is dead.
    LMAO!

  6. #5
    I need money in RS. Help? TiMxD's Avatar

    Rank
    True Member
    Join Date
    Jun 2010
    Location
    MineCraft
    Posts
    540

    Re: [Release] [SA:MP] [FS] Register - Login System

    Yeah yeah, old script ... Idc ... I need this ... Anyway, thanks! Now I got something to register with. This is a filter script, right?
    I rarely visit RaGEZONE anymore. Don't ask me why because I don't know. It's like it doesn't want me here even when I want to. Whatever.. 12/05/13

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HyperFilter
Sponsored by HyperFilter , secured by Incapsula , powered by LiteSpeed.
Mods by DBTech. All times are GMT +1. The time now is 09:43 AM.
Powered by vBulletin® Copyright , Jelsoft Enterprises Ltd.