Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dieses Coupon-System wurde von CoKeZ geschrieben.
- (C)CoKeZ - 2012
- */
- #include <a_samp>
- #include <dini>
- #define BLOCK_INTERVAL 3 // Sperrzeit nach mehrmaliger Falscheingabe des Codes (in Minuten)
- //COLORS
- #define COLOR_RED 0xFF0000FF
- #define COLOR_LYELLOW 0xFAF0CEFF
- #define COLOR_GREEN 0x33AA33AA
- //DIALOGE
- #define DIALOG_COUPONMENU 8123
- #define DIALOG_MONEY 8124
- #define DIALOG_SCORE 8125
- #define DIALOG_WANTEDS 8126
- #define DIALOG_WEAPONTYPE 8127
- #define DIALOG_WEAPONAMMO 8128
- #define DIALOG_ARMOUR 8129
- #define DIALOG_SKIN 8130
- #define DIALOG_CREATECOUPON 8131
- #define DIALOG_COUPON 8132
- forward Block(playerid);
- enum CouponEnum
- {
- Money,
- Score,
- Wanteds,
- Weapontype,
- Weaponammo,
- Armour,
- Skin
- };
- new Coupon[MAX_PLAYERS][CouponEnum];
- new CouponBlock[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Coupon-System by CoKeZ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- ResetCouponSettings(playerid);
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp("/createcoupon", cmdtext, true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- }
- else SendClientMessage(playerid, COLOR_RED, "Du bist kein Admin.");
- return 1;
- }
- if(strcmp("/coupon", cmdtext, true) == 0)
- {
- if(CouponBlock[playerid] != 2)
- {
- ShowPlayerDialog(playerid, DIALOG_COUPON, DIALOG_STYLE_INPUT, "Coupon einlösen", "Gib den Couponcode ein:", "Einlösen", "Abbrechen");
- }
- else SendClientMessage(playerid, COLOR_RED, "Du hast eine Couponsperre.");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_COUPONMENU)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- ShowPlayerDialog(playerid, DIALOG_MONEY, DIALOG_STYLE_INPUT, "Geld hinzufügen", "Wie viel Geld möchtest du hinzufügen?", "Hinzufügen", "Zurück");
- }
- case 1:
- {
- ShowPlayerDialog(playerid, DIALOG_SCORE, DIALOG_STYLE_INPUT, "Score hinzufügen", "Wie viel Score möchtest du hinzufügen?", "Hinzufügen", "Zurück");
- }
- case 2:
- {
- ShowPlayerDialog(playerid, DIALOG_WANTEDS, DIALOG_STYLE_INPUT, "Wanteds hinzufügen", "Wie viele Wanteds sollen hinzugefügt werden?", "Hinzufügen", "Zurück");
- }
- case 3:
- {
- ShowPlayerDialog(playerid, DIALOG_WEAPONTYPE, DIALOG_STYLE_INPUT, "Waffentype auswählen", "Welche Waffe soll hinzugefügt werden? (ID)", "Weiter", "Zurück");
- }
- case 4:
- {
- ShowPlayerDialog(playerid, DIALOG_ARMOUR, DIALOG_STYLE_INPUT, "Rüstung hinzufügen", "Wie viel Rüstung soll hinzugefügt werden?", "Hinzufügen", "Zurück");
- }
- case 5:
- {
- ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, "Skin hinzufügen", "Welcher Skin soll hinzugefügt werden?", "Hinzufügen", "Zurück");
- }
- case 6:
- {
- ShowPlayerDialog(playerid, DIALOG_CREATECOUPON, DIALOG_STYLE_INPUT, "Couponcode auswählen", "Wie soll der Couponcode lauten? (mind. 4 Zeichen)\n\nHinweis: Sollte kein Couponcode eingetragen werden, so wird ein zufälliger generiert.", "Erstellen", "Zurück");
- }
- }
- }
- else ResetCouponSettings(playerid);
- return 1;
- }
- if(dialogid == DIALOG_MONEY)
- {
- if(response)
- {
- if(strval(inputtext) == 0) return ShowPlayerDialog(playerid, DIALOG_MONEY, DIALOG_STYLE_INPUT, "Geld hinzufügen", "Wie viel Geld möchtest du hinzufügen?", "Hinzufügen", "Zurück");
- new msg[64];
- format(msg, sizeof(msg), "Dem Coupon wurden %i$ hinzugefügt.", strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Money] = strval(inputtext);
- }
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_SCORE)
- {
- if(response)
- {
- if(strval(inputtext) == 0) return ShowPlayerDialog(playerid, DIALOG_SCORE, DIALOG_STYLE_INPUT, "Score hinzufügen", "Wie viel Score möchtest du hinzufügen?", "Hinzufügen", "Zurück");
- new msg[64];
- format(msg, sizeof(msg), "Dem Coupon wurde %i Score hinzugefügt.", strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Score] = strval(inputtext);
- }
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_WANTEDS)
- {
- if(response)
- {
- if(strval(inputtext) == 0) return ShowPlayerDialog(playerid, DIALOG_WANTEDS, DIALOG_STYLE_INPUT, "Wanteds hinzufügen", "Wie viele Wanteds sollen hinzugefügt werden?", "Hinzufügen", "Zurück");
- new msg[64];
- if(strval(inputtext) == 1) format(msg, sizeof(msg), "Dem Coupon wurde 1 Wanted hinzugefügt.");
- else format(msg, sizeof(msg), "Dem Coupon wurden %i Wanteds hinzugefügt.", strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Wanteds] = strval(inputtext);
- }
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_WEAPONTYPE)
- {
- if(response)
- {
- new weaponid = strval(inputtext);
- if(weaponid > 0 && weaponid <= 46)
- {
- Coupon[playerid][Weapontype] = weaponid;
- ShowPlayerDialog(playerid, DIALOG_WEAPONAMMO, DIALOG_STYLE_INPUT, "Munition auswählen", "Wie viel Munition soll der Waffe hinzugefügt werden?", "Hinzufügen", "Zurück");
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "Ungültige Waffen ID.");
- ShowPlayerDialog(playerid, DIALOG_WEAPONTYPE, DIALOG_STYLE_INPUT, "Waffentype auswählen", "Welche Waffe soll hinzugefügt werden? (ID)", "Weiter", "Zurück");
- }
- }
- else
- {
- Coupon[playerid][Weapontype] = 0;
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- }
- return 1;
- }
- if(dialogid == DIALOG_WEAPONAMMO)
- {
- if(response)
- {
- if(strval(inputtext) == 0) return ShowPlayerDialog(playerid, DIALOG_WEAPONAMMO, DIALOG_STYLE_INPUT, "Munition auswählen", "Wie viel Munition soll der Waffe hinzugefügt werden?", "Hinzufügen", "Zurück");
- new msg[64];
- new weaponname[32];
- GetWeaponName(Coupon[playerid][Weapontype], weaponname, sizeof(weaponname));
- format(msg, sizeof(msg), "Dem Coupon wurde die Waffe %s mit %i Munition hinzugefügt,", weaponname, strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Weaponammo] = strval(inputtext);
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- }
- else ShowPlayerDialog(playerid, DIALOG_WEAPONTYPE, DIALOG_STYLE_INPUT, "Waffentype auswählen", "Welche Waffe soll hinzugefügt werden? (ID)", "Weiter", "Zurück");
- return 1;
- }
- if(dialogid == DIALOG_ARMOUR)
- {
- if(response)
- {
- if(strval(inputtext) == 0)
- {
- ShowPlayerDialog(playerid, DIALOG_ARMOUR, DIALOG_STYLE_INPUT, "Rüstung hinzufügen", "Wie viel Rüstung soll hinzugefügt werden?", "Hinzufügen", "Zurück");
- return 1;
- }
- else
- {
- new msg[64];
- format(msg, sizeof(msg), "Dem Coupon wurde %i Rüstung hinzugefügt.", strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Armour] = strval(inputtext);
- }
- }
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_SKIN)
- {
- if(response)
- {
- if(strval(inputtext) < 0 || strval(inputtext) > 299)
- {
- SendClientMessage(playerid, COLOR_RED, "Ungültige ID.");
- ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, "Skin hinzufügen", "Welcher Skin soll hinzugefügt werden?", "Hinzufügen", "Zurück");
- return 1;
- }
- else
- {
- new msg[64];
- format(msg, sizeof(msg), "Dem Coupon wurde der Skin %i hinzugefügt.", strval(inputtext));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- Coupon[playerid][Skin] = strval(inputtext)+1;
- }
- }
- ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_CREATECOUPON)
- {
- if(response)
- {
- if(strlen(inputtext) != 0 && strlen(inputtext) < 4)
- {
- SendClientMessage(playerid, COLOR_RED, "Der Code muss mindestens 4 Zeichen lang sein.");
- ShowPlayerDialog(playerid, DIALOG_CREATECOUPON, DIALOG_STYLE_INPUT, "Couponcode auswählen", "Wie soll der Couponcode lauten? (mind. 4 Zeichen)\n\nHinweis: Sollte kein Couponcode eingetragen werden, so wird ein zufälliger generiert.", "Erstellen", "Zurück");
- return 1;
- }
- else
- {
- new coupondata[64];
- new couponname[16];
- new msg[64];
- if(strlen(inputtext) == 0)
- {
- couponname = GenerateCode();
- format(coupondata, sizeof(couponname), "%s.txt", couponname);
- while(fexist(coupondata))
- {
- couponname = GenerateCode();
- format(coupondata, sizeof(couponname), "%s.txt", couponname);
- }
- }
- else
- {
- format(couponname, sizeof(couponname), inputtext);
- format(coupondata, sizeof(couponname), "%s.txt", couponname);
- }
- dini_Create(coupondata);
- dini_IntSet(coupondata, "Geld", Coupon[playerid][Money]);
- dini_IntSet(coupondata, "Score", Coupon[playerid][Score]);
- dini_IntSet(coupondata, "Wanteds", Coupon[playerid][Wanteds]);
- dini_IntSet(coupondata, "Waffe", Coupon[playerid][Weapontype]);
- dini_IntSet(coupondata, "Munition", Coupon[playerid][Weaponammo]);
- dini_IntSet(coupondata, "Rüstung", Coupon[playerid][Armour]);
- dini_IntSet(coupondata, "Skin", Coupon[playerid][Skin]);
- format(msg, sizeof(msg), "Der Coupon %s wurde erfolgreich erstellt.", couponname);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- ResetCouponSettings(playerid);
- }
- }
- else ShowPlayerDialog(playerid, DIALOG_COUPONMENU, DIALOG_STYLE_LIST, "Coupon erstellen", "Geld hinzufügen\nScore hinzufügen\nWanteds hinzufügen\nWaffe hinzufügen\nRüstung hinzufügen\nSkin hinzufügen\nCoupon erstellen", "Auswählen", "Abbrechen");
- return 1;
- }
- if(dialogid == DIALOG_COUPON)
- {
- if(response)
- {
- new coupondata[16];
- format(coupondata, sizeof(coupondata), "%s.txt", inputtext);
- if(fexist(coupondata))
- {
- new msg[128];
- new score = dini_Int(coupondata, "Score");
- new money = dini_Int(coupondata, "Geld");
- new wanteds = dini_Int(coupondata, "Wanteds");
- new weapontype = dini_Int(coupondata, "Waffe");
- new weaponammo = dini_Int(coupondata, "Munition");
- new Float:armour = dini_Int(coupondata, "Rüstung");
- new skin = dini_Int(coupondata, "Skin");
- format(msg, sizeof(msg), "-------- Coupon %s wurde eingelöst --------", inputtext);
- SendClientMessage(playerid, COLOR_GREEN, msg);
- if(score != 0)
- {
- SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
- format(msg, sizeof(msg), "Du hast %i Score erhalten", score);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- if(money != 0)
- {
- GivePlayerMoney(playerid, money);
- format(msg, sizeof(msg), "Du hast %i$ erhalten.", money);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- if(wanteds != 0)
- {
- SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+wanteds);
- if(wanteds == 1) format(msg, sizeof(msg), "Du hast 1 Wanted erhalten.");
- else format(msg, sizeof(msg), "Du hast %i Wanteds erhalten.", wanteds);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- if(weapontype != 0)
- {
- new weaponname[32];
- GivePlayerWeapon(playerid, weapontype, weaponammo);
- GetWeaponName(weapontype, weaponname, sizeof(weaponname));
- format(msg, sizeof(msg), "Du hast die Waffe %s mit %i Munition erhalten.", weaponname, weaponammo);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- if(armour != 0)
- {
- new Float:curArmour;
- GetPlayerArmour(playerid, curArmour);
- SetPlayerArmour(playerid, curArmour+armour);
- format(msg, sizeof(msg), "Du hast %i Rüstung erhalten.", floatround(armour));
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- if(skin != 0)
- {
- SetPlayerSkin(playerid, skin-1);
- format(msg, sizeof(msg), "Du hast den Skin %i erhalten.", skin-1);
- SendClientMessage(playerid, COLOR_LYELLOW, msg);
- }
- CouponBlock[playerid] = 0;
- fremove(coupondata);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "Ungültiger Coupon.");
- CouponBlock[playerid]++;
- if(CouponBlock[playerid] == 3)
- {
- SendClientMessage(playerid, COLOR_RED, "Du hast eine Couponsperre erhalten.");
- SetTimerEx("Block", 60000*BLOCK_INTERVAL, false, "i", playerid);
- }
- }
- }
- return 1;
- }
- return 1;
- }
- stock ResetCouponSettings(playerid)
- {
- Coupon[playerid][Money] = 0;
- Coupon[playerid][Score] = 0;
- Coupon[playerid][Wanteds] = 0;
- Coupon[playerid][Weapontype] = 0;
- Coupon[playerid][Weaponammo] = 0;
- Coupon[playerid][Armour] = 0;
- Coupon[playerid][Skin] = 0;
- }
- stock GenerateCode()
- {
- new zeichen[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
- new length = random(3) + 5;
- new index;
- new code[10];
- for(new i = 0; i < length; i++)
- {
- index = random(sizeof(zeichen)-1);
- code[i] = zeichen[index];
- }
- return code;
- }
- public Block(playerid)
- {
- CouponBlock[playerid] = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement