help me errors :/
#8

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Didn't notice. However, I copied the whole script you gave here and tried to compile.
It compiles with no errors, I don't know ... try it again.
pawn Код:
#include <a_samp>
#include <Dini>

#define COLOR_RED    0xAA3333AA
#define COLOR_YELLOW 0xF5DEB3AA
#define COLOR_WHITE  0xFFFFFFAA

#define REGISTER_PATH "Accounts/%s.ini"
// Change this to the folder in scriptfiles that will store all the accounts.
// NOTE: If you remove .ini, it will fuck this filterscript up.
// NOTE: You can change .ini to an extension of your choice (one you can read)

new IsPlayerLogged[MAX_PLAYERS];

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Basic Registration Filterscript ");
    print(" Copyright © 2010 by case 1337:");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pFile[100], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(pFile, sizeof(pFile), REGISTER_PATH, pName);
    if(dini_Exists(pFile))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Welcome, you may now login by typing '/login [password]'.");
        return 1;
    }
    else if(!dini_Exists(pFile))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Welcome, you may now register by typing '/register [password]'.");
        return 1;
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    if(IsPlayerLogged[playerid] == 0)
    {
        new pFile[100], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(pFile, sizeof(pFile), REGISTER_PATH, pName);
        if(dini_Exists(pFile))
        {
            SendClientMessage(playerid, COLOR_RED, "You must login first before performing this action.");
            SendClientMessage(playerid, COLOR_WHITE, "HINT: /login [password]");
            return 0;
        }
        else if(!dini_Exists(pFile))
        {
            SendClientMessage(playerid, COLOR_RED, "You must register first before performing this action.");
            SendClientMessage(playerid, COLOR_WHITE, "HINT: /register [password]");
            return 0;
        }
        return 0;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsPlayerLogged[playerid] == 1) {
        new pFile[100], pName[MAX_PLAYER_NAME];
        new pMoney = GetPlayerMoney(playerid);
        GetPlayerName(playerid, pName, sizeof(pName));
        format(pFile, sizeof(pFile), REGISTER_PATH, pName);
        dini_IntSet(pFile, "Cash", pMoney);
        return 1;
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/register", true) == 0)
    {
        new tmp[256];
        new string[256], pFile[100];
        new pName[MAX_PLAYER_NAME];
        tmp = strtok(cmdtext, idx);
        format(pFile, sizeof(pFile), REGISTER_PATH, pName);
        GetPlayerName(playerid, pName, sizeof(pName));
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /register [password]");
            return 1;
        }
        if(dini_Exists(pFile))
        {
            SendClientMessage(playerid, COLOR_RED, "You are already registered!");
            return 1;
        }
        if(IsPlayerLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_RED, "You are already logged in.");
            return 1;
        }
        if(!dini_Exists(pFile))
        {
            format(string, sizeof(string), "You have registered successfully with the password '%s', you have been logged in.",tmp);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            IsPlayerLogged[playerid] = 1;
            dini_Create(pFile);
            dini_IntSet(pFile, "Password", udb_encode(tmp));
            dini_IntSet(pFile, "Cash", 50000);
            GivePlayerMoney(playerid, 50000);
            return 1;
        }
        return 1;
    }
    if(strcmp(cmd, "/login", true) == 0)
    {
        new pFile[100];
        new pName[MAX_PLAYER_NAME];
        new tmp[256], pass[256];
        tmp = strtok(cmdtext, idx);
        GetPlayerName(playerid, pName, sizeof(pName));
        format(pFile, sizeof(pFile), REGISTER_PATH, pName);
        pass = dini_Get(pFile, "Password");
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /login [password]");
            return 1;
        }
        if(IsPlayerLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_RED, "You are already logged in.");
            return 1;
        }
        if(!dini_Exists(pFile))
        {
            SendClientMessage(playerid, COLOR_RED, "You must register first before performing this action.");
            SendClientMessage(playerid, COLOR_WHITE, "HINT: /register [password]");
            return 1;
        }
        if(udb_encode(tmp) == strval(pass))
        {
            IsPlayerLogged[playerid] = 1;
            GivePlayerMoney(playerid, dini_Int(pFile, "Cash"));
            SendClientMessage(playerid, COLOR_YELLOW, "You have successfully logged into your account.");
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "The password you have entered is incorrect.");
            return 1;
        }
    }
    return 0;
}

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;
}

stock udb_encode(buf[])
{
    new length = strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
i just tryed this and it still gives me these errors

Код:
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(163) : error 021: symbol already defined: "strtok"
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(178) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
do you have msn if so il add you and then do it on teamviewer?
Reply


Messages In This Thread
help me errors :/ - by hadzx - 14.01.2011, 08:56
Re: help me errors :/ - by Toreno - 14.01.2011, 09:09
Re: help me errors :/ - by hadzx - 14.01.2011, 09:14
Re: help me errors :/ - by Toreno - 14.01.2011, 09:21
Re: help me errors :/ - by hadzx - 14.01.2011, 09:24
Re: help me errors :/ - by Toreno - 14.01.2011, 09:32
Re: help me errors :/ - by [WF]Demon - 14.01.2011, 09:32
Re: help me errors :/ - by hadzx - 14.01.2011, 09:46
Re: help me errors :/ - by hadzx - 14.01.2011, 09:48
Re: help me errors :/ - by hadzx - 14.01.2011, 09:50

Forum Jump:


Users browsing this thread: 1 Guest(s)