AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting models on the moment, not on next spawn (https://forums.alliedmods.net/showthread.php?t=164688)

dreamedward 08-14-2011 14:15

Setting models on the moment, not on next spawn
 
Hello, guys. So I have made myself an admin menu which I use to change player's models. But my problem is that when i choose one of the options the models don't change at exactly that moment. They change on next round and on round end they don't go back to the normal. I'm using cs_set_user_model. So my point is how can I make my menu to change the player's models immediately after I choose one of the options and at round start the models to reset back to normal. Can you help me?

sader 08-14-2011 14:31

Re: Setting models on the moment, not on next spawn
 
I am not 100% sure but I saw this function cs_reset_user_model(player) so I believe you must call it after you call cs_set_user_model

dreamedward 08-14-2011 14:39

Re: Setting models on the moment, not on next spawn
 
It's the same function but sets the player model to (player). It's not what im asking for.

fysiks 08-14-2011 16:44

Re: Setting models on the moment, not on next spawn
 
Show your code.

dreamedward 08-14-2011 17:21

Re: Setting models on the moment, not on next spawn
 
Here
PHP Code:

#include <amxmodx>
 #include <cstrike>
 
new bool:golb[33];
 new 
bool:smith[33];
 new 
bool:neo[33];
 
 public 
plugin_init()
 {
    
register_clcmd"/setmodels1","Menu");
    
register_event("ResetHUD","ModelReset","b")
 }
 public 
Menu(id)
 {
    new 
menu menu_create("\rSet Player's Models:""menu_handler");
    
menu_additem(menu"\wGolb""1"0);
    
menu_additem(menu"\wSmith""2"0);
    
menu_additem(menu"\wNeo""3"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
 }
 public 
menu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
    
golb[id] = true
        
}
        case 
2:
        {
            
smith[id] = true
        
}
        case 
3:
        {
            
neo[id] = true
        
}
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 }
 public 
resetModel(id)
 {
    if(
golb[id]) {
 
cs_set_user_model(id"golb")
    }
    
    if(
smith[id]) {
 
cs_set_user_model(id"smith")
    }  
    
    if(
neo[id]) {
 
cs_set_user_model(id"neo")
    }


I have precached the models in another plugin. They're ok.

fysiks 08-14-2011 17:56

Re: Setting models on the moment, not on next spawn
 
Quote:

Originally Posted by dreamedward (Post 1532514)
But my problem is that when i choose one of the options the models don't change at exactly that moment. They change on next round and on round end they don't go back to the normal.

That's [almost] exactly how you have it coded. Set the user model when you want it to be set (and not in an event).

For setting it back you need to hook round end and loop through all players and reset their model.

dreamedward 08-14-2011 18:20

Re: Setting models on the moment, not on next spawn
 
Ok, for the looping i can do it but how can i reset the models back?

fysiks 08-14-2011 18:27

Re: Setting models on the moment, not on next spawn
 
Quote:

Originally Posted by dreamedward (Post 1532648)
Ok, for the looping i can do it but how can i reset the models back?

You search.

Are you sure they don't reset automatically?

dreamedward 08-15-2011 05:17

Re: Setting models on the moment, not on next spawn
 
You're awesome!


All times are GMT -4. The time now is 07:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.