Jump to content
  • 0
Sign in to follow this  
Snaehild

CP Credits to PoD

Question

Hi,

 

I would just like to consult my revised script from JayPee Mateo from his Vote For Points NPC Script. Though this is tested working, I just wanna check if i'm doing it right and if there are further optimizations that can be done. Thanks!

 

prontera,108,183,3	script	Donation Test	564,{//Function Prototypesfunction garbagecol;//Garbage collection for the Character variablesgarbagecol();function getPoints;//This will return the points of the player stored in the databasefunction updatePoints;//This will updates the points of the player stored in the database//NPC Nameset .npcname$,"[ Donation Test ]";	//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$;									set .@ritemid,7179;			set .@rquantity,1;			set .@rpoints,1;			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. :D";				}				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_credits` SET balance=(balance-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");		return;	}	function getPoints {		set .@account_id,getarg(0);		query_sql("SELECT `balance` FROM `cp_credits` WHERE account_id="+.@account_id+" LIMIT 1",.@points);		if(getarraysize(.@points)==0)			return 0;				return .@points[0];	}	function garbagecol{		deletearray @itemID[0],128;		deletearray @itemQ[0],128;		deletearray @points[0],128;			return;	}}

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.