Results 1 to 4 of 4

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts
    Precache your models only once in the gametype file, and basically call setModel("modelname") on a player entity.

    In your <gametype>.gsc (tdm.gsc) call a precache() function (don't thread it, otherwise it will keep going and might crash due to using un-precached stuff later), and inside there add all the precaches needed. Then change the behaviour of the loadModel function inside maps/mp/_utility.gsc to set the model to your needs. At last, do the check of the name and call that said loadModel function.

    Might have script errors, but the general idea is this (also the one that Mitch posted above):

    dm.gsc

    PHP Code:
    [...]

    Callback_StartGametype() {
        
    precache();
        
    // rest of stuff
        
    thread bla1();
        
    thread bla2();
        
    thread bla3();
    }

    [...]

    precache() {
        
    game["playermodels"] = [];
        
    game["playermodels"][0] = [];
        
    game["playermodels"][0]["model"] = "xmodel/model_0";
        
    game["playermodels"][0]["viewmodel"] = "xmodel/viewmodel_0";
        
        
    game["playermodels"][1] = [];
        
    game["playermodels"][1]["model"] = "xmodel/model_1";
        
    game["playermodels"][1]["viewmodel"] = "xmodel/viewmodel_1";

        
    game["playermodels"][2] = [];
        
    game["playermodels"][2]["model"] = "xmodel/model_2";
        
    game["playermodels"][2]["viewmodel"] = "xmodel/viewmodel_2";
        

        
        for(
    0game["playermodels"].sizei++) {
            
    precacheModel(game["playermodels"][i]["model"]);
            
    precacheModel(game["playermodels"][i]["viewmodel"]);
        }
    }

    [...]


    loadModel(info)
    {
        
    self detachAll();
        
        
    // get the saved model, then do the name check
        
    model undefined;
        
    viewmodel undefined;
        switch(
    self.name) {
            
    // add a case for each name check
            
    case "I will have model 0":
                
    model game["playermodels"][0]["model"];
                
    viewmodel game["playermodels"][0]["viewmodel"];
                break;
            case 
    "I will have model 1":
                
    model game["playermodels"][1]["model"];
                
    viewmodel game["playermodels"][1]["viewmodel"];
                break;
            case 
    "I will have model 2":
                
    model game["playermodels"][2]["model"];
                
    viewmodel game["playermodels"][2]["viewmodel"];
                break;
            default:
                
    // he will have the saved info["model"] that loads in setPlayerModels() (default one for each team)
                
    model info["model"];
                
    viewmodel info["viewmodel"];
        }
        
        
    self setModel(model);
        
    self setViewModel(viewmodel);

        
    // attach the rest of models
        
    attachInfo info["attach"];
        
    attachSize attachInfo.size;
        
        for(
    0attachSizei++)
            
    self attach(attachInfo[i]["model"], attachInfo[i]["tag"], attachInfo[i]["ignoreCollision"]);
    }

    [...] 
    Last edited by pollo; 4th March 2021 at 19:15.

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
  •