Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- prontera,169,172,2 script Vote por Pontos 563,{
- //Function Prototypes
- function garbagecol;//Garbage collection for the Character variables
- garbagecol();
- function add_item; //Syntanx: add_item(ItemID,QUANTITY,POINTS,CATEGORY);
- function makeCategory;//This will return a list of the categories
- function getItemsByCat;//This will return the list of items associated to the particular category
- function getItemDetails;//This will return the details of the item
- function getPoints;//This will return the points of the player stored in the database
- function updatePoints;//This will updates the points of the player stored in the database
- //NPC Name
- set .npcname$,"» Vote Points ";
- //Initialization of the Rewards
- add_item(566,1,90,"» Equipes Points");
- add_item(6153,1,150,"» Equipes Points");
- add_item(5423,1,800,"» Equipes Points");
- add_item(5377,1,900,"» Equipes Points");
- add_item(5518,1,1500,"» Equipes Points");
- add_item(12915,3,10,"» Equipes Points");
- add_item(12918,3,10,"» Equipes Points");
- add_item(5660,1,50,"» Equipes Points");
- add_item(5519,1,50,"» Equipes Points");
- add_item(5495,1,190,"» Equipes Points");
- add_item(5361,1,60,"» Equipes Points");
- add_item(2115,1,40,"» Equipes Points");
- add_item(2524,1,40,"» Equipes Points");
- add_item(2421,1,40,"» Equipes Points");
- add_item(2357,1,40,"» Equipes Points");
- add_item(5225,1,100,"» Equipes Points");
- //Script Start
- mes .npcname$;
- mes "Oi ^5566FF"+strcharinfo(0)+"^000000! Você quer trocar os seus pontos de voto?";
- switch(select("» Sim, eu quero trocar meus pontos:» Ver meus pontos:» Trocar Por Vip"))
- {
- case 1:
- next;
- mes .npcname$;
- mes "Por favor selecione uma categoria:";
- set .@selected,select(makeCategory())-1;
- next;
- mes .npcname$;
- mes "Por favor selecione uma categoria:";
- set .@selected,select(getItemsByCat(@listCat$[.@selected]))-1;
- next;
- mes .npcname$;
- set .@rItemID,getItemDetails(@itemKeys[.@selected],"ItemID");
- set .@rquantity,getItemDetails(@itemKeys[.@selected],"quantity");
- set .@rpoints,getItemDetails(@itemKeys[.@selected],"points");
- mes "ID:"+.@rItemID;
- mes "Nome: "+getitemname(.@rItemID);
- mes "Quantidade: "+.@rquantity+" pc(s).";
- mes "Pontos Requeridos: "+.@rpoints+" pt(s).";
- mes "\n";
- mes "Voce quer este item?";
- if(select("Sim:Nao")==1)
- {
- set .@points,getPoints(getcharid(3));
- if(.@points>=.@rpoints)
- {
- next;
- mes .npcname$;
- updatePoints(getcharid(3),.@rpoints);
- getitem .@rItemID,.@rquantity;
- mes "Vamos la entao. Obrigado por votar. Nao se esqueca de votar novamente =D";
- }
- else
- mes "Desculpe, voce nao tem pontos suficientes para este item.";
- }
- else
- {
- next;
- mes .npcname$;
- mes "Okay xau!";
- }
- garbagecol();
- close;
- case 2:
- next;
- mes .npcname$;
- set .@points,getPoints(getcharid(3));
- mes "Voce tem "+.@points+" pt(s).";
- garbagecol();
- close;
- case 3:
- goto escape;
- }
- end;
- escape:
- next;
- mes .npcname$;
- mes "Posso lhe dar um dia VIP por 3 pontos, tudo bem?";
- set .@points,getPoints(getcharid(3));
- mes "Voce tem "+.@points+" pt(s).";
- switch(select("Sim","Não")){
- case 1:
- if(.@points<3){
- mes "Você não tem pontos suficientes!";
- close;
- }
- mes "Pronto!";
- set .@account_id,getcharid(3);
- set .@usedPoints,3;
- set $nivelVip, 1;
- set $diasVip, 1;
- set $verificaVip, 1;
- query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");
- if (getgroupid() == 0){
- query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";
- }else{
- query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);
- }
- garbagecol();
- close2;
- message strcharinfo(0),"Pontos adicionados";
- end;
- case 2:
- close;
- }
- end;
- //Functions Bodies
- function updatePoints {
- set .@account_id,getarg(0);
- set .@usedPoints,getarg(1);
- query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");
- return;
- }
- function getPoints {
- set .@account_id,getarg(0);
- query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id="+.@account_id+" LIMIT 1",.@points);
- if(getarraysize(.@points)==0)
- return 0;
- return .@points[0];
- }
- function getItemDetails {
- set .@key,getarg(0); //Key
- set .@detail$,getarg(1); //What details to return such as ItemID, Points, Quantity, Category
- if(.@detail$ == "ItemID")
- return @ItemID[.@key];
- else if((.@detail$ == "Quantity") || (.@detail$ == "quantity"))
- return @itemQ[.@key];
- else if((.@detail$ == "Points") || (.@detail$ == "points"))
- return @points[.@key];
- else if((.@detail$ == "Category") || (.@detail$ == "category"))
- return @category$[.@key];
- }
- function getItemsByCat {
- set .@selectedCat$,getarg(0);
- set .@make_string$,"";
- set .@x,0;
- for(set .@i,0; .@i<getarraysize(@category$); set .@i,.@i+1)
- {
- if(.@selectedCat$ == @category$[.@i]);
- {
- setarray @itemKeys[.@x],.@i;
- if(.@make_string$ == "")
- set .@make_string$,getitemname(@ItemID[.@i]);
- else
- set .@make_string$,.@make_string$+":"+getitemname(@ItemID[.@i]);
- set .@x,.@x+1;
- }
- }
- return .@make_string$;
- }
- function makeCategory {
- set .@make_string$,"";
- for(set .@i,0; .@i<getarraysize(@category$); set .@i,.@i+1)
- {
- if(.@make_string$ == "")
- {
- setarray @listCat$[getarraysize(@listCat$)],@category$[.@i];
- set .@make_string$,@category$[.@i];
- }
- else
- {
- if(compare(.@make_string$,@category$[.@i])==0)
- {
- setarray @listCat$[getarraysize(@listCat$)],@category$[.@i];
- set .@make_string$,.@make_string$+":"+@category$[.@i];
- }
- }
- }
- return .@make_string$;
- }
- function add_item
- {
- set .@ItemID,getarg(0,-1); //IteID
- set .@itemQ,getarg(1,-1); //Item Quantity
- set .@points,getarg(2,-1);
- set .@cat$,getarg(3,"Uncategorized"); //Category
- if(.@ItemID == -1)
- {
- debugmes "Invalid Item ID. Script not completely loaded.";
- end;
- }
- else if(.@itemQ == -1)
- {
- debugmes "Invalid Item Quantity. Script not completely loaded.";
- end;
- }
- else if(.@points == -1)
- {
- debugmes "Points assignment error. Script not completely loaded.";
- end;
- }
- set .@key,getarraysize(@ItemID);
- setarray @ItemID[.@key],.@ItemID;
- setarray @itemQ[.@key],.@itemQ;
- setarray @points[.@key],.@points;
- setarray @category$[.@key],.@cat$;
- return 1; //return 1 as success
- }
- function garbagecol{
- deletearray @ItemID[0],128;
- deletearray @itemQ[0],128;
- deletearray @points[0],128;
- deletearray @category$[0],128;
- deletearray @listCat$[0],128;
- deletearray @itemKeys[0],128;
- return;
- }
- //OnInit:
- //waitingroom " #voteporPONTO's ",0;
- //end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement