Results 1 to 4 of 4

Thread: COD2 MP: defining setPlayerModels - based on player's multiplayer name.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    The function 'setPlayerModels()' precaches and sets which model are used for which team (global initialization).
    The function 'model()' is run on the player and determines which model is used.

    So you want something like this:

    PHP Code:
    setPlayerModels()
    {
        switch(
    game["allies"])
        {
            case 
    "british":
                if(
    isdefined(game["british_soldiertype"]) && game["british_soldiertype"] == "africa")
                {
                    
    mptype\british_africa::precache();
                    
    game["allies_model"] = mptype\british_africa::main;
                }
                else
                {
                    
    mptype\british_normandy::precache();
                    
    game["allies_model"] = mptype\british_normandy::main;
                }
                break;
        
            case 
    "russian":
                if(
    isdefined(game["russian_soldiertype"]) && game["russian_soldiertype"] == "padded")
                {
                    
    mptype\russian_padded::precache();
                    
    game["allies_model"] = mptype\russian_padded::main;
                }
                else
                {
                    
    mptype\russian_coat::precache();
                    
    game["allies_model"] = mptype\russian_coat::main;
                }
                break;
        
            case 
    "american":
            default:
                
    mptype\american_normandy::precache();
                
    game["allies_model"] = mptype\american_normandy::main;
        }

        
    // Here we initialize the player models we want for player one and two.
        
    mptype\german_winterdark::precache();
        
    mptype\german_winterlight::precache();
        
    game["axis_model_playerone"] = mptype\german_winterdark::main;
        
    game["axis_model_playertwo"] = mptype\german_winterlight::main;
        
        if(
    isdefined(game["german_soldiertype"]) && game["german_soldiertype"] == "winterdark")
        {
            
    game["axis_model"] = mptype\german_winterdark::main;
        }
        else if(
    isdefined(game["german_soldiertype"]) && game["german_soldiertype"] == "winterlight")
        {
            
    game["axis_model"] = mptype\german_winterlight::main;
        }
        else if(
    isdefined(game["german_soldiertype"]) && game["german_soldiertype"] == "africa")
        {
            
    mptype\german_africa::precache();
            
    game["axis_model"] = mptype\german_africa::main;
        }
        else
        {
            
    mptype\german_normandy::precache();
            
    game["axis_model"] = mptype\german_normandy::main;    
        }

    PHP Code:
    model()
    {
        
    self detachAll();
        
        if(
    self.pers["team"] == "allies") {
            [[
    game["allies_model"] ]]();
        } else if(
    self.pers["team"] == "axis") {
            if (
    self.name == "Player One") {
                [[
    game["axis_model_playerone"] ]]();
            } else if (
    self.name == "Player Two") {
                [[
    game["axis_model_playertwo"] ]]();
            } else {
                [[
    game["axis_model"] ]]();
            }
        }

        
    self.pers["savedmodel"] = maps\mp\_utility::saveModel();

    Last edited by Mitch; 4th March 2021 at 19:00. Reason: Fixed code spacing

Tags for this Thread

Posting Permissions

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