Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ||============================================================================||
- || Nicki's (a.k.a. Viky (samp forum deffo) ) filterscript for automessages ||
- ||============================================================================||
- */
- #include <a_samp>
- #include <sscanf2>
- #define FILTERSCRIPT
- #define M_COLOR 0x710000FF //message color for user/admin
- #define AUTOMSGS_DIALOG 2000 //Dialog ID
- #define TIMEGAP 59 //Time gap between automessages in seconds
- #define MAX_STRING_SIZE 129 //Maximum input size (cannot be increased due to samp limit)
- new gVar2=0;
- stock function_F1(playerid)
- {
- new File:fptr3=fopen("automsgs.txt",io_read);
- new string3[MAX_STRING_SIZE];
- new string4[1600];
- fread(fptr3,string3,sizeof(string3));
- new tm;
- sscanf(string3,"i",tm);
- strcat(string4,"1. ",sizeof(string4));
- new j=1;
- new sj[3];
- while(fread(fptr3,string3,sizeof(string3)))
- {
- strcat(string4,string3,sizeof(string4));
- j++;
- valstr(sj,j);
- if(j>tm)
- break;
- else
- {
- strcat(string4,sj,sizeof(string4));
- strcat(string4,". ",sizeof(string4));
- }
- }
- fclose(fptr3);
- strcat(string4,"\nTo edit or add, enter automessage as [number] [message]. Do not separate [no.] and [message] by a dot, just separate [no.] and [message] by a space.\nFor deleting an automessage, just enter the number of automessage followed by a space, without any message (yes you have to insert the space).",sizeof(string4));
- ShowPlayerDialog(playerid, AUTOMSGS_DIALOG, DIALOG_STYLE_INPUT,"Auto Messages", string4, "Enter", "Cancel");
- }
- forward function_F2();
- public function_F2()
- {
- new File:fptr2=fopen("automsgs.txt",io_read);
- new ch[3];
- fread(fptr2,ch);
- new tm;
- sscanf(ch,"i",tm);
- if(gVar2>tm)
- gVar2=1;
- gVar2++;
- new i=1;
- new string5[MAX_STRING_SIZE];
- while(fread(fptr2,string5,sizeof(string5)))
- {
- i++;
- if(i==gVar2)
- break;
- }
- SendClientMessageToAll(-1,string5);
- fclose(fptr2);
- }
- public OnFilterScriptInit()
- {
- print("\n-------------------------------------------------");
- print(" Nicki's (deffo) automessage filter script loaded ");
- print("---------------------------------------------------\n");
- gVar2=1;
- SetTimer("function_F2", TIMEGAP*1000 , true);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/automsgs", cmdtext, true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- function_F1(playerid);
- return 1;
- }
- else
- return 0;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case AUTOMSGS_DIALOG:
- {
- if(response)
- {
- new string8[MAX_STRING_SIZE];
- new val;
- new tm;
- new string7[1600];
- new File:fptr4=fopen("automsgs.txt",io_read);
- sscanf(inputtext,"i",val);
- fread(fptr4,string8);
- sscanf(string8,"i",tm);
- if(!inputtext[2] || !inputtext[3])
- {
- if(tm<=2)
- {
- SendClientMessage(playerid,M_COLOR,">>Error: There should be atleast two automessages!");
- }
- else
- {
- if(val>tm)
- {
- SendClientMessage(playerid,M_COLOR,">>Error: Invalid number entered!");
- }
- else
- {
- tm--;
- valstr(string8,tm);
- strcat(string8,"\0",sizeof(string8));
- strcat(string8,"\n",sizeof(string8));
- strcat(string7,string8,sizeof(string7));
- new i=1;
- while(fread(fptr4,string8,sizeof(string8)))
- {
- if(i!=val)
- strcat(string7,string8,sizeof(string7));
- i++;
- }
- SendClientMessage(playerid,M_COLOR,">>Automessage was successfully deleted.");
- fclose(fptr4);
- new File:fptr5=fopen("automsgs.txt",io_write);
- fwrite(fptr5,string7);
- fclose(fptr5);
- }
- }
- }
- else
- {
- if(val>9)
- {
- return SendClientMessage(playerid,M_COLOR,">>Error: You can add only upto 9 automessages.");
- }
- else if(val>tm)
- {
- tm++;
- valstr(string8,tm);
- strcat(string8,"\0",sizeof(string8));
- strcat(string8,"\n",sizeof(string8));
- strcat(string7,string8,sizeof(string7));
- while(fread(fptr4,string8,sizeof(string8)))
- {
- strcat(string7,string8,sizeof(string7));
- }
- sscanf(inputtext,"{i}p<`>s[129]",string8);
- strcat(string7,string8,sizeof(string7));
- strcat(string7,"\n",sizeof(string7));
- SendClientMessage(playerid,M_COLOR,">>Automessage was successfully added.");
- }
- else
- {
- strcat(string7,string8,sizeof(string7));
- new i=1;
- while(fread(fptr4,string8,sizeof(string8)))
- {
- if(i==val)
- {
- sscanf(inputtext,"{i}p<`>s[129]",string8);
- strcat(string7,string8,sizeof(string7));
- strcat(string7,"\n",sizeof(string7));
- }
- else
- strcat(string7,string8,sizeof(string7));
- i++;
- }
- SendClientMessage(playerid,M_COLOR,">>Automessage was successfully edited.");
- }
- fclose(fptr4);
- new File:fptr5=fopen("automsgs.txt",io_write);
- fwrite(fptr5,string7);
- fclose(fptr5);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment