Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== Athena Script =======================================================
- //= Event Ticket Handler NPC
- //= Purpose: It passes out Event Ticket(s) to specific
- //= players through GM input.
- //= Players can talk to NPC and retrieve them easily.
- //===== By ==================================================================
- //= LuminousRO Admin
- //===== Version =============================================================
- //= 1.0 - Might contain bug
- //= 1.1 - Fixed bug: Adding when the table has user in it but 0 tickets
- //= 1.2a - Added deduction function in case GMs give extra
- //= 1.2b - Added remove from database if there's nothing to deduct from
- //= 1.3 - Added set functions to set name, item to be rewarded, and GM level
- //- 1.4 - Changed it so that it can also give it to players when offline
- //===========================================================================
- prontera,152,188,6 script Event Ticket Girl 719,{
- set @name$,"Event Ticket Girl";
- set @itemid,6116;
- set @gmlvl,20; // Set
- if (getgmlevel() >= @gmlvl) goto L_GM;
- L_START:
- mes "["+@name$+"]";
- mes "Hellow what would you like to do today?";
- next;
- menu "More info",-,"Make a claim",L_CHECK,"Cancel",L_CLOSE;
- L_INFO:
- mes "["+@name$+"]";
- mes "GMs randomly host fun events";
- mes "and to make the event worth while,";
- mes "we reward the winner with Event";
- mes "Tickets so they could be exchanged";
- mes "for Event Items";
- next;
- menu "Make a claim",L_CHECK,"Cancel",L_CLOSE;
- L_CHECK:
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+getcharid(3), @amount$;
- query_sql "SELECT '"+@amount$+"' > 0", @enough;
- if(!@enough) {
- mes "["+@name$+"]";
- mes "Sorry but you must first participate in an Event to get Event Tickets";
- mes "But if you already did and still don't have any, please PM the GM who hosted the Event";
- mes "Thank you.";
- close;
- }
- L_CLAIM:
- mes "["+@name$+"]";
- mes "You have "+@amount$+" Event Ticket(s)!";
- mes "What would you like to claim them?";
- next;
- menu "Yes",L_CLAIMITEM,"No",L_Close;
- L_CLAIMITEM:
- mes "["+@name$+"]";
- mes "Here you go!";
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+getcharid(3), @amount$;
- getitem @itemid,@amount$;
- query_sql "UPDATE `event_tickets` SET `amount` = '0' WHERE `account_id` = "+getcharid(3);
- close;
- L_GM:
- mes "[GM Menu]";
- mes "Hello GM!";
- mes "What would you like to do?";
- next;
- menu "Add/Remove Event Tickets",L_GM2,"Test Script",L_START,"Nothing",L_CLOSE;
- L_GM2:
- menu "Give Event Tickets",L_TICKET,"Deduct Event Tickets",L_REMOVE,"Return to main menu",L_GM;
- L_TICKET:
- mes "[GM Menu]";
- mes "Please enter the player's name:";
- input @winner$;
- query_sql "SELECT `account_id` FROM `char` WHERE `name` = '"+@winner$+"'", @aid;
- set @wonBefore$, "";
- if(@aid==0)
- {
- goto L_NONE;
- }
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @wonBefore$;
- query_sql "SELECT '"+@wonBefore$+"' > 0", @wonBefore;
- switch(@wonBefore) {
- case 0:
- mes @winner$+" has 0 Event Tickets.";
- break;
- case 1:
- mes @winner$+" has "+@wonBefore$+" Event Tickets already.";
- break;
- }
- next;
- mes "[GM Menu]";
- mes "Please enter the amount of tickets to give to "+@winner$;
- input @ticketAmount$;
- query_sql "SELECT '"+escape_sql(@ticketAmount$)+"' > 0", @valid;
- if(!@valid)
- {
- next;
- goto L_ZERO;
- }
- next;
- mes "[GM Menu]";
- mes "You have specified that "+@winner$+" has won "+@ticketAmount$+" Event Ticket(s).";
- mes "Would you like to continue?";
- next;
- menu "No",L_GM,"Yes",-;
- set @boolean$,0;
- query_sql "SELECT `account_id` FROM `event_tickets` WHERE `account_id` = "+@aid, @boolean$;
- query_sql "SELECT '"+@boolean$+"' > 0", @boolean;
- if (@boolean != 0)
- {
- set @boolean,1;
- }
- else
- {
- set @boolean,0;
- }
- switch(@boolean) {
- case 0:
- query_sql "INSERT INTO `event_tickets` VALUES ("+@aid+", '"+@ticketAmount$+"')";
- break;
- case 1:
- query_sql "UPDATE `event_tickets` SET `amount` = `amount` + "+@ticketAmount$+" WHERE `account_id` = "+@aid;
- break;
- }
- logmes "Credited "+@winner$+" with "+@ticketAmount$ + " Event Ticket(s) by GM " +getcharid(3);
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @currentAmount$;
- mes "[GM Menu]";
- mes "Event Ticket(s) added successfully!";
- mes @winner$+" has a total of "+@currentAmount$+ " Event Ticket(s).";
- close;
- L_ZERO:
- mes "[GM Menu]";
- mes "You can't have 0 as an amount!";
- next;
- goto L_GM;
- L_NONE:
- mes "[GM Menu]";
- mes "Character name "+@winner$+" does not exist.";
- next;
- goto L_GM;
- L_REMOVE:
- mes "[GM Menu]";
- mes "Please enter the players's name:";
- input @winner$;
- set @aid, getcharid(3,@winner$);
- if(@aid==0)
- {
- next;
- goto L_NONE;
- }
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @wonBefore$;
- query_sql "SELECT '"+@wonBefore$+"' > 0", @wonBefore;
- next;
- mes "[GM Menu]";
- if(!@wonBefore) {
- query_sql "DELETE FROM `event_tickets` WHERE `account_id` = "+@aid;
- logmes "Deleted "+@winner$+" from Event Tickets database by GM " +getcharid(3);
- mes @winner$+" has no Event Tickets and has been deleted from the Event Tickets database.";
- } else {
- mes @winner$+" has "+@wonBefore$+" Event Ticket(s).";
- next;
- switch(select("Deduct an amount from "+@winner$,"Return to main menu")){
- mes "[GM Menu]";
- case 1:
- mes "Please enter the amount "+@winner$+" is to be deducted by:";
- input @deduct$;
- query_sql "SELECT '"+escape_sql(@deduct$)+"' > 0", @valid;
- if(!@valid)
- {
- next;
- goto L_ZERO;
- }
- mes "You have specified that "+@winner$+" is to be deducted by "+@deduct$+".";
- mes "Would you like to continue?";
- next;
- menu "No",L_GM,"Yes",-;
- query_sql "UPDATE `event_tickets` SET `amount` = `amount` - "+@deduct$+" WHERE `account_id` = "+@aid;
- query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @afterdeduct$;
- logmes "Deducted "+@deduct$+" from "+@winner$ + " Event Ticket(s) by GM " +getcharid(3);
- mes "[GM Menu]";
- mes "Event Ticket(s) deducted successfully!";
- mes @winner$+" has a total of "+@afterdeduct$+" Event Ticket(s)";
- break;
- case 2:
- next;
- goto L_GM;
- }
- }
- close;
- L_CLOSE:
- close;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement