Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: MODDING : How to make virtual money.

  1. #11
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,083 Times in 753 Posts
    I dont see any error there, but can you try to comment lines out and see, if it still triggers the error?
    timescale 0.01

  2. #12
    ... connecting
    Join Date
    Jun 2020
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Only 8 years late to the thread... I'm working on a similar mod but for S&D gametype. The problem is that player.money is set to 0 each round because PlayerConnect is being called after each spawn. No clue on that...
    I've solved it by saving the money into server cvars, but doesn't seem like an elegant solution.

    Anyone has a better idea?

  3. #13
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by igstyga View Post
    Only 8 years late to the thread... I'm working on a similar mod but for S&D gametype. The problem is that player.money is set to 0 each round because PlayerConnect is being called after each spawn. No clue on that...
    I've solved it by saving the money into server cvars, but doesn't seem like an elegant solution.

    Anyone has a better idea?
    Store it in player.pers["something"] variable, load it back on playerconnect if it's defined. player.pers array gets stored over multiple rounds.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    igstyga (17th June 2020),kung foo man (17th June 2020)

  5. #14
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by igstyga View Post
    Only 8 years late to the thread... I'm working on a similar mod but for S&D gametype. The problem is that player.money is set to 0 each round because PlayerConnect is being called after each spawn. No clue on that...
    I've solved it by saving the money into server cvars, but doesn't seem like an elegant solution.

    Anyone has a better idea?
    You can try storing money in global variables, I don’t know how good this idea is
    PHP Code:
    getID()
    {
        return 
    self getEntityNumber();
    }

    onPlayerConnect()
    {
        
    id self getID();
        
    level.money[id] = 0;
    }

    onPlayerDisconnect()
    {
        
    id self getID();
        
    level.money[id] = undefined;
    }

    Killed(/*...*/)
    {
        if (
    mod == "headshot")
            
    money 100;
        else if (
    mod == "melee")
            
    money 200;
        else 
            
    money 50;
        
        
    id self getID();
        
    level.money[id] += money;

    Last edited by maxdamage99; 18th June 2020 at 07:50.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  6. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (18th June 2020)

  7. #15
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by maxdamage99 View Post
    You can try storing money in global variables, I don’t know how good this idea is
    PHP Code:
    getID()
    {
        return 
    self getEntityNumber();
    }

    onPlayerConnect()
    {
        
    id self getID();
        
    level.money[id] = 0;

    Bad idea. The level var is also cleaned (except for level.game array) on round restart. Furthermore, since players go through the "playerconnecting" callback when the round restarts, their money gets reset using this technique.

    Just store in player.pers["money"] or something similar. Look at the stock sd gametype for .pers["kills"] for example.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (18th June 2020)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •