Intended for a class. Just a quick one I threw together, and some player wanted it. So... Here it is
PHP Code:
function onActionServerSide( afi, acc )
{
switch( afi )
{
case "allowPlayer":
{
temp.i = findPlayer( acc );
if ( player.account == "Your account here" )
{
temp.i.clientr.canWithdraw = 1;
temp.i.chat = "I can now withdraw from the safe!";
}
break;
}
case "disallowPlayer":
{
temp.i = findPlayer( acc );
if ( player.account == "" )
{
temp.i.chat = "I'm not allowed to withdraw from the safe anymore!";
temp.i.clientr.canWithdraw = 0;
}
break;
}
}
}
function onCreated()
{
setImg( "" ); // Your safe image
setShape( 1, 32, 32 );
}
function onPlayerChats()
{
temp.tokens = player.chat.tokenize();
if ( player.chat.starts( ":allow" ) )
{
triggerServer( "gui", name, "allowPlayer", temp.tokens[ 1 ] );
player.chat = "You allowed:" SPC temp.tokens[ 1 ] SPC "to withdraw from the safe!";
}
if ( player.chat.starts( ":disallow" ) )
{
triggerServer( "gui", name, "disallowPlayer", temp.tokens[ 1 ] );
player.chat = "You have disallowed:" SPC temp.tokens[ 1 ] SPC "to withdraw from the safe!";
}
if ( player.chat.starts( ":donate" ) )
{
this.moneyAdd = temp.tokens[ 1 ];
if ( clientr.item.Money >= this.moneyAdd )
{
if ( this.moneyAdd > 0 )
{
this.safeMoney += this.moneyAdd;
player.rupees -= this.moneyAdd;
onShowMoney();
saveLog2( "logs/safeDonate.txt", "Player:" SPC player.account SPC "donated:" SPC temp.tokens[ 1 ] SPC "at:" SPC player.level.name @ "!" );
}
else
{
player.chat = "You can't donate a negative amount!";
}
}
else
{
player.chat = "You don't have enough money to donate this amount!";
}
}
if ( player.chat.starts( ":withdraw" ) )
{
this.takeMoney = temp.tokens[ 1 ];
if ( this.safeMoney >= this.takeMoney )
{
if ( this.takeMoney > 0 )
{
if ( clientr.canWithdraw == 1 )
{
player.rupees += this.takeMoney;
this.safeMoney -= this.takeMoney;
saveLog2( "logs/safeWithdraw.txt", "Player:" SPC player.account SPC "withdrew" SPC temp.tokens[ 1 ] SPC "at:" SPC player.level.name );
onShowMoney();
}
else
{
player.chat = "You're not allowed to withdraw from the safe!";
}
}
else
{
player.chat = "You can't withdraw a negative amount!";
}
}
else
{
player.chat = "There isn't that much money in the safe!";
}
}
}
function onShowMoney()
{
showText( 1, x, y + .5, "Arial", "bc", "There is $" @ this.safeMoney SPC "in the safe!" );
}
Feel free to point out mistakes.