Cash Amount at Player Spawn! It is possible?

Started by JhonDude, Sep 14, 2022, 12:48 PM

Previous topic - Next topic

JhonDude

Hello Guys! Im new here!
Starting to create a DM server.
The question is: Is there a way for the character to start with some money?
The ideia is to start with $250 or $500.
How can i do that? Is a simple class edit? Or the scripts are the only way?

EnForcer

use onplayerrequestspawn event and add the requirement of cash like:
if ( player.Cash < 250 ) return false;
else return true;

JhonDude

Tnx so much man!
A nice and simple script!
Waiting to go home and try this one...
I will post here the results!
See ya!

JhonDude

Quote from: EnForcer on Sep 15, 2022, 12:11 PMuse onplayerrequestspawn event and add the requirement of cash like:
if ( player.Cash < 250 ) return false;
else return true;

Hello again!
The script didn't work for me.
I dont know wy.

So, i made this in a simple way:
Just add: player.Cash +=500; in the event: onPlayerJoin
Like this:
==================
onPlayerJoin
{
    player.Cash +=500;
}
==================
Now i want to add a timer on this.
Each player must earn the amount of 500 for every 15 minutes of play.

Thanks in advance for any help!

PSL

This function should help you:
Put the GiveCash(player.ID); in onPlayerJoin.
function GiveCash(ID)
{
    local player=FindPlayer(ID);
    if(player)
    {
        player.Cash+=500;
        NewTimer("GiveCash",900000,1,player.ID);
    }
}

JhonDude

Quote from: PSL on Sep 21, 2022, 10:00 AMThis function should help you:
Put the GiveCash(player.ID); in onPlayerJoin.
function GiveCash(ID)
{
    local player=FindPlayer(ID);
    if(player)
    {
        player.Cash+=500;
        NewTimer("GiveCash",900000,1,player.ID);
    }
}

Thanks for the help man!
I tryed the script, but withouth sucsses.
Server starts, and crash on me when "GiveCash" function starts.

So i changed the initial idea to a simple one.
Just add some cash pickups over the map. With a respawntime set on 5min.

this will make the player go around the map looking for these points,
if he wants to have some money at the beginning.

So, tnx for the help!