Results 1 to 4 of 4

Thread: Save custom player model and retrieve

  1. #1
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Save custom player model and retrieve

    I have a mod which set the player's model to custom models if you select that in the menu

    An example from the ui_mp/objects1.menu

    PHP Code:
    execKey "a" play "mouse_click"scriptMenuResponse "xmodel/brush_desertshrubgroup01"close objects1 }

    itemDef 
            
    {
                
    name            "button_a"
                
    visible            1
                rect            0 0 128 20
                origin            ORIGIN_CHOICEA
                forecolor        GLOBAL_UNFOCUSED_COLOR
                type            ITEM_TYPE_BUTTON
                text            
    "@OBJ_OBJ1_1"
                
    textfont        UI_FONT_NORMAL
                textscale        .3
                textstyle        ITEM_TEXTSTYLE_SHADOWED
                textaligny        20
                action
                
    {
                    
    play "mouse_click";
                    
    scriptMenuResponse "xmodel/brush_desertshrubgroup01";
                    
    close objects1
                
    }
            } 
    This is set a custom player model on mouse click or button_a, if I'm right.

    Now I want to make this model to invisible I found a script which was made by IzNoGoD:

    PHP Code:
    makeInvisible(arg)
    {
        if(!
    isdefined(self.isInv)) self.isInvfalse;
        
        if((
    arg) && (!self.isInv))
        {
            
    self detachall();
            
    self setmodel("");
            
    self.isInvtrue;
        }
        else
        {
            if(!
    isdefined(self.pers["savedmodel"]))
                
    maps\mp\gametypes\_teams::model();
            else
                
    maps\mp\_utility::loadModel(self.pers["savedmodel"]);
            
    self.isInvfalse;
        }

    Okay, this is make the model to invisible if I'm calling makeInvisible(true); but after that I can't set the model back which was before... (xmodel/brush_desertshrubgroup01) I'm always getting back the default allies model

    I see in the maps\mp\_utility.gsc have 2 functions which save and load model but how can I save these models like that if the script changing the custom models in a menu file?

    PHP Code:
    saveModel()
    {
        
    info["model"] = self.model;
        
    info["viewmodel"] = self getViewModel();
        
    attachSize self getAttachSize();
        
    info["attach"] = [];
        
        for(
    0attachSizei++)
        {
            
    info["attach"][i]["model"] = self getAttachModelName(i);
            
    info["attach"][i]["tag"] = self getAttachTagName(i);
            
    info["attach"][i]["ignoreCollision"] = self getAttachIgnoreCollision(i);
        }
        
        return 
    info;
    }

    loadModel(info)
    {
        
    self detachAll();
        
    self setModel(info["model"]);
        
    self setViewModel(info["viewmodel"]);

        
    attachInfo info["attach"];
        
    attachSize attachInfo.size;
        
        for(
    0attachSizei++)
            
    self attach(attachInfo[i]["model"], attachInfo[i]["tag"], attachInfo[i]["ignoreCollision"]);


  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Do you savemodel after you setmodel at spawn?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. #3
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    I don't set the model at spawn as I said this script is setting the model when I click on a button in the menu... a .menu file handling the setmodel or I'm wrong?

    PHP Code:
    execKey "a" play "mouse_click"scriptMenuResponse "xmodel/brush_desertshrubgroup01"close objects1 }

    itemDef 
            
    {
                
    name            "button_a"
                
    visible            1
                rect            0 0 128 20
                origin            ORIGIN_CHOICEA
                forecolor        GLOBAL_UNFOCUSED_COLOR
                type            ITEM_TYPE_BUTTON
                text            
    "@OBJ_OBJ1_1"
                
    textfont        UI_FONT_NORMAL
                textscale        .3
                textstyle        ITEM_TEXTSTYLE_SHADOWED
                textaligny        20
                action
                
    {
                    
    play "mouse_click";
                    
    scriptMenuResponse "xmodel/brush_desertshrubgroup01";
                    
    close objects1
                
    }
            } 

  4. #4
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by Toxys View Post
    I don't set the model at spawn as I said this script is setting the model when I click on a button in the menu... a .menu file handling the setmodel or I'm wrong?

    PHP Code:
    execKey "a" play "mouse_click"scriptMenuResponse "xmodel/brush_desertshrubgroup01"close objects1 }

    itemDef 
            
    {
                
    name            "button_a"
                
    visible            1
                rect            0 0 128 20
                origin            ORIGIN_CHOICEA
                forecolor        GLOBAL_UNFOCUSED_COLOR
                type            ITEM_TYPE_BUTTON
                text            
    "@OBJ_OBJ1_1"
                
    textfont        UI_FONT_NORMAL
                textscale        .3
                textstyle        ITEM_TEXTSTYLE_SHADOWED
                textaligny        20
                action
                
    {
                    
    play "mouse_click";
                    
    scriptMenuResponse "xmodel/brush_desertshrubgroup01";
                    
    close objects1
                
    }
            } 
    1. try search code from .gsc like:
    PHP Code:
        /* ... */
        
        
    self waittill("menuresponse"menuresponse);
        
        if (
    menu == "objects1")
            
    self setmodel(response);
        
        
    /* ... */ 
    2. try
    PHP Code:
    makeInvisible(arg)
    {
        if(!
    isdefined(self.isInv)) self.isInvfalse;
        
        if((
    arg) && (!self.isInv))
        {
            
    //save model before invi
            
    self maps\mp\_utility::saveModel();
            
            
    self detachall();
            
    self setmodel("");
            
    self.isInv true;
        }
        else
        {
            if(!
    isdefined(self.pers["savedmodel"]))
                
    maps\mp\gametypes\_teams::model();
            else
                
    maps\mp\_utility::loadModel(self.pers["savedmodel"]);
            
    self.isInvfalse;
        }

    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

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

    Toxys (3rd November 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
  •