25.03.2013, 11:30
Well, I decided to make one login/logout/register/changepass, anyway, it had a problem, here's my full script.
Errors:
pawn Код:
#include <a_samp>
#include <dini>
#include <dutils>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#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
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define PlayerFile "XianAdmin/Users/%s.ini"
#define SettingFile "XianAdmin/Settings/MainSettings.ini"
#define CommandFile "XianAdmin/Settings/Commands.ini"
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" XianLogIn by Xian");
print("--------------------------------------\n");
if(!fexist(SettingFile))
{
dini_Create(SettingFile);
dini_IntSet(SettingFile, "PocketMoney", 3000);
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
enum PLAYER_MAIN
{
PLAYER_NAME[MAX_PLAYER_NAME],
PLAYER_IP[16],
PLAYER_REGGED,
PLAYER_PASS,
PLAYER_LOGGED,
PLAYER_LEVEL,
PLAYER_MUTED,
PLAYER_JAILED,
}
new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
enum SETTINGS_MAIN
{
POCKET_MONEY,
JAIL_COMMANDS,
ANNOUNCE_SECONDS,
PASS_MIN,
PASS_MAX
}
new gSettings[SETTINGS_MAIN];
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
new file[100], name[MAX_PLAYER_NAME], Ip[16];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, Ip, sizeof(Ip));
format (file, sizeof(file), PlayerFile, name);
if(!dini_Exists(file))
{
dini_Create(file);
dini_Set(file, "Name", name);
dini_Set(file, "IP", Ip);
dini_IntSet(file, "Registered", -1);
dini_IntSet(file, "Password", 0);
dini_IntSet(file, "Level", 0);
dini_IntSet(file, "Muted", 0);
dini_IntSet(file, "Jailed", 0);
SendClientMessage(playerid, COLOR_ORANGE, "You haven't register on our server yet. Please use /register to register on our server.");
}
strcat(gPlayerInfo[playerid][PLAYER_NAME],
strcat(gPlayerInfo[playerid][PLAYER_IP],
gPlayerInfo[playerid][PLAYER_REGGED]
gPlayerInfo[playerid][PLAYER_PASS]
gPlayerInfo[playerid][PLAYER_LEVEL]
gPlayerInfo[playerid][PLAYER_MUTED]
gPlayerInfo[playerid][PLAYER_JAILED]
if(gPlayerInfo[playerid][PLAYER_REGGED] == 0)
else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
gPlayerInfo[playerid][PLAYER_REGGED]
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[100];
format(file, sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
dini_Set(file, "IP", gPlayerInfo[playerid][PLAYER_IP]);
dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
dini_IntSet(file, "Muted", gPlayerInfo[playerid][PLAYER_MUTED]);
dini_IntSet(file, "Jailed", gPlayerInfo[playerid][PLAYER_JAILED]);
gPlayerInfo[playerid][PLAYER_NAME] = 0;
gPlayerInfo[playerid][PLAYER_IP] = 0;
gPlayerInfo[playerid][PLAYER_REGGED] = 0;
gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
gPlayerInfo[playerid][PLAYER_PASS] = 0;
gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
gPlayerInfo[playerid][PLAYER_MUTED] = 0;
gPlayerInfo[playerid][PLAYER_JAILED] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
dcmd(logout, 6, cmdtext);
dcmd(password, 8, cmdtext);
return 0;
}
dcmd_register(playerid,params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You've registered on our server! /login to continue!");
else if(!params[0])
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /register [password]");
else if (strlen(params) < gSettings[PASS_MIN]] || strlen(params) > gSettings [PASS_MAX])
{
new string[128];
format(string, sizeof(string), "ERROR: Password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOR_ORANGE, string);
}
else
{
new password = num_hash(params);
gPlayerInfo[playerid][PLAYER_PASS] = password;
gPlayerInfo[playerid][PLAYER_REGGED] = 1;
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_ID], 16);
new string[128]; format (string, sizeof(string), "You've registered your account with the password %s. You've been automatically logged in. Remember your password well!");
return SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
dcmd_login(playerid,params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You must register first!");
else if(gPlayerInfo[playerid][PLAYER_LOEED] == 1)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are already logged in.");
else if(!params[0])
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /login [password]");
else
{
new password = num_hash(params);
if(gPlayerInfo[playerid][PLAYER_PASS] == password)
{
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have logged in to your account!");
}
else
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Wrong password!");
}
}
dcmd_logout(playerid, params[])
{
#pragma unused params
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You must register to do that! Use /register [password] to register.");
else if(gPlayerInfo[playerid][PLAYER_LOGGED] = 0)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are already logged out, login again use /login [password]");
else
{
gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have logged out!");
}
}
dcmd_changepass(playerid, params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You must register to do that! Use /register [password] to register.");
else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You must log in to do that! Use /login [password].");
else
{
new tmp[30],
tmp2[30],
index;
tmp = strtok(params, index);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /changepass [current password] [new password]");
tmp2 = strtok(params, index);
if(!strlen(tmp2))
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /changepass [current password] [new password]");
new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2)
if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
{
if(oldpassword == newpassword)
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Your current password cannot be same with new password!");
else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
{
new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOR_ORANGE, string);
}
gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
new string[128]; format(string, sizeof(string), "You have changed your password from %s to %s, remember the new password properly!", tmp, temp2);
return SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
else
return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Wrong password.");
}
}
Код:
C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(91 -- 94) : error 001: expected token: ",", but found "-identifier-" C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(94 -- 95) : warning 215: expression has no effect C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(95) : error 001: expected token: ";", but found "-identifier-" C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(95 -- 96) : warning 215: expression has no effect C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(96) : error 001: expected token: ";", but found "-identifier-" C:\Users\Kelvin\Desktop\Scripting\filterscripts\admin.pwn(96) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.