Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Server rating script
- By Stream
- Do not re-relase or claim this script as your own.
- */
- #include <a_samp>
- #define GREEN 0x21DD00FF
- #define RED 0xE60000FF
- //---------- Defines - set to true to enable, to false to disable ----------
- #define CONNECTMSG true //Will display a message on connect so people get informed about /rate
- #define FILENAME "ratings.txt" //NEEDED! The file where you´ll find all ratings listed.
- #define DIALOG 2432 //Dialog-ID used, edit if you experience problems with your dialogs
- //---------- End of defines - editing below at your own risk ----------
- new rating1[MAX_PLAYERS];
- new rating2[MAX_PLAYERS];
- new rating3[MAX_PLAYERS];
- new rating4[MAX_PLAYERS];
- new rating5[MAX_PLAYERS];
- forward CalculateSummary(playerid);
- public OnPlayerConnect(playerid)
- {
- #if defined CONNECTMSG
- SendClientMessage(playerid,RED,"You can rate this server. To do so, use /rate.");
- #endif
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/rate", true))
- {
- ShowPlayerDialog(playerid,DIALOG,DIALOG_STYLE_MSGBOX,"Server rating system","This is the server rating system.\nIf you want to rate this server,\npress Okay, else press Cancel.","Okay","Cancel");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG)
- {
- if(response) ShowPlayerDialog(playerid,DIALOG+1,DIALOG_STYLE_LIST,"Rate the SCRIPT FEATURES.","1 (Worst)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Best)","Rate","Cancel");
- return 1;
- }
- if(dialogid == DIALOG+1)
- {
- if(response)
- {
- rating1[playerid] = listitem+1;
- ShowPlayerDialog(playerid,DIALOG+2,DIALOG_STYLE_LIST,"Rate the BUG APPEARANCE.","1 (Much)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (None)","Rate","Cancel");
- return 1;
- }
- }
- if(dialogid == DIALOG+2)
- {
- if(response)
- {
- rating2[playerid] = listitem+1;
- ShowPlayerDialog(playerid,DIALOG+3,DIALOG_STYLE_LIST,"Rate the ADMIN STAFF.","1 (Worst)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Best)","Rate","Cancel");
- return 1;
- }
- }
- if(dialogid == DIALOG+3)
- {
- if(response)
- {
- rating3[playerid] = listitem+1;
- ShowPlayerDialog(playerid,DIALOG+4,DIALOG_STYLE_LIST,"Rate the PLAYERS.","1 (Bad)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Nice)","Rate","Cancel");
- return 1;
- }
- }
- if(dialogid == DIALOG+4)
- {
- if(response)
- {
- rating4[playerid] = listitem+1;
- ShowPlayerDialog(playerid,DIALOG+5,DIALOG_STYLE_LIST,"Rate the FUN.","1 (Boring)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Fun)","Rate","Cancel");
- return 1;
- }
- }
- if(dialogid == DIALOG+5)
- {
- if(response)
- {
- rating5[playerid] = listitem+1;
- CalculateSummary(playerid);
- return 1;
- }
- }
- return 0;
- }
- public CalculateSummary(playerid)
- {
- new string[140],string2[140],pname[24];
- GetPlayerName(playerid,pname,sizeof(pname));
- new string3[140];
- new bool:allowed = true;
- new File:log2 = fopen(FILENAME,io_append);
- while(fread(log2, string3))
- {
- if(strcmp(string3,pname) == 0) allowed = false;
- }
- fclose(log2);
- if(allowed == true)
- {
- new average;
- average = ((rating1[playerid]+rating2[playerid]+rating3[playerid]+rating4[playerid]+rating5[playerid])/5);
- format(string,sizeof(string),"%s rated the server with %d average. [Script: %d | Bugs: %d | Staff: %d | Players: %d | Fun: %d]",pname,average,rating1[playerid],rating2[playerid],rating3[playerid],rating4[playerid],rating5[playerid]);
- format(string2,sizeof(string2),"%s rated the server with %d average. [Script: %d | Bugs: %d | Staff: %d | Players: %d | Fun: %d]\n",pname,average,rating1[playerid],rating2[playerid],rating3[playerid],rating4[playerid],rating5[playerid]);
- SendClientMessageToAll(GREEN,string);
- new File:log = fopen(FILENAME,io_append);
- fwrite(log, string2);
- fclose(log);
- ShowPlayerDialog(playerid,DIALOG+10,DIALOG_STYLE_MSGBOX,"Server rating system","Thanks for rating!","Close","Close");
- }
- else ShowPlayerDialog(playerid,DIALOG+10,DIALOG_STYLE_MSGBOX,"Server rating system","We have already received \na rating from you.","Close","Close");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement