Jump to content

Dark Theme was set as default for all members. Please report any issues here.

  • 0
Zarbony

Pow to operator?

Question

Hey there, i use the Shop System whish i found here in herc.

If i Use this System, the server says that "pow" will be removed in future und is deprecated.

How i can fix it without getting issues in NPC Text and Function?

function	ValueConvert	{
	set [email protected], atoi(""+getarg(0));
	if ( [email protected] == 0 || [email protected] >= 2147483647 ) return getarg(0);
	set [email protected], getstrlen(""[email protected]);
	for ( set [email protected],0; [email protected] < [email protected]; set [email protected], [email protected] + 1 ) {
		set [email protected]$, [email protected] % pow(10,[email protected]+1) / pow(10,[email protected]) + [email protected]$;
			if ( ([email protected]+1) % 3 == 0 && [email protected]+1 != [email protected] ) set [email protected]$, ","+ [email protected]$;
	}
	return [email protected]$;
}

I changed the pow(10,[email protected]+1) to (10 ** [email protected]+1) but this got me some issues when i buy some Items from the NPC and the Item Count in text is wrong.

If i use the Pow(10,[email protected]+1) then it works but the console says deprecated.

How i can fix this?

 

 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

You should link where you got the script from.

Anyway, your issue is basic maths...order of exponents. Use your parentheses correctly.

pow(10,[email protected]+1) is the same as 10 ^ ([email protected]+1)
When you change it to 10 ** [email protected]+1 it is being read as (10 ^ [email protected]) + 1

Share this post


Link to post
Share on other sites
  • 0

Hey, it is this Script:

Spoiler


-	shop	F_EMISTRY	-1,512:100
// pvpwait,72,87,5	script	Badge Exchanger#12	757,{

prontera,155,171,5	script	asmplwrwojirdh	4_F_KAFRA9,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;

mes "Hi";
next;
set @menu,select( "Open Shop" );

ClearData();
ShopSettings( @menu );
npcshopitem "F_EMISTRY",512,100;
npcshopdelitem "F_EMISTRY",512;
for(set [email protected],0; [email protected] < getarraysize( @ItemLists ); set [email protected],[email protected]+1)
	npcshopadditem "F_EMISTRY",@ItemLists[[email protected]],@ItemCost[[email protected]];
	mes "^FF0000Information:^000000";
	mes "----------------------------";
	CurrencyInfo( @Currency$ );
	mes "----------------------------";
	callshop "F_EMISTRY",1;
	npcshopattach "F_EMISTRY";
end;


function	ShopSettings	{
	switch( getarg(0) ){
		case 1:
			// Currency [ Item ID / Variable Name ]
			set @Currency$,"29996";
			// Item ID Lists
			setarray @ItemLists[0],6153,7227;
			// Item Price
			setarray @ItemCost[0],100,1;
			break;
			// case 4,5,6.....etc...
		default:
			ErrorNotice( "Invalid Menu Selection for Menu "[email protected]+"." );
			close;
	}
	
	
	if( @Currency$ == "" )
		ErrorNotice( "Invalid Currency Setting in Menu "[email protected]+" ." );
	if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
		ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "[email protected]+" ." );
		return;
	}

	function	ErrorNotice	{
		mes "^FF0000ERROR^000000 - "+getarg(0);
		mes "----------------------------";
		mes "Inform this Message to ^0000FFGame Staffs^000000 immediately.";
		close;
	}

	function	CurrencyInfo	{
	if( getitemname( atoi( getarg(0) ) ) != "null" )
	{
		mes "Required : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
		mes "Total : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
	}
	return;
}

	function	ValidateCost	{
	if( getitemname( atoi( getarg(0) ) ) != "null" )
	{
		if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
		}else{
			if( getd( getarg(0) ) < getarg(1) ) return 1;
		}
	return 0;
}

	function ClearData	{
		set @Currency$,"";
		set @TotalCost,0;
		deletearray @bought_nameid[0],getarraysize( @bought_nameid );
		deletearray @bought_quantity[0],getarraysize( @bought_quantity );
		deletearray @ItemLists[0],getarraysize( @ItemLists );
		deletearray @ItemCost[0],getarraysize( @ItemCost );
		return;
	}

	function	ValueConvert	{
		set [email protected], atoi(""+getarg(0));
		if ( [email protected] == 0 || [email protected] >= 2147483647 ) return getarg(0);
		set [email protected], getstrlen(""[email protected]);
		for ( set [email protected],0; [email protected] < [email protected]; set [email protected], [email protected] + 1 )
		{
			set [email protected]$, [email protected] % pow(10,[email protected]+1) / pow(10,[email protected]) + [email protected]$;
				if ( ([email protected]+1) % 3 == 0 && [email protected]+1 != [email protected] ) set [email protected]$, ","+ [email protected]$;
		}
		return [email protected]$;
	}

OnBuyItem:
	ShopSettings( @menu );
	for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
		for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
			if( @ItemLists[@j] == @bought_nameid[@i] ) {
			//set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );

				set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
				set [email protected]_weight,getiteminfo( @bought_nameid[@i],6 );
				set [email protected]_item_weight,( [email protected]_weight * @bought_quantity[@i] );
				set [email protected]_weight,( [email protected]_weight + [email protected]_item_weight );
			}
	if( [email protected]_weight > ( MaxWeight - Weight )) {
		mes "You can take that much.";
		close;
	}

	mes "^FF0000Billing List:^000000";
	mes "----------------------------";
	for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
			mes "^FF0000"[email protected]_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
	mes "----------------------------";
	// if (!checkweight2(@bought_nameid,@bought_quantity)) {
		// next;
		// mes "^FF0000You are currently over-weighted.^000000";
		// mes "^FF0000Please store some items before you do purchases.^000000";
		// close;
	// }else{
		// goto L_getpassed;
	// }	
L_getpassed:
	if( getitemname( atoi( @Currency$ ) ) != "null" ) {
		mes "Total : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
	}
	next;
	if( ValidateCost( @Currency$,@TotalCost ) ){
		if( getitemname( atoi( @Currency$ ) ) != "null" ) {
			mes "Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
		}
	} else {
		if( select( "- ^0000FFPurchase^000000:- Cancel" ) == 1 ) {
			if( getitemname( atoi( @Currency$ ) ) != "null" )
				delitem atoi( @Currency$ ),@TotalCost;
			else {
				set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
			}
			for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
				getitem @bought_nameid[@i],@bought_quantity[@i];
			dispbottom( "[Notice] Purchased "+getarraysize( @bought_nameid )+" Items.", 0xFF6600 );
			//dispbottom( "- "+ @bought_quantity[@i] +" x "+ getitemname( @bought_nameid[@i] ) +"", 0xFF6600 );
			mes "Please come back, if you want to shopping again.";
		}
	}
	ClearData();
	close;
}


 

Ive tested the 10 ^([email protected]+1) and the NPC Stuck.

if i use 10 ** [email protected]+1 it works but the value is wrong, now i know why this happen.

How i can fix this Script so that it will Work?

Thank you

Share this post


Link to post
Share on other sites
  • 0

LMAO! Haven't you ever seen somebody make an actual calculation? '^' is literally the character used on PC calculators. SMH. I was trying to show you what your calculation was doing...

Edited by bWolfie

Share this post


Link to post
Share on other sites
  • 0

Ive seen someone but i used only the basics.

this is the first time i used this operators and calculators.

Thats why i need help.

If i can fix this by myself i dont ask this question...

ErrorPw.PNG.85063cdd166acdcce61aa761c13b1647.PNG

 

Heres my next try but it will show the next error.

I used the function in Deprecated Notice

This one:

# from the Hercules root folder:
find npc db -type f -exec sed -i -r 's/pow\((.+),[ ]*(.+)\)/((\1) ** (\2))/g' {} +

 

 

 

 

Edited by Zarbony

Share this post


Link to post
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.   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...

×
×
  • Create New...

Important Information

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