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.
/* 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; }
#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; }
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.
SPECIFIC lines...
pawn Код:
copy this line and also do the same thing with line 185 |
{
return result;
#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;
}
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 Код:
|
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