Jump to content
  • 0

help How to convert this points system to kafrapoints or cash points


lieneil

Question


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  39
  • Reputation:   0
  • Joined:  10/03/12
  • Last Seen:  

//====================================================================================
//Script Name: Vote For Points NPC Script for FluxCP
//SVN: Tested in rAthena r156513
//Developed By: JayPee Mateo
//Version: 1.0
//Requirement(s): FluxCP V4P Addon
//Description: This is a npc script for FluxCP Vote for points in order for the players
//to claim their vote points
//====================================================================================
royal_room3,80,136,5 script VoteForPoints 89,{
//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 For Points ]";

//Initialization of the Rewards
add_item(555,1,100,"Hello");
add_item(556,2,101,"Hello");
add_item(557,3,101,"Hello1");

//Script Start
mes .npcname$;
mes "Hi! Do you want to exchange your vote points?:";
switch(select("Yes, I want to exchange my points:See my points"))
{
 case 1:
 next;
  mes .npcname$;
  mes "Please choose a category:";
  set .@selected,select(makeCategory())-1;
 next;
  mes .npcname$;
  mes "Please the item you want:";
  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 "Item ID:"+.@ritemid;
  mes "Item Name: "+getitemname(.@ritemid);
  mes "Item Quantity: "+.@rquantity+" pc(s).";
  mes "Required Points: "+.@rpoints+" pt(s).";
  mes "\n";
  mes "Do you want to this item?";
  if(select("Yes:No")==1)
  {
set .@points,getPoints(getcharid(3));
if(.@points>=.@rpoints)
{
 next;
 mes .npcname$;  
 updatePoints(getcharid(3),.@rpoints);
 getitem .@ritemid,.@rquantity;
 mes "Here you go!. Thank you for voting. Don't forget to vote again. ";
}
else
 mes "Sorry, you do not have enough points for this item.";  
  }
  else
  {
next;
mes .npcname$;  
mes "Okay bye!";
  }  
  garbagecol();
 close;
 case 2:
  next;
  mes .npcname$;  
  set .@points,getPoints(getcharid(3));  
  mes "You currently have "+.@points+" pt(s).";
  garbagecol();
 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(strtolower(.@detail$) == strtolower("ItemID"))
  return @itemID[.@key];
 else if(strtolower(.@detail$) == strtolower("Quantity"))
  return @itemQ[.@key];
 else if(strtolower(.@detail$) == strtolower("Points"))
  return @points[.@key];
 else if(strtolower(.@detail$) == strtolower("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(strtolower(.@selectedCat$) == strtolower(@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;
}
}

please help me with this.. I'm having a hard time understanding how this script gives points.. well I kinda figured out how it give points but converting the points here makes me confused. well just want to ask how can i make this script converted to kafra points or cashpoints.. thanks and hope you will help me..

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

The script store your points with this code:

query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");

And loads your points with this code:

query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id="+.@account_id+" LIMIT 1",.@points);

Now, can you see where does the points get stored on your database?

Yes, it's stored as "cp_v4p_voters" points. :)

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2350
  • Joined:  10/28/11
  • Last Seen:  

since you want to convert the points....

something like this would be sufficient...

query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id="+.@account_id+" LIMIT 1",.@points);
query_sql("UPDATE `cp_v4p_voters` SET points=0 WHERE account_id='"+.@account_id+"'");
set #KAFRAPOINTS,#KAFRAPOINTS + .@points;
dispbottom "gained "+.@points+" kafrapoints.";

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  39
  • Reputation:   0
  • Joined:  10/03/12
  • Last Seen:  

thanks for your concern sir emistry but this does not work.. when i click to my cash shop npc the points wont be counted... help me please some one that has successfully done this by the way it's sir jaypee's vote points npc.. thanks..

help please.. somebody who know how to deal with this.. thanks..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  39
  • Reputation:   0
  • Joined:  10/03/12
  • Last Seen:  

someone please help me with this..

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Replace

switch( select( "Yes, I want to exchange my points:See my points" ) ) {

by

switch( select( "Yes, I want to exchange my points", "See my points", "Exchange points to Cashpoints" ) ) {

and

  	 case 2:
           next;

           mes .npcname$;  
           set .@points, getPoints( getcharid(3) );  
           mes "You currently have "+ .@points +" pt(s).";
           garbagecol();
           close;
   }

to

  	 case 2:
           next;

           mes .npcname$;  
           set .@points, getPoints( getcharid(3) );  
           mes "You currently have "+ .@points +" pt(s).";
           garbagecol();
           close;
       case 3:
           next;

           set .@points, getPoints( getcharid(3) );

           mes .npcname$;
           if( !.@points ) {
               mes "Sorry you don't have points.";
               close;
           }
           mes "You will exchange "+ .@points +" for "+ .@points +" Cashpoints.";
           mes "Proceed ?";
           if( select( "Yes", "No" ) -1 ) close;

           query_sql("UPDATE `cp_v4p_voters` SET points=0 WHERE account_id='"+ getcharid(3) +"'");
           set #CASHPOINTS, #CASHPOINTS + .@points;
           dispbottom "Gained: "+.@points+" Cashpoints.";
           close;    
   }

>> Add a menu to convert points to Cashpoints.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...