Register Sys
#3

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

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

#define COLOR_WHITE 0xFFFFFFAA

#pragma unused ret_memcpy
#pragma tabsize 0

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

enum pInfo
{
    AdminLevel,
    Cash
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new IsLogged[MAX_PLAYERS];

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    IsLogged[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    IsLogged[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx, file[128], tmp[256], tmp2[256];
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/register", true) == 0)
    {
        new name[MAX_PLAYER_NAME];
        tmp = strtok(cmdtext, idx);
        GetPlayerName(playerid, name, sizeof(name));
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
        format(file,sizeof(file),"Users/%s.ini",name);
        if(!fexist(file))
        {
            dini_Create(file);
            dini_IntSet(file, "Password", udb_hash(tmp));
            dini_IntSet(file,"AdminLevel", 0);
            dini_IntSet(file,"Cash", 0);
            SendClientMessage(playerid, COLOR_WHITE, "[System]: Account Created!");
            PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            GetPlayerName(playerid, name, sizeof(name));
            printf("%s has registered a account!", name);
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, " Account Already Found In Database");
            PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        }
        return 1;
    }
    if(strcmp(cmd, "/login", true) == 0)
    {
        new PlayerName[24];
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
        new name[MAX_PLAYER_NAME];
        if(IsLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You already are logged in!");
            return 1;
        }
        else
        {
            GetPlayerName(playerid, name, sizeof(name));
            format(file,sizeof(file),"%s.ini",name);
            if(fexist(file))
            {
            tmp2 = dini_Get(file, "Password");
                if(udb_hash(tmp) != strval(tmp2))
                {
                  SendClientMessage(playerid, COLOR_WHITE, "Login Failed!");
                  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
                  printf("%s has failed to login", name);
                }
                else
                {
                    IsLogged[playerid] = 1;
                    SetPlayerMoney(playerid, dini_Int(file, "Cash"));
                    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
                    SendClientMessage(playerid, COLOR_WHITE, "[System]: Account Logged into!");
                }
            }
        }
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Redone.
Reply


Messages In This Thread
Register Sys - by ServerRestart - 11.07.2011, 00:56
Re: Register Sys - by Adil - 11.07.2011, 01:20
Re: Register Sys - by Kush - 11.07.2011, 01:21
Re: Register Sys - by Adil - 11.07.2011, 01:25
Re: Register Sys - by Kush - 11.07.2011, 01:45
Re: Register Sys - by Adil - 11.07.2011, 01:51
Re: Register Sys - by Kush - 11.07.2011, 01:57

Forum Jump:


Users browsing this thread: 1 Guest(s)