Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dynamic Update System
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <sscanf>
- // Dialogs //
- #define DIALOG_UPDATED 50
- #define DIALOG_UPDATE 51
- #define DIALOG_UE 52
- #define DIALOG_U 53
- // Colors //
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_RED 0xFF0000FF
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Dynamic Update System By Usman");
- print("--------------------------------------\n");
- if (!dini_Exists("updates.ini")){ dini_Create("updates.ini");}
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new updates = GetPVarInt(playerid, "UID");
- if(dialogid == DIALOG_UPDATE)
- {
- if(response)
- {
- if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_UPDATE, DIALOG_STYLE_INPUT, "adding update", "please write your update below", "Add", "Cancel");
- for(new x=1 ; x<560 ; x++)
- {
- new s[256];
- format(s, sizeof(s), "update%d", x);
- if(!dini_Isset("updates.ini", s))
- {
- new year, month, day;
- getdate(year, month, day);
- new utext[1024];
- format(utext, sizeof(utext), "%d/%d/%d", day, month, year);
- format(s, sizeof(s), "date%d", x);
- dini_Set("updates.ini", s, utext);
- format(utext, sizeof(utext), "%s", inputtext);
- format(s, sizeof(s), "update%d", x);
- dini_Set("updates.ini", s, utext);
- new dd = dini_Int("updates.ini", "MAX");
- dini_IntSet("updates.ini", "MAX", dd+1);
- format(s, sizeof(s), "Added update id %d. Your Update: '%s', and Date: %d/%d/%d.", x, inputtext, day, month, year);
- SendClientMessage(playerid, COLOR_YELLOW, s);
- break;
- }
- }
- return 1;
- }
- return 1;
- }
- if(dialogid == DIALOG_UE)
- {
- if(response)
- {
- if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_UE, DIALOG_STYLE_INPUT, "editing your update", "please write your update below", "Edit", "Cancel");
- new s[256];
- format(s, sizeof(s), "update%d", updates);
- if(dini_Isset("updates.ini", s))
- {
- new year, month, day;
- getdate(year, month, day);
- new utext[1024];
- format(utext, sizeof(utext), "%d/%d/%d", day, month, year, inputtext);
- format(s, sizeof(s), "date%d", updates);
- dini_Set("updates.ini", s, utext);
- format(s, sizeof(s), "update%d", updates);
- format(utext, sizeof(utext), "%s", inputtext);
- dini_Set("updates.ini", s, utext);
- format(s, sizeof(s), "Update editted '%s'", inputtext);
- SendClientMessage(playerid, COLOR_YELLOW, s);
- }
- else return SendClientMessage(playerid, COLOR_RED, "Error: Update Doesnt Exist!");
- return 1;
- }
- return 1;
- }
- return 1;
- }
- CMD:addupdate(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- ShowPlayerDialog(playerid, DIALOG_UPDATE, DIALOG_STYLE_INPUT, "adding update", "please write your update below", "Add", "Cancel");
- return 1;
- }
- CMD:editupdate(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- new updates;
- if(sscanf(params, "d", updates)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /editupdate [update id]");
- SetPVarInt(playerid, "UID", updates);
- ShowPlayerDialog(playerid, DIALOG_UE, DIALOG_STYLE_INPUT, "editing update", "Write your new update below", "Edit", "Cancel");
- return 1;
- }
- CMD:delupdate(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- new ud;
- if(sscanf(params, "d", ud)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /delupdate [updateid]");
- new dd = dini_Int("updates.ini", "MAX");
- if(ud < dd) return SendClientMessage(playerid, COLOR_RED, "Error: Update Doesn't Exist!");
- new tmp[256], h[256];
- format(tmp, sizeof(tmp), "update%d", ud);
- format(h, sizeof(h), "date%d", ud);
- dini_Unset("updates.ini", tmp);
- dini_Unset("updates.ini", h);
- dini_IntSet("updates.ini", "MAX", dd-1);
- new string[250];
- format(string, sizeof(string), "Update %d has removed.", ud);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- CMD:updates(playerid, params[])
- {
- new tmp[256], tmp4[512];
- new dd = dini_Int("updates.ini", "MAX");
- if (dd == 0) return SendClientMessage(playerid, COLOR_RED, "Currently There are no update.");
- new tmp3[512], h[256];
- for (new u = 1; u <= dd; u++)
- {
- format(tmp, 20, "update%d", u);
- format(h, sizeof(h), "date%d", u);
- format(tmp, sizeof(tmp), "%s", dini_Get("updates.ini", tmp));
- format(tmp3, sizeof(tmp3), "%s%s.\t%s\n", tmp3, tmp, dini_Get("updates.ini", h));
- }
- format(tmp4, sizeof(tmp4), "Updates\tDate Of Update\n%s", tmp3);
- ShowPlayerDialog(playerid, DIALOG_UPDATED, DIALOG_STYLE_TABLIST_HEADERS, "{FF0000}Server Name {FFFFFF}- Server Updates", tmp4, "Ok", "");
- return 1;
- }
- CMD:maxupdates(playerid, params[])
- {
- new str[256];
- if(!IsPlayerAdmin(playerid)) return 0;
- new dd = dini_Int("updates.ini", "MAX");
- format(str, sizeof(str), "Currently we have %d updates.", dd);
- SendClientMessage(playerid, COLOR_YELLOW, str);
- return 1;
- }
Add Comment
Please, Sign In to add comment