help me errors :/
#1

i downloaded a fs because i want to make it so people have to register&login to spawn or just login to spawn and this fs does it and i get 2 errors

Код:
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(170) : error 021: symbol already defined: "strtok"
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(185) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
and heres the filterscript code

Код:
/*
	Basic Registration
	©2010 by case 1337:
*/

// You are prohibited from stealing this script and claiming copyright off it.

#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;
}
Reply
#2

Give the specific lines.
Reply
#3

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Give the specific lines.
Код:
#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)
	{// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< line 170
	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;//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> line 185
}

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 hope that helps
Reply
#4

SPECIFIC lines...
pawn Код:
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(170) : error 021: symbol already defined: "strtok"
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(185) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Press ctrl + g and type 170 then press enter,
copy this line and also do the same thing with line 185
Reply
#5

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
SPECIFIC lines...
pawn Код:
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(170) : error 021: symbol already defined: "strtok"
C:\Users\Stephen-Laptop\Desktop\Untitled.pwn(185) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Press ctrl + g and type 170 then press enter,
copy this line and also do the same thing with line 185
i did on that long script so you could see the codes around the error line but ok lol

Код:
	{
thats line 170

Код:
	return result;
thats line 185
Reply
#6

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

Try This. compiled with no errors from my side (Click Me)
Reply
#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
#9

Quote:
Originally Posted by Crodox RP
Посмотреть сообщение
thanks urs complied and im gona test now
Reply
#10

Quote:
Originally Posted by Crodox RP
Посмотреть сообщение
well i went in game and it dint let me spawn i had 2 login/register !!

so i registered and then the game lost connection and the samp-server.exe or whatever its called keeps closing when i register
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)