setprop

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 098.

Moderator: POL Developer

Post Reply
Joram
New User
Posts: 9
Joined: Thu Aug 12, 2010 8:06 am

setprop

Post by Joram »

Is there a .setprop script out here?
I have been tring to get pol097 working, But i do not have the experance with polscripting. I am tring but just not getting it. I am thinking that is someone had one for pol098 with wod scripts i could compare the 2 and hopefully get a better understanding of how to convert some of the scripts from other versions to pol098. Well at lease i hope so.

Please if u do msg me in these forums. Thank you
guialtran
Grandmaster Poster
Posts: 120
Joined: Wed Jul 30, 2008 12:42 pm

Re: setprop

Post by guialtran »

http://docs.polserver.com/pol099/objref.php#Account

setprop(string propname, propval) true SetObjProperty for account objects.

http://docs.polserver.com/pol099/objref ... ileElement

SetProp(string propname, object propvalue) true/error Sets a packable object to a property

http://docs.polserver.com/pol099/objref.php#Guild

setprop(string propname, object propval) true/error Sets a packable object to a property.

http://docs.polserver.com/pol099/objref.php#Party

setprop(string propname, object propval) true/error Sets a packable object to a property.

http://docs.polserver.com/pol099/objref.php#UObject

setprop(string propname, object propval) true/error Sets a packable object to a property.
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm
Location: South Africa

Re: setprop

Post by Justae »

Hello Joram,

This .setprop compiles just as easily under POL096, 097, 098
Copy the code below and paste it into a text editor and save it (as setprop.src) into your commands directory you want to access (GM, Admin, Seer whichever one). Compile it and enjoy. Just remember that this will only allow you to set read/write props.

There are props which are readonly, for example, mobile.acctl, the prop ".acct" is readonly, you cannot modify that on the fly. There is a whole list of props to be found in the excellent eScript documentation, I urge you to go through the introduction to eScript as well, probably a good idea as a first-stop.

Let me know if you want a .setobjproperty script.

By the way, if you get involved with the conversion of scripts from one version of POL to another, your guide and Bible is the "changelog.txt" you will find in the root directory of each POL server release.

Code: Select all

use uo;
use basic;
use os;

program textcmd_setprop( who, text )

	var parms := SplitWords( text );
	if( !len(parms) )
		SendSysMessage( who , "Structure is : .setprop <prop_name> <prop_val>" );
		return;
	endif

	var prop_name	:= parms[1];
	var prop_val	:= parms[2];
	
	if( !prop_name or (!prop_val and prop_val != 0))
		SendSysMessage( who , "Structure is : .setprop <prop_name> <prop_val>" );
		return;
	endif

	if ( CDbl(prop_val) or prop_val == 0 )
		prop_val := CDbl(prop_val);
		if ( CDbl(prop_val) == CInt(prop_val))
			prop_val := CInt( prop_val );
		endif
	else
		if (CInt(prop_val))
			prop_val := CInt( prop_val );
		else
			prop_val := Cstr( text - (prop_name + " ") );
		endif
	endif
		
	if( !prop_val or prop_val == 9999 )
		prop_val := 0;
	endif

	SendSysMessage( who, "Select an object to set "+prop_name+" property on" );

	var obj := Target( who );
	if( obj )

		var value;
		var newvalue;

		value := obj.get_member(prop_name);
		case (prop_name)
			"objtype":
			"graphic":
			"serial":
			"color":
			"truecolor":
			"trueobjtype":
				SendSysmessage( who , prop_name + " was: " + hex(value) );	break;
			default:
				SendSysmessage( who , prop_name + " was: " + value );		break;
		endcase

		var ismove := 0;
		var x := obj.x;
		var y := obj.y;
		var z := obj.z;
		case (prop_name)
			"x":	x := prop_val;
					ismove := 1;
				break;

			"y":	y := prop_val;
					ismove := 1;
				break;

			"z":	z := prop_val;
					ismove := 1;
				break;

		endcase
		
		var ret := 0;
		if (ismove)
			if (obj.IsA(POLCLASS_MOBILE))
				MoveObjectToLocation( obj, x, y, z, obj.realm, 0 );
			else
				MoveObjectToLocation( obj, x, y, z, obj.realm, MOVEOBJECT_FORCELOCATION );
			endif
			ret := 1;
		else
			ret := obj.set_member(prop_name, prop_val);
		endif
		
		if (ret)
			newvalue := obj.get_member(prop_name);
			case (prop_name)
				"objtype":
				"graphic":
				"serial":
				"color":
				"truecolor":
				"trueobjtype":
					newvalue := hex(newvalue);
			endcase
				
			if( newvalue == value )
				SendSysmessage( who , "Property unchanged." );
			elseif(newvalue)
				SendSysmessage( who , prop_name + " now: " + newvalue );
			else
				SendSysmessage( who , "Error occured." );
			endif

		else
			SendSysmessage( who , "Could not write to " + prop_name + "." );
		endif

	else
		SendSysMessage(who, "Cancelled.");
	endif

endprogram
Regards,
Justae
Joram
New User
Posts: 9
Joined: Thu Aug 12, 2010 8:06 am

Re: setprop

Post by Joram »

Great thanks,

U 2 are the first real help i had here. I will try as soon as possible and post here results. Thanks for the info. I am tringto learn C++ u think that will help me at escripting?



Joram
Joram
New User
Posts: 9
Joined: Thu Aug 12, 2010 8:06 am

Re: setprop

Post by Joram »

ok That worked alsome. Thanks And yes i would like .setobjproperty. that would be great and any other scrpits u think we could use. i am in middle of learning scripting. Thank you very much.

Seems we do not have regionspawner either.



Joram
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm
Location: South Africa

Re: setprop

Post by Justae »

Learning eScript is like any other programming language. You learn the syntax of the commands, what the commands can and cannot do. Always refer back to the eScript guide if you are stuck, or other functioning code to determine how it works.

Here is a basic .setobjproperty command.
Copy and save as setobjproperty.src as per last command.

Code: Select all

use uo;

program addobjproperty( who , text )

	var parms := SplitWords( text );
	if( !len(parms) )
		SendSysMessage( who , "Structure is : .setobjproperty <prop_name> <prop_type> <prop_val>" );
		return;
	endif

	var prop_name	:= parms[1];
	var prop_type	:= parms[2];
	var prop_val	:= parms[3];
	
	if( !prop_name or !prop_type )
		SendSysMessage( who , "Structure is : .setobjproperty <prop_name> <prop_type> <prop_val>" );
		return;
	endif

	if( !prop_val and prop_type == "serial" )
		SendSysMessage( who , "Set the serial of who/what?" );
		var object2 := Target( who );
		if( !object2 )
			SendSysMessage( who , "You must target the object from which you want to use the serial number." );
			return;
		endif
		
		prop_val := object2.serial;
		if( !prop_val )
			SendSysMessage( who , "That don't have a serial number." );
			return;
		endif
		
	elseif( prop_val and prop_type == "array" )
		prop_val := { parms[3] };

	elseif( !prop_val and prop_type == "array" )
		prop_val := ProcessArrayProp( who );
		if( !prop_val )
			SendSysMessage( who , "That isn't a valid array." );
			return;
		endif
	endif
	
	if( !prop_val )
		SendSysMessage( who , "Structure is : .setobjproperty <prop_name> <prop_type> <prop_val>" );
		return;
	endif
	
	var i := 4;
	case( prop_type )
		"int":		prop_val := Cint( prop_val );
				break;
			
		"dbl":		prop_val := Cdbl( prop_val ); 
				break;
			
		"string":	while( parms[i] )
					prop_val := prop_val + " " + parms[i];
					i := i + 1;
				endwhile
				break;
		
		"hex":		prop_val := Hex( prop_val );
				break;
				
		"serial":	break;
		
		"array":
				while( parms[i] )
					prop_val.append(parms[i]);
					i := i + 1;
				endwhile
				break;

		default:	
				SendSysMessage( who , "The valid prop_types are 'int' , 'dbl' , 'string' , 'hex' , 'serial' and 'array'." );
				return;
	endcase
		
	SendSysMessage( who , "Set the property on what?" );
	var object := Target( who );

	if( prop_val || prop_val == 0)
		if( SetObjProperty( object , prop_name , prop_val ) )
			SendSysMessage( who , "Property " + prop_name + " was successfully set to " + prop_val + " as a " + prop_type + " on the target." );
		else
			SendSysMessage( who , "Couldn't write the cprop." );
		endif
	endif
         
endprogram


function ProcessArrayProp( who )

	var array_length;
	var counter  := 1;
	var prop_val := {};
	
	array_length := Cint( RequestInput( who , who.backpack , "What is the length of the array?" ) );
	if( !array_length )
		return 0;
	endif
	
	while( counter <= array_length )
		
		var data	 := RequestInput( who , who.backpack , "What is the data for the element #" + counter + "?" );
		var splited	 := Splitwords( data );
		var type	 := splited[1];
		var val	 := splited[2];

		if( !type )
			SendSysMessage( who , "The valid prop_types are 'int' , 'dbl' , 'string' , 'hex' , 'serial' and 'array'." );
			continue;
		endif

		if( !val and type == "serial" )
			SendSysMessage( who , "Set the serial of who/what?" );
			var object := Target( who );
			if( !object )
				SendSysMessage( who , "You must target the object from which you want to use the serial number." );
				continue;
			endif
		
			val := object.serial;
			if( !val )
				SendSysMessage( who , "That don't have a serial number." );
				continue;
			endif
			
		elseif( !val and type == "array" )
			val := ProcessArrayProp( who );
			if( !val )
				SendSysMessage( who , "That isn't a valid array." );
				continue;
			endif
		endif
	
		if( !val )
			SendSysMessage( who , "Structure is : <type> <val>" );
			continue;
		endif
	
		var i := 3;
		case( type )
			"int":		val := Cint( val );
					break;
			
			"dbl":		val := Cdbl( val ); 
					break;
				
			"string":	while( splited[i] )
						val := val + " " + splited[i];
						i := i + 1;
					endwhile
					break;	
			
			"hex":		val := Hex( val );
					break;
					
			"serial":	break;
			
			"array":	break;
			
			default:	
					SendSysMessage( who , "The valid types are 'int' , 'dbl' , 'string' , 'hex' , 'serial' and 'array'." );
					continue;
		endcase
		
		prop_val.append( val );
		counter := counter + 1;
		
	endwhile
	
	return prop_val;
	
endfunction
Regards,
Justae
Post Reply