Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <SII>
- #include <sscanf2>
- #define COLOR_GREY 0x778899FF
- #define COLOR_RED 0xCC3300FF
- #define COLOR_LIGHTBLUE 0x87CEFAFF
- enum PlayerInfo
- {
- Logged,
- Level,
- Frozen,
- pPass,
- pCash
- }
- new PInfo[MAX_PLAYERS][PlayerInfo];
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- 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 OnGameModeExit()
- {
- return 1;
- }
- 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[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
- GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
- format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
- if(!fexist(file))//Checking if the file exists
- {
- SendClientMessage(playerid,-4,"Your account its not registred! Please use /register <password> to register one");
- }
- else
- {
- SendClientMessage(playerid,-4,"Your account its already registred!Please Use /login <password> to login into your account");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- PInfo[playerid][Logged] = 0;
- return 1;
- }
- CMD:register(playerid,params[])
- {
- if(PInfo[playerid] [Logged] == 1) return SendClientMessage(playerid,-4,"You are already logged in !");//checks if player its logged or not
- new password[23];//Creates a variable to store passowrds
- if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,-1,"USAGE:/Register <passowrd>");// this will check if player wrote something or no
- new file[64],PlayerName[24];// creates/stores player names
- GetPlayerName(playerid,PlayerName,sizeof PlayerName);
- format(file,sizeof file,"Admin/%s.ini",PlayerName);
- if(fexist(file)) return SendClientMessage(playerid,-4,"Somehow you're already registered!");//Checking if the player is already registered, again....
- INI_Open(file);//Opening the file with SII include (with this function, if the file is not created, it will automatically create the file.)
- INI_WriteString("Password",password);//Writing in the file the password the player has inputted.
- INI_WriteInt("Level",PInfo[playerid][Level]);//Writing in the file, the variable of the admin level.
- INI_Save();//After we write something to the file, we already have to use this to save the information in the player's file.
- INI_Close();//"Closing the file", that means that we're not using it anymore :P
- SendClientMessage(playerid,-1,"You have successfully registered!");
- PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
- return 1;
- }
- CMD:login(playerid,params[])
- {
- if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,-4,"You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to login
- new password[23],password2[23];//Creating a variable to store the password, and another one to store the password from the user's file.
- if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,-1,"USAGE: /login <password>");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
- new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
- GetPlayerName(playerid,PlayerName,sizeof PlayerName);
- format(file,sizeof file,"Admin/%s.ini",PlayerName);
- if(!fexist(file)) return SendClientMessage(playerid,-4,"Please use /register");//Checking if the player is not registered, again....
- INI_Open(file);//Opening the file with SII include
- INI_ReadString(password2,"Password");
- if(strcmp(password,password2) != 0) return SendClientMessage(playerid,-4,"Wrong password!"),INI_Close();//Checking if he inputted the correct password, if not, retrieve him a message and closing the file;
- PInfo[playerid][Level] = INI_ReadInt("Level");//Setting the admin level variable, to the one thats in his file.
- INI_Close();//"Closing the file", that means that we're not using it anymore :P
- SendClientMessage(playerid,-1,"You have been successfully logged in!");
- PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
- return 1;
- }
- CMD:kick(playerid, params[])
- {
- if(PInfo[playerid][Level] >= 3) {
- new PID; //define the playerid we wanna kick
- new reason[64]; //the reason, put into a string
- new str[128]; //a new message string
- new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
- GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
- GetPlayerName(PID, Playername, sizeof(Playername));
- if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
- if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
- return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
- format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
- SendClientMessageToAll(COLOR_RED, str); //send that message to all
- Kick(PID); //kick the playerid we've defined
- }
- else //if he has not got the permissions
- {
- SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!"); //return this message
- }
- return 1;
- }
- CMD:Setlevel(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)||PInfo[playerid][Level]<5)return SendClientMessage(playerid,0xFF0000FF,"You're not authorized to use that command");
- new tmpspace = strfind(cmdtext," ",true,11);
- if(!cmdtext[11])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /MakeAdmin <playerid> <admin level>");
- if(!cmdtext[tmpspace+1])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /MakeAdmin <playerid> <admin level>");
- PlayerInfo[strval(cmdtext[11])][AdminLevel]=strval(cmdtext[tmpspace+1]);
- new tmpstring[128];
- GetPlayerName(strval(cmdtext[11]),tmpstring,MAX_PLAYER_NAME);
- format(tmpstring,128,"You made %s AdminLevel %d",tmpstring,strval(cmdtext[tmpspace+1]));
- SendClientMessage(playerid,0xFFFFFFFF,tmpstring);
- GetPlayerName(playerid,tmpstring,MAX_PLAYER_NAME);
- format(tmpstring,128,"%s made you AdminLevel %d",tmpstring,strval(cmdtext[tmpspace+1]));
- return SendClientMessage(strval(cmdtext[11]),0xFFFFFFFF,tmpstring);
- }
- CMD:ban(playerid, params[])
- {
- if(PInfo[playerid][Level] >= 3) {
- new PID; //define the playerid we wanna ban
- new reason[64]; //the reason, put into a string
- new str[128]; //a new message string
- new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
- GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
- GetPlayerName(PID, Playername, sizeof(Playername));
- if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
- if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
- return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
- format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
- SendClientMessageToAll(COLOR_RED, str); //send that message to all
- Ban(PID); //Ban the playerid we've defined
- }
- else //if he has not got the permissions
- {
- SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
- }
- return 1;
- }
- COMMAND:freeze(playerid,params[])
- {
- if(PInfo[playerid][Level] >= 5)
- {
- new Target; //defines the playerid we wanna freeze
- if(sscanf(params, "u", Target)) SendClientMessage(playerid, COLOR_RED, "USAGE: /freeze [playerid]"); //tell sscanf again if the parameters/syntax is wrong to return a special message
- if(!IsPlayerConnected(Target)) //if the ID doesn't exist, return an error-message
- return SendClientMessage(playerid, COLOR_GREY, "ERROR:Player is not connected!");
- if(!sscanf(params, "u", Target))
- {
- if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: Cant perform this command on yourself!" ); //I wouldn't add this line, because it won't let you perform this CMD on yourself
- if(PInfo[Target][Level] > PInfo[playerid][Level]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are higher than your level!"); // if the player you're performing this command on has a higher level as you, return a message, you ain't able to freeze him
- new tname[MAX_PLAYER_NAME]; //define the new target-name of the playerid
- GetPlayerName(Target,tname,sizeof(tname)); //get the playername with this function
- new pname[MAX_PLAYER_NAME]; //define the adminname
- GetPlayerName(playerid,pname,sizeof(pname)); //get the adminname with this function
- new tstring[128]; //define the string for the player (victim)
- new pstring[128];// define the string for the admin which is performing
- new astring[128];//define the string for all the players which are online
- format(tstring,sizeof(tstring),"You have been frozen by administrator %s! You cant move!",pname); //this is formatting the player-string, while it's also getting the adminname
- format(pstring,sizeof(pstring),"You have frozen player %s(%d)!",tname,Target); //this is formatting the adminname-string, while it's also getting the playername and his ID(target)
- format(astring,sizeof(astring),"Administrator %s has frozen %s!",pname,tname); //this is formatting the all-string, while it's sending this message to everybody and is getting admin- and playername
- SendClientMessage(Target,COLOR_RED,tstring);//sends the message to the victim
- SendClientMessage(playerid,COLOR_RED,pstring);//sends the message to the admin
- SendClientMessageToAll(COLOR_RED,astring);//sends the message to everybody
- TogglePlayerControllable(Target,0); //with that function, the player won't be able to mov, while we're using the variable "Target" as the playerid
- PInfo[Target][Frozen] = 1;//IMPORTANT:we're getting the variable "[frozen]" out of the enum, and set it's value to "1', the compiler knows now that the player is frozen
- }
- }
- // if he doesn't have permissions, return that message!
- else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
- return 1;
- }
- COMMAND:unfreeze(playerid,params[])
- {
- if(PInfo[playerid][Level] >= 5)
- {
- new Target; //defines the playerid we wanna unfreeze
- if(sscanf(params, "u", Target)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /unfreeze [playerid]"); //tell sscanf again if the parameters/syntax is wrong to return a special message
- if(!IsPlayerConnected(Target)) //if the ID doesn't exist, return an error-message
- return SendClientMessage(playerid, COLOR_GREY, "ERROR:Player is not connected!");
- if(!sscanf(params, "u", Target))
- {
- if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: Cant perform this command on yourself!" ); //I wouldn't add this line, because it won't let you perform this CMD on yourself
- if(PInfo[Target][Level] > PInfo[playerid][Level]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are higher than your level!"); // if the player you're performing this command on has a higher level as you, return a message, you ain't able to unfreeze him
- new tname[MAX_PLAYER_NAME]; //define the new target-name of the playerid
- GetPlayerName(Target,tname,sizeof(tname)); //get the playername with this function
- new pname[MAX_PLAYER_NAME]; //define the adminname
- GetPlayerName(playerid,pname,sizeof(pname)); //get the adminname with this function
- new tstring[128]; //define the string for the player (victim)
- new pstring[128];// define the string for the admin which is performing
- new astring[128];//define the string for all the players which are online
- format(tstring,sizeof(tstring),"You have been unfrozen by administrator %s! You cant move!",pname); //this is formatting the player-string, while it's also getting the adminname
- format(pstring,sizeof(pstring),"You have unfrozen player %s(%d)!",tname,Target); //this is formatting the adminname-string, while it's also getting the playername and his ID(target)
- format(astring,sizeof(astring),"Administrator %s has unfrozen %s!",pname,tname); //this is formatting the all-string, while it's sending this message to everybody and is getting admin- and playername
- SendClientMessage(Target,COLOR_RED,tstring);//sends the message to the victim
- SendClientMessage(playerid,COLOR_RED,pstring);//sends the message to the admin
- SendClientMessageToAll(COLOR_LIGHTBLUE,astring);//sends the message to everybody
- TogglePlayerControllable(Target,1); //with that function, the player will be able to move again, while we're using the variable "Target" as playerid again
- PInfo[Target][Frozen] = 0;//IMPORTANT:we're getting the variable "[frozen]" out of the enum, and set it's value to "0", the compiler knows now that the player is unfrozen
- }
- }
- // if he doesn't have permissions, return that message!
- else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
- return 1;
- }
- COMMAND:clearchat(playerid,params[])
- {
- if( PInfo[ playerid ][ Level ] < 1 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You must be level 1 to use this command!" );
- {
- for( new i = 0; i <= 100; i ++ ) SendClientMessageToAll( COLOR_LIGHTBLUE, "" );
- }
- return 1;
- }[/HTML]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement