Need Help in dcmd
#1

hi all this is my FilerScript of Admin+registration:
Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#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 GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
enum gPInfo
{
	Logged,
	Regged,
	Level
	
	
};
new PInfo[MAX_PLAYERS][gPInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("    Admin Script Tutorial By Cale");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}


public OnPlayerConnect(playerid)
{
	PInfo[playerid][Logged] = 0;
	PInfo[playerid][Regged] = 0;
	PInfo[playerid][Level] = 0;
	new n[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid,n,sizeof(n));
	format(file,sizeof(file),"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),"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;
}
//========================= >>> REGISTER <<< =================================//
dcmd_register(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
 	format(file,sizeof(file),"Users/%s.txt",n);
  	if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"Your Account is Registered in our DataBase!Please ((/login))");
  	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,"Registered",1);
	        dini_IntSet(file,"Logged",0);
	        dini_IntSet(file,"AdminLevel",0);
	        SendClientMessage(playerid,LIGHTBLUE,"Congratulations, your Account is registered in our DataBase! please ((/login))");
	        PInfo[playerid][Regged] = 1;
			return 1;
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
	    return 1;
	}
	return 1;
}
//===========================>>> LOGIN <<<======================================
dcmd_login(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
	format(file,sizeof(file),"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 yet ! ((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,"Server: You have entered a wrong password for this account.");
			}
			else
			{
			    dini_IntSet(file,"Logged",1);
			    PInfo[playerid][Logged] = 1;
			    PInfo[playerid][Level] = dini_Int(file,"AdminLevel");
			    SendClientMessage(playerid,YELLOW,"You have now logged in!");
			    return 1;
			}
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
	    return 1;
	}
	return 1;
}
/////////////////////// NORMAL PLAYER COMMANDS:////////////////////////
/*==============================================================================
=============================ADMIN Lvl 5====================================
================================================================================*/
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];// 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),"Users/%s.txt",n);//formatting the file
	if(PInfo[playerid][Level] < 5) return SendClientMessage(playerid,ORANGE,"You need be Admin lvl 5 to use this command !");// if the string is empty
	if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <1-5>");
	if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"This ID is not Connected."); //if the id is not connected
	PInfo[id][Level] = level;//sets the level of the player
	dini_IntSet(file,"AdminLevel",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);
	return 1;
}
//////////////////////////////////////ADMIN LVL 3/////////////////////////////////
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;
}
//////////////////////////////Admin LVL 4///////////////////////////////
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] < 4) return SendClientMessage(playerid,ORANGE,"You need to be level 4 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 the Player %s From this Server",n,on);
	SendClientMessageToAll(ORANGE,str);
	Ban(id);
	return 1;
}
///////////////////////Admin LVL 2////////////////////////////////////////////


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;
}
the Problem is whene i add another command to the FS like: Slap , it says: undefind symbole:dcmd_slap symbole never used

Need i add new includ? or work only with Dini ? HELP
Reply
#2

Add under OnPlayerCommandText

PHP Code:
dcmd(slap,4,cmdtext); 
Reply
#3

The Pawn code ::: dcmd(slap,4,cmdtext);
Reply
#4

Quote:
Originally Posted by Hurdehack
View Post
The Pawn code ::: dcmd(slap,4,cmdtext);
I Just told him that.
Reply
#5

No Working this is the code after modification(the text in Orange what i added):
Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#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 GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
enum gPInfo
{
	Logged,
	Regged,
	Level
	
	
};
new PInfo[MAX_PLAYERS][gPInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("    Admin Script Tutorial By Cale");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}


public OnPlayerConnect(playerid)
{
	PInfo[playerid][Logged] = 0;
	PInfo[playerid][Regged] = 0;
	PInfo[playerid][Level] = 0;
	new n[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid,n,sizeof(n));
	format(file,sizeof(file),"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),"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);
	dcmd(slap,4,cmdtext);
	return 0;
}
//========================= >>> REGISTER <<< =================================//
dcmd_register(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
 	format(file,sizeof(file),"Users/%s.txt",n);
  	if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"Your Account is Registered in our DataBase!Please ((/login))");
  	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,"Registered",1);
	        dini_IntSet(file,"Logged",0);
	        dini_IntSet(file,"AdminLevel",0);
	        SendClientMessage(playerid,LIGHTBLUE,"Congratulations, your Account is registered in our DataBase! please ((/login))");
	        PInfo[playerid][Regged] = 1;
			return 1;
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
	    return 1;
	}
	return 1;
}
//===========================>>> LOGIN <<<======================================
dcmd_login(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
	format(file,sizeof(file),"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 yet ! ((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,"Server: You have entered a wrong password for this account.");
			}
			else
			{
			    dini_IntSet(file,"Logged",1);
			    PInfo[playerid][Logged] = 1;
			    PInfo[playerid][Level] = dini_Int(file,"AdminLevel");
			    SendClientMessage(playerid,YELLOW,"You have now logged in!");
			    return 1;
			}
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
	    return 1;
	}
	return 1;
}
/////////////////////// NORMAL PLAYER COMMANDS:////////////////////////
/*==============================================================================
=============================ADMIN Lvl 5====================================
================================================================================*/
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];// 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),"Users/%s.txt",n);//formatting the file
	if(PInfo[playerid][Level] < 5) return SendClientMessage(playerid,ORANGE,"You need be Admin lvl 5 to use this command !");// if the string is empty
	if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <1-5>");
	if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"This ID is not Connected."); //if the id is not connected
	PInfo[id][Level] = level;//sets the level of the player
	dini_IntSet(file,"AdminLevel",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);
	return 1;
}
//////////////////////////////////////ADMIN LVL 3/////////////////////////////////
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;
}
//////////////////////////////Admin LVL 4///////////////////////////////
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] < 4) return SendClientMessage(playerid,ORANGE,"You need to be level 4 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 the Player %s From this Server",n,on);
	SendClientMessageToAll(ORANGE,str);
	Ban(id);
	return 1;
}
///////////////////////Admin LVL 2////////////////////////////////////////////
dcmd_slap(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >=2)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_SYN, "[Syntax:]{FFFFFF}  /slap [playerid]");

        new Float:shealth;
        new Float:slx, Float:sly, Float:slz;

        if(IsPlayerConnected(giveplayerid))
        {

            GetPlayerHealth(giveplayerid, shealth);
            SetPlayerHealth(giveplayerid, shealth-5);
            GetPlayerPos(giveplayerid, slx, sly, slz);
            SetPlayerPos(giveplayerid, slx, sly, slz+5);
            PlayerPlaySound(giveplayerid, 1130, slx, sly, slz+5);
            format(string, sizeof(string), "AdmCmd: %s was slapped by %s",GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,string,2);

        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}

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;
}
Errors:
Code:
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 017: undefined symbol "PlayerInfo"
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : warning 215: expression has no effect
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 029: invalid expression, assumed zero
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
4 Errors....
Reply
#6

Quote:
Originally Posted by ServerScripter
View Post
No Working this is the code after modification(the text in Orange what i added):
Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#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 GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
enum gPInfo
{
	Logged,
	Regged,
	Level
	
	
};
new PInfo[MAX_PLAYERS][gPInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("    Admin Script Tutorial By Cale");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}


public OnPlayerConnect(playerid)
{
	PInfo[playerid][Logged] = 0;
	PInfo[playerid][Regged] = 0;
	PInfo[playerid][Level] = 0;
	new n[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid,n,sizeof(n));
	format(file,sizeof(file),"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),"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);
	dcmd(slap,4,cmdtext);
	return 0;
}
//========================= >>> REGISTER <<< =================================//
dcmd_register(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
 	format(file,sizeof(file),"Users/%s.txt",n);
  	if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"Your Account is Registered in our DataBase!Please ((/login))");
  	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,"Registered",1);
	        dini_IntSet(file,"Logged",0);
	        dini_IntSet(file,"AdminLevel",0);
	        SendClientMessage(playerid,LIGHTBLUE,"Congratulations, your Account is registered in our DataBase! please ((/login))");
	        PInfo[playerid][Regged] = 1;
			return 1;
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
	    return 1;
	}
	return 1;
}
//===========================>>> LOGIN <<<======================================
dcmd_login(playerid,params[])
{
	new file[256],n[MAX_PLAYER_NAME];
	GetPlayerName(playerid,n,MAX_PLAYER_NAME);
	format(file,sizeof(file),"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 yet ! ((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,"Server: You have entered a wrong password for this account.");
			}
			else
			{
			    dini_IntSet(file,"Logged",1);
			    PInfo[playerid][Logged] = 1;
			    PInfo[playerid][Level] = dini_Int(file,"AdminLevel");
			    SendClientMessage(playerid,YELLOW,"You have now logged in!");
			    return 1;
			}
		}
	}
	else
	{
	    SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
	    return 1;
	}
	return 1;
}
/////////////////////// NORMAL PLAYER COMMANDS:////////////////////////
/*==============================================================================
=============================ADMIN Lvl 5====================================
================================================================================*/
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];// 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),"Users/%s.txt",n);//formatting the file
	if(PInfo[playerid][Level] < 5) return SendClientMessage(playerid,ORANGE,"You need be Admin lvl 5 to use this command !");// if the string is empty
	if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <1-5>");
	if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"This ID is not Connected."); //if the id is not connected
	PInfo[id][Level] = level;//sets the level of the player
	dini_IntSet(file,"AdminLevel",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);
	return 1;
}
//////////////////////////////////////ADMIN LVL 3/////////////////////////////////
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;
}
//////////////////////////////Admin LVL 4///////////////////////////////
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] < 4) return SendClientMessage(playerid,ORANGE,"You need to be level 4 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 the Player %s From this Server",n,on);
	SendClientMessageToAll(ORANGE,str);
	Ban(id);
	return 1;
}
///////////////////////Admin LVL 2////////////////////////////////////////////
dcmd_slap(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >=2)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_SYN, "[Syntax:]{FFFFFF}  /slap [playerid]");

        new Float:shealth;
        new Float:slx, Float:sly, Float:slz;

        if(IsPlayerConnected(giveplayerid))
        {

            GetPlayerHealth(giveplayerid, shealth);
            SetPlayerHealth(giveplayerid, shealth-5);
            GetPlayerPos(giveplayerid, slx, sly, slz);
            SetPlayerPos(giveplayerid, slx, sly, slz+5);
            PlayerPlaySound(giveplayerid, 1130, slx, sly, slz+5);
            format(string, sizeof(string), "AdmCmd: %s was slapped by %s",GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,string,2);

        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}

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;
}
Errors:
Code:
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 017: undefined symbol "PlayerInfo"
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : warning 215: expression has no effect
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : error 029: invalid expression, assumed zero
C:\DOCUME~1\mrich\Bureau\tyr\ZOMBIE~1\FILTER~1\admin.pwn(234) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
4 Errors....
I Copied the filterscript, I'll Fix it and Send you a link by PM, Expect the pm in 5 minutes or less.
Reply
#7

Ok thanx Man ! i'm whaiting for your P
Reply
#8

well before u now its a virus with more errors!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)