05.04.2011, 00:25
Ok.. i made this admin script in about.. 30-45 minutes.. but when i /login it tells me to register (i already did register!!!). So, when i /register, it says that im already registered. What should i do
CODE:
PLEASE HELP FAST AS POSSIBLE!!! THX!!!
CODE:
pawn Код:
#include <a_samp>
#include <dini>
#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 COLOR_RED 0xFF0000FF
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
new muted[MAX_PLAYERS];
enum gPInfo
{
Logged,
Regged,
Level
};
new PInfo[MAX_PLAYERS][gPInfo];
public OnPlayerConnect(playerid)
{
new n[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid,n,sizeof(n));
format(file,sizeof(file),"MAdmin/Users/%s.ini",n);
if(dini_Exists(file))
{
SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 0;
return 1;
}
else 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),"MAdmin/Users/%s.ini",n);
PInfo[playerid][Logged] = 0;
if(dini_Exists(file))
{
dini_IntSet(file,"Regged",1);
dini_IntSet(file,"Logged",0);
dini_IntSet(file,"Level",PInfo[playerid][Level]);
return 1;
}
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);
dcmd(get,3,cmdtext);
dcmd(nuke,4,cmdtext);
dcmd(mute,4,cmdtext);
dcmd(unmute,6,cmdtext);
return 0;
}
public OnPlayerText(playerid, text[])
{
if(muted[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You cannot talk while muted!");
return 0;
}
return 1;
}
dcmd_register(playerid,params[])
{
new file[256],n[MAX_PLAYER_NAME]; GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MAdmin/Users/%s.ini",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);
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),"MAdmin/Users/%s.ini",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;
}
dcmd_setlevel(playerid,params[])
{
new level,id,file[256],n[MAX_PLAYER_NAME];//creating the new variabls
new tmp[256], tmp2[256], Index,str[50], str2[50];// creating the new variables
tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);// setting them to strtok so we can use them as parameters of our command
GetPlayerName(id,n,MAX_PLAYER_NAME);//getting the players name
format(file,sizeof(file),"MAdmin/Users/%s.ini",n);//formatting the file
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");//if the player is not rcon admin
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");// if the string is empty
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID"); //if the id is not connected
PInfo[id][Level] = level;//sets the level of the player
dini_IntSet(file,"Level",level);//saves the new level to the file
format(str,sizeof(str),"You have set %s's level to %d",n,level);//creates the string
SendClientMessage(playerid,LIGHTBLUE,str);
format(str2, sizeof(str2), "%s Set your admin level to %i", n, level);
SendClientMessage(id, COLOR_RED, str2);
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_get(playerid,params[])
{
new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index;
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,n,sizeof(n));
if(PInfo[playerid][Level] < 1) return SendClientMessage(playerid,ORANGE,"You need to be level 1 to use this command!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /get <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(id, x, y, z+3);
return 1;
}
dcmd_nuke(playerid,params[])
{
new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index;
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: /nuke <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
new Float:x,Float:y,Float:z;
GetPlayerPos(id,x,y,z);
CreateExplosion(x,y,z,7,100);
CreateExplosion(x,y,z,7,100);
CreateExplosion(x,y,z,7,100);
CreateExplosion(x,y,z+10,7,100);
CreateExplosion(x,y+10,z,7,100);
CreateExplosion(x,y-10,z,7,100);
CreateExplosion(x+10,y,z,7,100);
CreateExplosion(x-10,y,z,7,100);
SetPlayerHealth(id, -100);
return 1;
}
dcmd_mute(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] < 2) return SendClientMessage(playerid,ORANGE,"You need to be level 2 to use this command!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /mute <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
format(str,sizeof(str),"%s has muted %s",n,on);
SendClientMessageToAll(LIGHTBLUE,str);
muted[id] = 1;
SendClientMessage(id, COLOR_RED, "You were muted!");
return 1;
}
dcmd_unmute(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] < 2) return SendClientMessage(playerid,ORANGE,"You need to be level 2 to use this command!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /unmute <ID> ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
format(str,sizeof(str),"%s has unmuted %s",n,on);
SendClientMessageToAll(LIGHTBLUE,str);
muted[id] = 0;
SendClientMessage(id, COLOR_RED, "You were unmuted!");
return 1;
}