Jump to content

Release: [Script Command] getdconst & setdconst


Zell

Recommended Posts


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

[Script Command] getdconst & setdconst


First of all, yes, I know that this break the "const" concept, but I really miss "static values" in script engine.

Yes, I know that we can use $vars but it's a lot pretty using const logic.

If you don't know what is a "const", open your db/const.txt file

In the end of file, you can add something like this:

X_VALUE%TAB%1005

And now, you can call X_VALUE in any script and the script will know that X_VALUE is not a player script, it's a """"global"""" variable, so you can call it with or without a player attached.

And now we came to my commands.

getdsconst allow you to get a constant dynamically like getd.

For sample:

.@var = getdconst( "X" + "_" + "VALUE" );

This would return 1005.

And now with setdconst we can change those as well.

setdconst( "X_VALUE", 2020 );

Remember, when you restar t your server, this constant will be 1005 again!
 

Here another sample script:

prontera,150,150,5	Script	CommandsTest	90,{

	.@const$[0] = "SWORDCLAN";
	.@const$[1] = "ARCWANDCLAN";
	.@const$[2] = "GOLDENMACECLAN";
	
	for( ; .@i < getarraysize( .@const$ ); .@i++ )
		mes "Contant Value of ["  + .@const$[.@i] + "] is " + getdconst( .@const$[.@i] );
	
	next;
	
	mes "I will now, change all const values to +1";
	
	for( .@i = 0; .@i < getarraysize( .@const$ ); .@i++ )
		setdconst( .@const$[.@i], getdconst( .@const$[.@i] ) + 1 );
	
	close;
}

 


 

  • Upvote 2
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
Reply to this topic...

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