Loan And PayLoan Cmd

Started by [VM_U]Spectra.PhantoM^, Dec 22, 2015, 08:10 AM

Previous topic - Next topic

[VM_U]Spectra.PhantoM^

function onPlayerCommand( player, cmd, text )
{
else if ( cmd == "loan" )
{
local cash = status[ player.ID ].Cash;
local add = cash + 20000;
status[ player.ID ].Cash = add;
player.Cash = add;
Message("" +player.Name+ " took a loan of 20k. ");
}
}

Easy as hell. This Makes Ur Cash Go Up To 20000$ (You can edit cash amount by editing local add default value is 20k) And also pay loan :
else if ( cmd == "payloan" )
{
local cash = status[ player.ID ].Cash;
local det = cash - 20000;
status[ player.ID ].Cash = det;
player.Cash = det;
Message("[#ff0000]" +player.Name+ " [#ffffff]payed his loan of 20k. ");
}
}

@S.L.C Updated Post
Wanna Talk To Me? Come At Irc #Jugo@LUNet

.

Wan't me to tell you how useless this is? Well, for starters, let's begin with "loan".

Useless and never used. Whatever cash the player had they'll be erased at the end of this context.
local cash = status[ player.ID ].Cash;
What's the point of this?
local add = 20000;
You are literally replacing the payer cash here with a fixed value. If the player had $30,000 and needed another $20,000 to buy something then he just lost $10,000.
status[ player.ID ].Cash = add;
player.Cash = add;

Should I continue with "payloan" ? That's just a copy of the "loan" with a different name. Therefore you are no paying anything but rather getting money again. Where dafuq did you copied these pieces of junk?

Stop filling the snippet section with junk. You're making it harder for people to find good stuff. You damn retards think people can't write a 5 line snippet like this on their own?

@S.L.C requests @maxorator to lock the Snippet Showroom section for people with less than 100 posts. Otherwise we all have to put up with crap like this until we find the snippet we need. Or at least something that prevents people from spamming this section.
.

Anik

What kind of snippet is it?? You should add "loan=false;" in class to prevent abuse. And also use the "loan=false;"loan in cmd.

[VM_U]Spectra.PhantoM^

Quote from: S.L.C on Dec 22, 2015, 08:29 AMWan't me to tell you how useless this is? Well, for starters, let's begin with "loan".

Useless and never used. Whatever cash the player had they'll be erased at the end of this context.
local cash = status[ player.ID ].Cash;Sorry Updated Now

What's the point of this?
local add = 20000;
You are literally replacing the payer cash here with a fixed value. If the player had $30,000 and needed another $20,000 to buy something then he just lost $10,000.
status[ player.ID ].Cash = add;
player.Cash = add;

Should I continue with "payloan" ? That's just a copy of the "loan" with a different name. Therefore you are no paying anything but rather getting money again. Where dafuq did you copied these pieces of junk?

Stop filling the snippet section with junk. You're making it harder for people to find good stuff. You damn retards think people can't write a 5 line snippet like this on their own?

@S.L.C requests @maxorator to lock the Snippet Showroom section for people with less than 100 posts. Otherwise we all have to put up with crap like this until we find the snippet we need. Or at least something that prevents people from spamming this section.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

Anik

This a better modified snippet.
add this on class Playerstats
loan = false;Now on cmd
else if ( cmd == "loan" )
{
if ( status[ player.ID ].loan == true ) MessagePlayer("** [Error]: >> You Already took Loan!", player );
else
{
local cash = player.Cash;
local add = cash + 20000;
player.Cash = add;
status[ player.ID ].loan = true;
Message("" +player.Name+ " took a loan of 20k. ");
}
}

else if ( cmd == "payloan" )
{
if ( status[ player.ID ].loan == false ) MessagePlayer("** [Error]: >> You didnt took Loan!", player );
else{
local cash = player.Cash;
local det = cash - 20000;
player.Cash = det;
status[ player.ID ].loan = false;
Message("" +player.Name+ " payed his loan of 20k. ");
}
}

Anik

I can say without testing the code that it will make your cash to -20000 either how much cash u have.
QuoteEasy as hell. This Makes Ur Cash Go Up To 20000$ (You can edit cash amount by editing local add default value is 20k) And also pay loan :
else if ( cmd == "payloan" )
{
local cash = status[ player.ID ].Cash;
local det = cash - 20000;
status[ player.ID ].Cash = det;
player.Cash = det;
Message("[#ff0000]" +player.Name+ " [#ffffff]payed his loan of 20k. ");
}
}
@S.L.C Updated Post

.

#6
Replace:
local cash = player.Cash;
local add = cash + 20000;
player.Cash = add;

With:
player.Cash += 20000;
And also replace:
local cash = player.Cash;
local det = cash - 20000;
player.Cash = det;

With:
player.Cash -= 20000;
Same result, less code. But if you don't understand it then the following has the same result.
player.Cash = (player.Cash + 20000);
player.Cash = (player.Cash - 20000);

And also add a check to see if you have where to withdraw the money from.

if (player.Cash < 20000)
    MessagePlayer("** [Error]: >> You don't have the money fool!", player );
    // EXPLODE!
.

Anik

Yeah @S.L.C But shouldn't this topic moved to Support or Squirrel Scripting Board??

.

I'm guessing the intent of this topic was to be a snippet but it ended up in a regular topic in the end. So yeah, this could fit int any of these sections except Support since that's for server/client support and not scripting support.
.

Williams

Can i ask one thing i want 100k loan to how can i take 100k ? can anyone change to this
else if ( cmd == loan )
if ( !text ) MessagePlayer( " / "+ cmd +" <loan price > " player );

We can take limited loan like 10k to 500k
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

Anik

#10
Quote from: Williams on Dec 25, 2015, 09:34 AMCan i ask one thing i want 100k loan to how can i take 100k ? can anyone change to this
else if ( cmd == loan )
if ( !text ) MessagePlayer( " / "+ cmd +" <loan price > " player );

We can take limited loan like 10k to 500k
that's so easy to do. Anyway I m posting a better on.