Advertisement
Guest User

help

a guest
Nov 15th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.67 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <SII>
  8. #include <sscanf2>
  9.  
  10. #define COLOR_GREY 0x778899FF
  11. #define COLOR_RED 0xCC3300FF
  12. #define COLOR_LIGHTBLUE 0x87CEFAFF
  13.  
  14.  
  15.  
  16. enum PlayerInfo
  17. {
  18. Logged,
  19. Level,
  20. Frozen,
  21. pPass,
  22. pCash
  23. }
  24. new PInfo[MAX_PLAYERS][PlayerInfo];
  25. main()
  26. {
  27. print("\n----------------------------------");
  28. print(" Blank Gamemode by your name here");
  29. print("----------------------------------\n");
  30. }
  31.  
  32.  
  33. public OnGameModeInit()
  34. {
  35. // Don't use these lines if it's a filterscript
  36. SetGameModeText("Blank Script");
  37. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  38. return 1;
  39. }
  40.  
  41. public OnGameModeExit()
  42. {
  43. return 1;
  44. }
  45.  
  46. public OnPlayerRequestClass(playerid, classid)
  47. {
  48. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  49. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  50. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  51. return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56. new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
  57. GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
  58. format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
  59. if(!fexist(file))//Checking if the file exists
  60. {
  61. SendClientMessage(playerid,-4,"Your account its not registred! Please use /register <password> to register one");
  62. }
  63. else
  64. {
  65. SendClientMessage(playerid,-4,"Your account its already registred!Please Use /login <password> to login into your account");
  66. }
  67. return 1;
  68. }
  69.  
  70. public OnPlayerDisconnect(playerid,reason)
  71. {
  72. PInfo[playerid][Logged] = 0;
  73. return 1;
  74. }
  75.  
  76.  
  77. CMD:register(playerid,params[])
  78. {
  79. if(PInfo[playerid] [Logged] == 1) return SendClientMessage(playerid,-4,"You are already logged in !");//checks if player its logged or not
  80. new password[23];//Creates a variable to store passowrds
  81. if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,-1,"USAGE:/Register <passowrd>");// this will check if player wrote something or no
  82. new file[64],PlayerName[24];// creates/stores player names
  83. GetPlayerName(playerid,PlayerName,sizeof PlayerName);
  84. format(file,sizeof file,"Admin/%s.ini",PlayerName);
  85. if(fexist(file)) return SendClientMessage(playerid,-4,"Somehow you're already registered!");//Checking if the player is already registered, again....
  86. INI_Open(file);//Opening the file with SII include (with this function, if the file is not created, it will automatically create the file.)
  87. INI_WriteString("Password",password);//Writing in the file the password the player has inputted.
  88. INI_WriteInt("Level",PInfo[playerid][Level]);//Writing in the file, the variable of the admin level.
  89. INI_Save();//After we write something to the file, we already have to use this to save the information in the player's file.
  90. INI_Close();//"Closing the file", that means that we're not using it anymore :P
  91. SendClientMessage(playerid,-1,"You have successfully registered!");
  92. PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
  93. return 1;
  94. }
  95. CMD:login(playerid,params[])
  96. {
  97. 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
  98. new password[23],password2[23];//Creating a variable to store the password, and another one to store the password from the user's file.
  99. 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.
  100. new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
  101. GetPlayerName(playerid,PlayerName,sizeof PlayerName);
  102. format(file,sizeof file,"Admin/%s.ini",PlayerName);
  103. if(!fexist(file)) return SendClientMessage(playerid,-4,"Please use /register");//Checking if the player is not registered, again....
  104. INI_Open(file);//Opening the file with SII include
  105. INI_ReadString(password2,"Password");
  106. 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;
  107. PInfo[playerid][Level] = INI_ReadInt("Level");//Setting the admin level variable, to the one thats in his file.
  108. INI_Close();//"Closing the file", that means that we're not using it anymore :P
  109. SendClientMessage(playerid,-1,"You have been successfully logged in!");
  110. PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
  111. return 1;
  112. }
  113.  
  114. CMD:kick(playerid, params[])
  115. {
  116. if(PInfo[playerid][Level] >= 3) {
  117. new PID; //define the playerid we wanna kick
  118. new reason[64]; //the reason, put into a string
  119. new str[128]; //a new message string
  120. new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
  121. GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
  122. GetPlayerName(PID, Playername, sizeof(Playername));
  123. 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)
  124.  
  125. if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
  126. return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
  127.  
  128. 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
  129. SendClientMessageToAll(COLOR_RED, str); //send that message to all
  130. Kick(PID); //kick the playerid we've defined
  131.  
  132. }
  133. else //if he has not got the permissions
  134. {
  135. SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!"); //return this message
  136. }
  137. return 1;
  138. }
  139. CMD:Setlevel(playerid, params[])
  140. {
  141. if(!IsPlayerAdmin(playerid)||PInfo[playerid][Level]<5)return SendClientMessage(playerid,0xFF0000FF,"You're not authorized to use that command");
  142. new tmpspace = strfind(cmdtext," ",true,11);
  143. if(!cmdtext[11])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /MakeAdmin <playerid> <admin level>");
  144. if(!cmdtext[tmpspace+1])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /MakeAdmin <playerid> <admin level>");
  145. PlayerInfo[strval(cmdtext[11])][AdminLevel]=strval(cmdtext[tmpspace+1]);
  146. new tmpstring[128];
  147. GetPlayerName(strval(cmdtext[11]),tmpstring,MAX_PLAYER_NAME);
  148. format(tmpstring,128,"You made %s AdminLevel %d",tmpstring,strval(cmdtext[tmpspace+1]));
  149. SendClientMessage(playerid,0xFFFFFFFF,tmpstring);
  150. GetPlayerName(playerid,tmpstring,MAX_PLAYER_NAME);
  151. format(tmpstring,128,"%s made you AdminLevel %d",tmpstring,strval(cmdtext[tmpspace+1]));
  152. return SendClientMessage(strval(cmdtext[11]),0xFFFFFFFF,tmpstring);
  153. }
  154. CMD:ban(playerid, params[])
  155. {
  156. if(PInfo[playerid][Level] >= 3) {
  157. new PID; //define the playerid we wanna ban
  158. new reason[64]; //the reason, put into a string
  159. new str[128]; //a new message string
  160. new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
  161. GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
  162. GetPlayerName(PID, Playername, sizeof(Playername));
  163. 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)
  164.  
  165. if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
  166. return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
  167.  
  168. 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
  169. SendClientMessageToAll(COLOR_RED, str); //send that message to all
  170. Ban(PID); //Ban the playerid we've defined
  171.  
  172. }
  173. else //if he has not got the permissions
  174. {
  175. SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
  176. }
  177. return 1;
  178. }
  179. COMMAND:freeze(playerid,params[])
  180. {
  181. if(PInfo[playerid][Level] >= 5)
  182. {
  183. new Target; //defines the playerid we wanna freeze
  184. 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
  185. if(!IsPlayerConnected(Target)) //if the ID doesn't exist, return an error-message
  186. return SendClientMessage(playerid, COLOR_GREY, "ERROR:Player is not connected!");
  187. if(!sscanf(params, "u", Target))
  188. {
  189. 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
  190. 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
  191. new tname[MAX_PLAYER_NAME]; //define the new target-name of the playerid
  192. GetPlayerName(Target,tname,sizeof(tname)); //get the playername with this function
  193. new pname[MAX_PLAYER_NAME]; //define the adminname
  194. GetPlayerName(playerid,pname,sizeof(pname)); //get the adminname with this function
  195. new tstring[128]; //define the string for the player (victim)
  196. new pstring[128];// define the string for the admin which is performing
  197. new astring[128];//define the string for all the players which are online
  198. 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
  199. 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)
  200. 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
  201. SendClientMessage(Target,COLOR_RED,tstring);//sends the message to the victim
  202. SendClientMessage(playerid,COLOR_RED,pstring);//sends the message to the admin
  203. SendClientMessageToAll(COLOR_RED,astring);//sends the message to everybody
  204. TogglePlayerControllable(Target,0); //with that function, the player won't be able to mov, while we're using the variable "Target" as the playerid
  205. 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
  206. }
  207.  
  208. }
  209.  
  210. // if he doesn't have permissions, return that message!
  211. else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
  212. return 1;
  213. }
  214. COMMAND:unfreeze(playerid,params[])
  215. {
  216. if(PInfo[playerid][Level] >= 5)
  217. {
  218. new Target; //defines the playerid we wanna unfreeze
  219. 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
  220. if(!IsPlayerConnected(Target)) //if the ID doesn't exist, return an error-message
  221. return SendClientMessage(playerid, COLOR_GREY, "ERROR:Player is not connected!");
  222. if(!sscanf(params, "u", Target))
  223. {
  224. 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
  225. 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
  226. new tname[MAX_PLAYER_NAME]; //define the new target-name of the playerid
  227. GetPlayerName(Target,tname,sizeof(tname)); //get the playername with this function
  228. new pname[MAX_PLAYER_NAME]; //define the adminname
  229. GetPlayerName(playerid,pname,sizeof(pname)); //get the adminname with this function
  230. new tstring[128]; //define the string for the player (victim)
  231. new pstring[128];// define the string for the admin which is performing
  232. new astring[128];//define the string for all the players which are online
  233. 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
  234. 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)
  235. 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
  236. SendClientMessage(Target,COLOR_RED,tstring);//sends the message to the victim
  237. SendClientMessage(playerid,COLOR_RED,pstring);//sends the message to the admin
  238. SendClientMessageToAll(COLOR_LIGHTBLUE,astring);//sends the message to everybody
  239. TogglePlayerControllable(Target,1); //with that function, the player will be able to move again, while we're using the variable "Target" as playerid again
  240. 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
  241. }
  242.  
  243. }
  244.  
  245. // if he doesn't have permissions, return that message!
  246. else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
  247. return 1;
  248. }
  249. COMMAND:clearchat(playerid,params[])
  250. {
  251. if( PInfo[ playerid ][ Level ] < 1 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You must be level 1 to use this command!" );
  252. {
  253. for( new i = 0; i <= 100; i ++ ) SendClientMessageToAll( COLOR_LIGHTBLUE, "" );
  254. }
  255. return 1;
  256. }[/HTML]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement