problem with my seed script
Posted: Sun Dec 04, 2011 7:05 pm
Code: Select all
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
{
var itemOwner = GetPackOwner( iUsed, 0 );
if( itemOwner == null || itemOwner.serial != pUser.serial )
{
pUser.SysMessage( "This must be in your backpack." );
return false;
}
else if( iUsed.type != 15 )
{
var targMsg = GetDictionaryEntry( 443, socket.Language );
socket.CustomTarget( 1, targMsg );
}
else
return true;
}
return false;
}
function onCallback1( socket, ourObj)
{
var mChar = socket.currentChar;
if( mChar && mChar.isChar )
{
var tileID = 0;
if( socket.GetByte( 1 ) )
{
tileID = socket.GetWord( 17 );
if( !tileID )
tileID = GetTileIDAtMapCoord( socket.GetWord( 11 ), socket.GetWord( 13 ), mChar.worldNumber );
}
else if( ourObj && ourObj.isItem )
tileID = ourObj.id;
if( tileID != 0 )
{
if(tileID == 0x0009 || tileID == 0x0010 || tileID == 0x0011 || tileID == 0x0012 || tileID == 0x0013 ||
tileID == 0x0014 || tileID == 0x0015 ) // fields
{
// remove one seed
var iMakeResource = mChar.ResourceCount( 0x0f23 ); // is there enough resources to use up to make it
if( iMakeResource < 1 )
{
mChar.SysMessage( "You don't seem to have any garlic seeds" );
return;
}
if( mChar.skills[13] < 200 )
{
mChar.SysMessage( "You are not skilled enough to do that." );
return;
}
mChar.UseResource( 1, 0x0f23 ); // uses up a resource (amount, item ID, item colour)
mChar.SoundEffect( 0x0021, true );
// check the skill
if( !mChar.CheckSkill( 13, 100, 500 ) ) // character to check, skill #, minimum skill, and maximum skill
{
mChar.SysMessage( "You dropped the seed" );
return;
}
var itemMade = CreateDFNItem( mChar.socket, mChar, "garlicspawner", 1, "ITEM", false ); // places a garlic spawner. mChar.SysMessage( "You plant the seed." );
return;
}
else
socket.SysMessage( "You cannot plant seeds here." );
}
else
socket.SysMessage( "You cannot plant seeds here." );
}
}its like the spawner broke seen as it was placed
One other problem I'm having is getting the item to be created where i point my target curser. instead just creates the item at my feet.
And on more thing is how do i get it to check for a nother spawner in that spot so doesn't place a spawner on top of one.