AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   choosen model on respawn help (https://forums.alliedmods.net/showthread.php?t=56541)

flyeni6 06-15-2007 19:59

choosen model on respawn help
 
ok, in this code, there is a random model seceter(gives players random player models on respawn). When someone types "/haloskin" in chat a menu will come up and the player can select his/her skin color.
After they select their skin, the skin color turns the ways that they selected, which is good.

but when they respawn the the random model selector gives them a diff model.

can someone help
thx in advance

PHP Code:

#include <amxmodx>
#include <cstrike>
#define MAXMODELS 8
new models[MAXMODELS][] = 

 
"Halo_Blue",
 
"Halo_Green",
 
"Halo_Purple",
 
"Halo_Teal",
 
"Halo_Orange",
 
"Halo_Dark_Orange",
 
"Halo_Red",
 
"Halo_Yellow"
};

 
#define PLUGIN "omg models!"
#define VERSION "1.1"
#define AUTHOR "flyeni"
 
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR);
 
register_cvar("amx_randmodels""1");
 
register_event("ResetHUD","model","b");
 
register_clcmd"say /haloskin","halo_skin_menu")
}
public 
plugin_precache()
{
 
precache_model("models/player/Halo_Blue/Halo_Blue.mdl")
 
precache_model("models/player/Halo_Green/Halo_Green.mdl")
 
precache_model("models/player/Halo_Purple/Halo_Purple.mdl")
 
precache_model("models/player/Halo_Teal/Halo_Teal.mdl")
 
precache_model("models/player/Halo_Orange/Halo_Orange.mdl")
 
precache_model("models/player/Halo_Dark_Orange/Halo_Dark_Orange.mdl")
 
precache_model("models/player/Halo_Red/Halo_Red.mdl")
 
precache_model("models/player/Halo_Yellow/Halo_Yellow.mdl")
}
 
public 
model(id)
{  
  new 
random_model
  
if(cs_get_user_team(id) == CS_TEAM_CT
  {
   
random_model random_num(0,MAXMODELS-1);
   
cs_set_user_model(idmodels[random_model]);
   
set_hudmessage(3220232, -1.00.8806.012.0);
   
show_hudmessage(id"Random Skin: %s"models[random_model]);
 
  }
  else if(
cs_get_user_team(id) == CS_TEAM_T
  {  
   
random_model random_num(0,MAXMODELS-1);
   
cs_set_user_model(idmodels[random_model]);
   
set_hudmessage(3220232, -1.00.8806.012.0);
   
show_hudmessage(id"Random Skin: %s"models[random_model]);
 
  } 
}
public 
halo_skin_menu(id)
{
  new 
menu menu_create("\rHalo Slayer Skins:""menu_handler")
 
  
menu_additem(menu"\wBlue""1"0)
  
menu_additem(menu"\wGreen""2"0)
  
menu_additem(menu"\wPurple""3"0)
  
menu_additem(menu"\wTeal""4"0)
  
menu_additem(menu"\wOrange""5"0)
  
menu_additem(menu"\wDark Orange""6"0)
  
menu_additem(menu"\wRed""7"0)
  
menu_additem(menu"\wYellow""8"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], iName[64]
 new 
accesscallback
 
 menu_item_getinfo
(menuitemaccessdata,5iName63callback)
 new 
key str_to_num(data)
 switch(
key)
 {
  case 
1:
  {
   
cs_set_user_model(id"Halo_Blue")
 
   
set_hudmessage(4242255, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Blue")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Blue Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Blue Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
2:
  {
   
cs_set_user_model(id"Halo_Green")
 
   
set_hudmessage(3220232, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Green")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Green Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Green Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
3:
  {
   
cs_set_user_model(id"Halo_Purple")
 
   
set_hudmessage(1700255, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Purple")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Purple Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Purple Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
4:
  {
   
cs_set_user_model(id"Halo_Teal")
 
   
set_hudmessage(0127255, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Teal")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Teal Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Teal Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
5:
  {
   
cs_set_user_model(id"Halo_Orange")
   
set_hudmessage(2551270, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Orange")
   
client_print(idprint_chat"[Halo Mod] You Now Have An Orange Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have An Orange Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
6:
  {
   
cs_set_user_model(id"Halo_Dark_Orange")
   
set_hudmessage(255850, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Dark Orange")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Dark Orange Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Dark Orange Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
7:
  {
   
cs_set_user_model(id"Halo_Red")
   
set_hudmessage(25500, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Red")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Red Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Red Halo Skin Color")
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
  case 
8:
  {
   
cs_set_user_model(id"Halo_Yellow")
   
set_hudmessage(2552120, -1.00.8806.06.0);
   
show_hudmessage(id"Halo Skin: Yellow")
   
client_print(idprint_chat"[Halo Mod] You Now Have A Yellow Halo Skin Color")
   
client_print(idprint_console"[Halo Mod] You Now Have A Yellow Halo Skin Color")
 
   
menu_destroy(menu)
   return 
PLUGIN_HANDLED
  
}
 }
 
menu_destroy(menu)
 return 
PLUGIN_HANDLED



Rolnaaba 06-15-2007 23:08

Re: choosen model on respawn help
 
first of all, for correct catching of the PlayerSpawn event see here:
http://forums.alliedmods.net/showthread.php?t=42159

Second, you tell it to give them a different model, in your model() function you pick a random model which may be different form the one they choose with the menu...
If you want to have them get the same model upon respawn, store the model they pick with the menu and give them that model instead of a random one...


and change random_num(0, MAXMODELS-1) to random(MAXMODELS), because random() is used as follows:
Code:
random(max) //chooses random number from "0" to "max-1"

flyeni6 06-16-2007 12:13

Re: choosen model on respawn help
 
Quote:

Originally Posted by Rolnaaba (Post 490468)

Second, you tell it to give them a different model, in your model() function you pick a random model which may be different form the one they choose with the menu...
If you want to have them get the same model upon respawn, store the model they pick with the menu and give them that model instead of a random one...


how would i go about doing this?

Rolnaaba 06-16-2007 12:37

Re: choosen model on respawn help
 
...
Code:
#include <amxmodx> #include <cstrike> #define HALO_BLUE 0 #define HALO_GREEN 1 #define HALO_PURPLE 2 #define HALO_TEAL 3 #define HALO_ORANGE 4 #define HALO_DARK_ORANGE 5 #define HALO_RED 6 #define HALO_YELLOW 7 #define MAXMODELS 8 new models[MAXMODELS][] = {     "Halo_Blue",     "Halo_Green",     "Halo_Purple",     "Halo_Teal",     "Halo_Orange",     "Halo_Dark_Orange",     "Halo_Red",     "Halo_Yellow" };   #define PLUGIN "omg models!" #define VERSION "1.1" #define AUTHOR "flyeni" new ChosenModel[33]; //a varriable to store their chosen model in. public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_randmodels", "1");     register_event("ResetHUD","model","b");     register_clcmd( "say /haloskin","halo_skin_menu") } public plugin_precache() {     precache_model("models/player/Halo_Blue/Halo_Blue.mdl")     precache_model("models/player/Halo_Green/Halo_Green.mdl")     precache_model("models/player/Halo_Purple/Halo_Purple.mdl")     precache_model("models/player/Halo_Teal/Halo_Teal.mdl")     precache_model("models/player/Halo_Orange/Halo_Orange.mdl")     precache_model("models/player/Halo_Dark_Orange/Halo_Dark_Orange.mdl")     precache_model("models/player/Halo_Red/Halo_Red.mdl")     precache_model("models/player/Halo_Yellow/Halo_Yellow.mdl") }   public model(id) {     /* Dont do a random model!!     new random_model     if(cs_get_user_team(id) == CS_TEAM_CT) {         random_model = random_num(0,MAXMODELS-1);         cs_set_user_model(id, models[random_model]);         set_hudmessage(32, 202, 32, -1.0, 0.88, 0, 6.0, 12.0);         show_hudmessage(id, "Random Skin: %s", models[random_model]);       } else if(cs_get_user_team(id) == CS_TEAM_T) {           random_model = random_num(0,MAXMODELS-1);         cs_set_user_model(id, models[random_model]);         set_hudmessage(32, 202, 32, -1.0, 0.88, 0, 6.0, 12.0);         show_hudmessage(id, "Random Skin: %s", models[random_model]);       } */         //instead load the model they chose earlier:     cs_set_user_model(id, models[ChosenModel[id]]); } public halo_skin_menu(id) {     new menu = menu_create("\rHalo Slayer Skins:", "menu_handler")         menu_additem(menu, "\wBlue", "1", 0)     menu_additem(menu, "\wGreen", "2", 0)     menu_additem(menu, "\wPurple", "3", 0)     menu_additem(menu, "\wTeal", "4", 0)     menu_additem(menu, "\wOrange", "5", 0)     menu_additem(menu, "\wDark Orange", "6", 0)     menu_additem(menu, "\wRed", "7", 0)     menu_additem(menu, "\wYellow", "8", 0)     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)     menu_display(id, menu, 0) } public menu_handler(id, menu, item) {     if (item == MENU_EXIT) {         menu_destroy(menu)         return PLUGIN_HANDLED     }     new data[6], iName[64]     new access, callback       menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)     new key = str_to_num(data)     switch(key) {         case 1: {             cs_set_user_model(id, "Halo_Blue")               set_hudmessage(42, 42, 255, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Blue")             client_print(id, print_chat, "[Halo Mod] You Now Have A Blue Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Blue Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_BLUE;                         return PLUGIN_HANDLED         }         case 2: {             cs_set_user_model(id, "Halo_Green")               set_hudmessage(32, 202, 32, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Green")             client_print(id, print_chat, "[Halo Mod] You Now Have A Green Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Green Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_GREEN;                         return PLUGIN_HANDLED         }         case 3: {             cs_set_user_model(id, "Halo_Purple")               set_hudmessage(170, 0, 255, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Purple")             client_print(id, print_chat, "[Halo Mod] You Now Have A Purple Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Purple Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_PURPLE;                         return PLUGIN_HANDLED         }         case 4: {             cs_set_user_model(id, "Halo_Teal")               set_hudmessage(0, 127, 255, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Teal")             client_print(id, print_chat, "[Halo Mod] You Now Have A Teal Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Teal Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_TEAL;                         return PLUGIN_HANDLED         }         case 5: {             cs_set_user_model(id, "Halo_Orange")             set_hudmessage(255, 127, 0, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Orange")             client_print(id, print_chat, "[Halo Mod] You Now Have An Orange Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have An Orange Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_ORANGE;                         return PLUGIN_HANDLED         }         case 6: {             cs_set_user_model(id, "Halo_Dark_Orange")             set_hudmessage(255, 85, 0, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Dark Orange")             client_print(id, print_chat, "[Halo Mod] You Now Have A Dark Orange Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Dark Orange Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_DARK_ORANGE;                         return PLUGIN_HANDLED         }         case 7: {             cs_set_user_model(id, "Halo_Red")             set_hudmessage(255, 0, 0, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Red")             client_print(id, print_chat, "[Halo Mod] You Now Have A Red Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Red Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_RED;                         return PLUGIN_HANDLED         }         case 8: {             cs_set_user_model(id, "Halo_Yellow")             set_hudmessage(255, 212, 0, -1.0, 0.88, 0, 6.0, 6.0);             show_hudmessage(id, "Halo Skin: Yellow")             client_print(id, print_chat, "[Halo Mod] You Now Have A Yellow Halo Skin Color")             client_print(id, print_console, "[Halo Mod] You Now Have A Yellow Halo Skin Color")             menu_destroy(menu)                         //store their chosen model             ChosenModel[id] = HALO_YELLOW;                         return PLUGIN_HANDLED         }     }     menu_destroy(menu)     return PLUGIN_HANDLED }

flyeni6 06-16-2007 12:47

Re: choosen model on respawn help
 
thank you rolnaaba it works!

flyeni6 06-16-2007 12:51

Re: choosen model on respawn help
 
nvm i got it to work

Rolnaaba 06-16-2007 13:05

Re: choosen model on respawn help
 
what was wrong with it?

flyeni6 06-16-2007 13:20

Re: choosen model on respawn help
 
no lol i wanted it to work with random modeling and i got it to work.

thx for u help thou

Rolnaaba 06-16-2007 13:35

Re: choosen model on respawn help
 
np


All times are GMT -4. The time now is 10:32.

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