Jump to content
  • 0

Vote for points, exchange points for cash


Kido

Question


  • Group:  Members
  • Topic Count:  127
  • Topics Per Day:  0.03
  • Content Count:  1445
  • Reputation:   163
  • Joined:  08/17/13
  • Last Seen:  

Hello, just installed the vote for points (version 1.0) on my fluxcp (i was not sure if post this on website support or here on script support) and i want to make the vote points exchangeable for cash points, 1 vote = 1 cash point, i don't know at all how to it, thanks in advance for the help!

my scirpt

//====================================================================================
//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
//====================================================================================

turbo_room,106,116,4	script	Vote for Cash Points	906,{

//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$,"[ Vots ]";
	
//Initialization of the Rewards
add_item(673,100,1,"Bronze Coin"); //<<<---- that for 1 cash point 


//Script Start	
	mes .npcname$;
	mes "Hola ¿te gustaria cambiar tus puntos de votacion?:";
	switch(select("Si, quiero cambiar mis puntos de votacion:Quiero ver mis puntos"))
	{
		case 1:
		next;
			mes .npcname$;
			mes "Por favor selecciona una categoria:";
			set .@selected,select(makeCategory())-1;
		next;
			mes .npcname$;
			mes "Selecciona el Objeto que deseas:";
			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 "¿Quieres este objeto?";
			if(select("Si por favor:No gracias")==1)
			{
				set .@points,getPoints(getcharid(3));
				if(.@points>=.@rpoints)
				{
					next;
					mes .npcname$;			
					updatePoints(getcharid(3),.@rpoints);
					getitem .@ritemid,.@rquantity;
					mes "Aqui tienes!. Gracias por votar. No olvides votar cada 12 horas :D";
				}
				else
					mes "Disculpa, no tienes sufientes puntos para este objeto.";				
			}
			else
			{
				next;
				mes .npcname$;			
				mes "Bueno adios!";
			}			
			garbagecol();
		close;
		case 2:
			next;
			mes .npcname$;			
			set .@points,getPoints(getcharid(3));			
			mes "Actualmente tienes "+.@points+" punto(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;
	}
}

thanks again in advance!

Edited by Kido
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

something like this:

.@points=getPoints(getcharid(3));
#CASHPOINTS+=.@points;
updatePoints(getcharid(3),.@points);
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  127
  • Topics Per Day:  0.03
  • Content Count:  1445
  • Reputation:   163
  • Joined:  08/17/13
  • Last Seen:  

 

something like this:

.@points=getPoints(getcharid(3));
#CASHPOINTS+=.@points;
updatePoints(getcharid(3),.@points);

thank you sit/lady (duuno which gender you are D:)

to it would be like this then?

//Initialization of the Rewards
//add_item(673,100,1,"Bronze Coin"); //<<<---- that for 1 cash point 
.@points=getPoints(getcharid(3));
#CASHPOINTS+=.@points;
updatePoints(getcharid(3),.@points);

sorry i'm so bad at scripting D:! 

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...