Made you one, try to learn from it. Middle mouse or right click to destroy, double click to set message, b to turn on/off.
Script of weapon -Staff/Block
PHP Code:
function onActionServerSide( cmd, dx, dy )
{
switch ( cmd )
{
case "dropBlock":
{
temp.block = putnpc2( dx, dy, "" );
block.join( "object_block" );
savelog2( "staff/block.txt", format( "%s layed a block at (%s, %s) in %s", player.communityname, dx, dy, player.level.name ) );
}
}
}
//#CLIENTSIDE
function onKeyPressed( code, key )
{
switch ( key )
{
case "b":
{
this.blockOn = 1 - this.blockOn;
if ( ! this.blockOn )
{
hideimg( 1 );
}
setTimer( this.blockOn ? .05 : 0 );
break;
}
}
}
function onTimeOut()
{
if ( ! this.blockOn )
{
hideimg( 1 );
return;
}
showimg( 1, "block.png", mousex, mousey );
changeimgcolors( 1, 1, 1, 1, .5 );
if ( rightmousebutton )
{
triggeraction( mousex, mousey, "killBlock", player.chat );
}
if ( leftmousebutton )
{
triggerserver( "gui", name, "dropBlock", mousex, mousey );
hideimg( 1 );
setTimer( .1 );
return;
}
setTimer( 0.05 );
}
function onMouseDown( button )
{
switch ( button )
{
case "middle":
case "double":
{
triggeraction( mousex, mousey, "setMessage", player.account, player.chat );
break;
}
}
}
Script of class object_block:
PHP Code:
function onCreated()
{
this.image = "block.png";
setshape( 1, 32, 32 );
}
function onActionSetMessage( acc, msg )
{
savelog2( "staff/block.txt", format( "%s changed the message of block (%s, %s) in %s from \"%s\" to \"%s\"", findPlayer( acc ).communityname, this.x, this.y, this.level.name, this.chat, msg ) );
this.chat = msg;
}
function onActionKillBlock( acc )
{
savelog2( "staff/block.txt", format( "%s destroyed a block at (%s, %s) in %s ", findPlayer( acc ).communityname, this.x, this.y, this.level.name ) );
destroy();
}
Fully logged to logs/staff/block.txt