Код:
#define FILTERSCRIPT
#include <a_samp>
#include <dini>
#include <gTeam>
#include <pInfo>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
enum PInfo
{
Logged,
Regged,
Level
}
#if defined FILTERSCRIPT
//TEAMS ------------------------------------------------------------------------
#define TEAM_ADMIN 1
#define TEAM_DRIFTER 2
//TEAM COLOUR-------------------------------------------------------------------
#define TEAM_ADMIN_COLOUR 0xFFFFFFAA
#define TEAM_DRIFTER_COLOUR 0x0000BBAA
//DEFINES A VARIABLE TO STORE THE TEAMS DATA------------------------------------
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Admin Script ");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Class Script ");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(282,1607.0870,1815.6981,10.8203,193.8336,0,0,0,0,0,0);
return 1;
}
public OnPlayerConnect(playerid)
{
PInfo[playerid][Regged] = 0;
PInfo[playerid][Level] = 0;
new n[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid,n,sizeof(n));
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(dini_Exists(file))
{
SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 0;
return 1;
}
if(!dini_Exists(file))
{
SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
PInfo[playerid][Regged] = 0;
PInfo[playerid][Logged] = 0;
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new n[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid,n,sizeof(n));
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
PInfo[playerid][Logged] = 0;
dini_IntSet(file,"Logged",0);
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
dcmd(register,8,cmdtext);
dcmd(login,5,cmdtext);
dcmd(setlevel,8,cmdtext);
dcmd(kick,4,cmdtext);
dcmd(ban,3,cmdtext);
return 0;
}
dcmd_register(playerid,params[])
{
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
if(strlen(params))
{
if(!dini_Exists(file))
{
dini_Create(file);
dini_Set(file,"Password",params);
dini_IntSet(file,"Regged",1);
dini_IntSet(file,"Logged",0);
dini_IntSet(file,"Level",0);
dini_IntSet(file, "Class", 2);//SETS THE DEFAULT CLASS NUMBER WHEN A PLAYER REGISTERS! 2 = DRIFTER [LINE 30]
SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
PInfo[playerid][Regged] = 1;
return 1;
}
}
else
{
SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
return 1;
}
return 1;
}
dcmd_login(playerid,params[])
{
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
if(strlen(params))
{
new pass[256];
pass = dini_Get(file,"Password");
if(dini_Exists(file))
{
if(strcmp(params,pass,false) != 0)
{
SendClientMessage(playerid,YELLOW,"Wrong Password!");
}
else
{
dini_IntSet(file,"Logged",1);
PInfo[playerid][Logged] = 1;
PInfo[playerid][Level] = dini_Int(file,"Level");
SendClientMessage(playerid,YELLOW,"You have now logged in!");
return 1;
}
}
}
else
{
SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
return 1;
}
return 1;
}
//admin cmds
dcmd_setlevel(playerid,params[])
{
new level,id,file[256],n[MAX_PLAYER_NAME];
new tmp[256], tmp2[256], Index,str[50];
tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
GetPlayerName(id,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
PInfo[id][Level] = level;
dini_IntSet(file,"Level",level);
format(str,sizeof(str),"You have set %s's level to %d",n,level);
SendClientMessage(playerid,LIGHTBLUE,str);
return 1;
}
dcmd_kick(playerid,params[])
{
new id,n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,n,sizeof(n));
if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
format(str,sizeof(str),"%s has kicked %s",n,on);
SendClientMessageToAll(LIGHTBLUE,str);
Kick(id);
return 1;
}
dcmd_ban(playerid,params[])
{
new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,n,sizeof(n));
if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
format(str,sizeof(str),"%s has banned %s",n,on);
SendClientMessageToAll(ORANGE,str);
Ban(id);
return 1;
}
dcmd_gethere(playerid,params[])
(
new targetid, Float:x, Float:y, Float:z;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR, "USAGE: /gethere [id]");
if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(targetid, x+1, y+1, z);
return 1;
}
dcmd_goto(playerid,params[])
(
new ID;
if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");
else if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(ID, x, y, z);
SetPlayerPos(playerid, x+1, y+1, z);
return 1;
}
dcmd_stats(playerid,params[])
{
new string[128];
new pDeaths;
new player1, h, m, s;
if(!strlen(params)) player1 = playerid;
else player1 = strval(params);
if(IsPlayerConnected(player1))
{
TotalGameTime(player1, h, m, s);
if(AccInfo[player1][Deaths] == 0) pDeaths = 1;
else pDeaths = AccInfo[player1][Deaths];
format(string, sizeof(string), "|- %s's Statistics -|",PlayerName2(player1));
SendClientMessage(playerid, green, string);
format(string, sizeof(string), "Kills: [%d] | Deaths: [%d] | Ratio: [%0.2f] | Money: [$%d] | Time: [%d] hrs [%d] mins [%d] secs |", AccInfo[player1][Kills], AccInfo[player1][Deaths], Float:AccInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s);
return SendClientMessage(playerid, green, string);
} else
return SendClientMessage(playerid, red, "ERROR: Player Not Connected!");
}
#endif
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;
}
public OnPlayerSpawn (playerid)
{
if(gTeam[playerid] == TEAM_DRIFTER)
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, -2537.0408, -611.9086, 132.5625);
return 1;
}
else if(gTeam[playerid] == TEAM_ADMIN)
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, -1590.0541,715.7346,-5.2422);
return 1;
}