Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: wilber32 on Aug 30, 2015, 03:35 PM

Title: Functions money modified
Post by: wilber32 on Aug 30, 2015, 03:35 PM
This to functions function DecCash( player, amount )
{
local cash = stats[ player.ID ].Cash;
local det = cash - amount;
stats[ player.ID ].Cash = det;
player.Cash = det;
}

function IncCash( player, amount )
{
local cash = stats[ player.ID ].Cash;
local add = cash + amount;
stats[ player.ID ].Cash = add;
player.Cash = add;
}

function IncKills( player, amount )
{
local kills = stats[ player.ID ].Kills;
local add = kills + amount;
stats[ player.ID ].Kills = add;
}

function IncKilleds( player, amount )
{
local killeds = stats[ player.ID ].Killeds;
local add = killeds + amount;
stats[ player.ID ].Killeds = add;
}

function IncDeaths( player, amount )
{
local deaths = stats[ player.ID ].Deaths;
local add = deaths + amount;
stats[ player.ID ].Deaths = add;
}
function DecBank( player, amount )
{
local bank = stats[ player.ID ].Bank;
local det = bank - amount;
stats[ player.ID ].Bank = det;
}
function IncBank(player,amount)
{
local bank = stats[ player.ID ].Bank;
local add = bank + amount;
stats[ player.ID ].Bank = add;
}

This to Main.nut else if ( cmd == "deposit" )
{
local status = stats;
local Cash = status[ player.ID ].Cash;
local Pos = player.Pos, checkpoly;
checkpoly = InPoly( Pos.x, Pos.y, -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( status[ player.ID ].IsReg == false ) MessagePlayer( "[#FF0000][ERROR]You are not registered.", player );
else if ( status[ player.ID ].IsLogged == false ) MessagePlayer( "[#FF0000][ERROR]You are not logged in.", player );
else if ( !text ) MessagePlayer( "[#570057][Syntax]: /deposit [Amount/All]", player );
else if( checkpoly == false ) MessagePlayer( "[#ff0000]You have to be at the bank.", player );
else if ( status[ player.ID ].Cash == 0 ) MessagePlayer( "[#ff0000]You have no money.", player );
else {
if( text == "all" )
{local pcash = status[ player.ID ].Cash;
if( pcash > 0 ) {
DecCash( player, pcash );
IncBank( player, pcash );
MessagePlayer( "[#005703]you have deposited: ["+ pcash +"] to your account.", player );
local Bank = status[ player.ID ].Bank;
MessagePlayer( "[#005703]your new balance is: [ $"+Bank+" ].", player );
}
}
else if ( !IsNum( text ) )  MessagePlayer( "[#ff0000][ERROR]the amount should be in numbers.", player );
else if ( Cash < text.tointeger() ) MessagePlayer( "[#ff0000][ERROR]You have no money.", player );
else {
local text = text.tointeger();
DecCash( player, text );
IncBank( player, text );
MessagePlayer( "[#005703]you deposit [$"+ text +"] to your account.", player );
local Bank = status[ player.ID ].Bank;
MessagePlayer( "[#005703]your new balance is: [ $"+Bank+" ].", player );
}
}
}


else if ( cmd == "givecash" )
{
local Pos = player.Pos, checkpoly;
checkpoly = InPoly( Pos.x, Pos.y, -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( stats[ player.ID ].IsReg == false ) MessagePlayer( "[#FF0000][ERROR]You are not registered.", player );
else if ( stats[ player.ID ].IsLogged == false ) MessagePlayer( "[#FF0000][ERROR]You are not logged in.", player );
else if ( !player.IsSpawned ) MessagePlayer( "[#ff0000][ERROR]You have not done spawn", player );
else if( checkpoly == false ) MessagePlayer( "[#ff0000][ERROR]You have to be at the bank.", player );
else if ( !text )
{
MessagePlayer( "[#570057][Syntax]: /givecash [monto] [Nick/ID]", player );
return;
}
else if ( !IsNum( text ) )  MessagePlayer( "[#ff0000][ERROR]the amount should be in numbers.", player );
else {
local plr = GetPlayer( GetTok( text, " ", 2 ) );
if ( !plr ) MessagePlayer( "[#ff0000][ERROR] Player Unknow", player );
else if (plr.ID == player.ID) MessagePlayer( "[#ff0000][ERROR]you can not do yourself",player);
else {
local Poss = plr.Pos,checkpolyy;
checkpolyy = InPoly( Poss.x, Poss.y, -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( checkpolyy == false ) {MessagePlayer( "[#ff0000]You have to be at the bank.", player ); MessagePlayer( "[#ff0000]"+player.name+"should be in the bank.",plr);}
else {
if ( text.tointeger() > player.Cash ) MessagePlayer( "[#ff0000][ERROR]Invalid amount.", player );
else if (!IsNum(GetTok( text, " ", 1 ) ) ) MessagePlayer( "[#ff0000][ERROR]the amount should be in numbers.", player );
else if ( text.tointeger() < 0 ) MessagePlayer( "[#ff0000][ERROR]Invalid amount.", player );
else {
DecCash( player, text.tointeger() );
IncCash( plr, text.tointeger() );
MessagePlayer( "[#005703]You have given $" + text.tointeger() + " to " + plr.Name + "",player);
MessagePlayer( "[#005703]"+player.Name+" gave you $" + text.tointeger() + "Do not spend on marijuana!.",plr);
}
}
}
}
}

else if ( cmd == "withdraw" )
{
local status = stats;
local Bank = status[ player.ID ].Bank;
local Pos = player.Pos, checkpoly;
checkpoly = InPoly( Pos.x, Pos.y,  -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( status[ player.ID ].IsReg == false ) MessagePlayer( "[#FF0000][ERROR]You are not registered.", player );
else if ( status[ player.ID ].IsLogged == false ) MessagePlayer( "[#FF0000][ERROR]You are not logged in.", player );
else if ( !text ) MessagePlayer( "[#570057][Syntax]: /withdraw [Amout/All]", player );
else if ( checkpoly == false ) MessagePlayer( "[#ff0000][ERROR]You have to be at the bank.", player );
else if ( status[ player.ID ].Bank == 0 ) MessagePlayer( "[#ff0000][ERROR]You have no money in the bank", player );
else {
if( text == "all" )
{local pbank = status[ player.ID ].Bank;
if( pbank > 0 ) {
DecBank( player, pbank );
IncCash( player, pbank );
MessagePlayer( "[#005703]you have taken: [ $"+Bank+" ] your account.", player );
}
}
else if ( !IsNum( text ) ) MessagePlayer( "[#ff0000][ERROR]the amount should be in numbers.", player );
else if ( Bank < text.tointeger() ) MessagePlayer( "[#ff0000][ERROR]You do not have money", player );
else {
local text = text.tointeger();
DecBank( player, text );
IncCash( player, text );
MessagePlayer( "[#005703]you have taken: [ $"+text+" ] your account.", player );
}
}
}

  else if ( cmd == "cash" )
  {
      if ( !text ) MessagePlayer( "[#570057][Syntax]: /cash <Nick/ID>", player );
  else
  {
     local plr = GetPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000][Error] - Invalid Player", player );
                         if ( stats[ player.ID ].IsReg == false ) MessagePlayer( "[#FF0000][ERROR]You are not registered.", player );
else MessagePlayer( plr.Name + "'[#005703]s Cash: $" + stats[ plr.ID ].Cash + " Bank: $" + stats[ plr.ID ].Bank + "", player );
  }
  }

this is for those who spoke of my, Now I showed that his words no value does not convince me. Here I is modified by me my server DM
Title: Re: Functions money modified
Post by: . on Aug 30, 2015, 03:40 PM
Can't you just update your previous topic? What's the point of all that junk.
Title: Re: Functions money modified
Post by: wilber32 on Aug 30, 2015, 04:00 PM
That I did it myself and I'm demonstrating to those who talk about my
Title: Re: Functions money modified
Post by: Xmair on Aug 30, 2015, 04:18 PM
You just removed a couple of lines, nothing else.
Title: Re: Functions money modified
Post by: wilber32 on Aug 30, 2015, 05:16 PM
Only fix the problem I had
Title: Re: Functions money modified
Post by: KAKAN on Aug 30, 2015, 05:53 PM
:P, I can write it in even simpler way, now you should give your login and register system too, or else there will be no value of it
Title: Re: Functions money modified
Post by: wilber32 on Aug 30, 2015, 07:25 PM
because I have to give it?
Title: Re: Functions money modified
Post by: KAKAN on Aug 31, 2015, 08:41 AM
WHat do ya mean actually?
Title: Re: Functions money modified
Post by: FinchDon on Aug 31, 2015, 09:20 AM
Ok You Got this from your DM server and you paste from any script to your DM Server Removing Somelines Dosen't mean you have scripted that @wilber32
Title: Re: Functions money modified
Post by: Thijn on Aug 31, 2015, 03:49 PM
Might as well lock this. The script has been posted and there's only going to be useless replies.