20.08.2011, 11:25
hi all this is my FilerScript of Admin+registration:
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
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; }
Need i add new includ? or work only with Dini ? HELP