AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Animal Xp with changing model (https://forums.alliedmods.net/showthread.php?t=12575)

NiGHTFiRE 04-18-2005 14:26

Animal Xp with changing model
 
I'm trying to do Xuntrics animal xp plugin. I'm trying to do so if you choose the the animal dog you get to be a model that looks like a dog. here is my code:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define CLASS_NOTHING 0 #define CLASS_DOG 1 #define CLASS_CAT 2 #define CLASS_HORSE 3 #define CLASS_COW 4 #define MAXCLASSES 5 new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] new const CLASSES[MAXCLASSES][] = {     "None",     "Dog",     "Cat",     "Horse",     "Cow" } new msgtext new const LEVELS[6] = {     100,     200,     400,     800,     1600,     3200 } public plugin_precache() {    PlayerClass[id] = CLASS_DOG;    precache_model("models/animals/dog.mdl"); } public plugin_init() {     register_plugin("Animal Mod", "1.0", "XunTric")         register_cvar("sv_animalmod", "1")         register_event("DeathMsg", "DeathMsg", "a")         register_cvar("XP_per_kill", "20")         register_menucmd(register_menuid("menu_ChooseAnimal"),1023,"DoChooseAnimal");         register_event("ResetHUD", "ResetHud", "b")         msgtext = get_user_msgid("StatusText")     register_clcmd("say /changeanimal", "ChangeAnimal")     register_clcmd("say_team /changeanimal", "ChangeAnimal") } stock ChooseAnimal(id) {     new menu[192]     new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;         format(menu, 191, "Animal Mod: Choose Animal^n^n1. Dog^n2. Cat^n3. Horse^n4. Cow^n^n0. Exit")     show_menu(id, keys, menu, -1, "menu_ChooseAnimal")         return PLUGIN_CONTINUE } public DoChooseAnimal(id, key) {     if(key == 0) {                  if(PlayerClass[id] == CLASS_DOG) {                         client_print(id, print_chat, "[Animal Mod] You are allready a Dog! Choose something else!")               ChooseAnimal(id)                         return PLUGIN_HANDLED          }                  PlayerClass[id] = CLASS_DOG                  client_print(id, print_chat, "[Animal Mod] You are now a Dog!")               }                       if(key == 1) {                    if(PlayerClass[id] == CLASS_CAT) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Cat! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_CAT          client_print(id, print_chat, "[Animal Mod] You are now a Cat!")     }         if(key == 2) {                    if(PlayerClass[id] == CLASS_HORSE) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Horse! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_HORSE          client_print(id, print_chat, "[Animal Mod] You are now a Horse!")     }         if(key == 3) {                    if(PlayerClass[id] == CLASS_COW) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Cow! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_COW          client_print(id, print_chat, "[Animal Mod] You are now a Cow!")     }           ShowHUD(id)         return PLUGIN_HANDLED } public ResetHUD(id) {     if(PlayerClass[id] == CLASS_NOTHING) {              ChooseAnimal(id)          return PLUGIN_HANDLED     }         return PLUGIN_HANDLED } public DeathMsg() {     if(get_cvar_num("sv_animalmod") == 0) {          return PLUGIN_HANDLED     }         new attacker = read_data(1)         if(PlayerClass[attacker] == CLASS_NOTHING) {          return PLUGIN_HANDLED     }         if(PlayerLevel[attacker] == 6) {          return PLUGIN_HANDLED     }                 PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {                PlayerLevel[attacker] += 1                    client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])                    ShowHUD(attacker)     }           ShowHUD(attacker)         return PLUGIN_CONTINUE } public ShowHUD(id)     {     new HUD[51]     format(HUD, 50, "[%s]Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id])     message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end()     return }

I get this error: Error 017: Undefined symbol "id"

XunTric 04-18-2005 15:12

This might work...
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define CLASS_NOTHING 0 #define CLASS_DOG 1 #define CLASS_CAT 2 #define CLASS_HORSE 3 #define CLASS_COW 4 #define MAXCLASSES 5 new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] new const CLASSES[MAXCLASSES][] = {     "None",     "Dog",     "Cat",     "Horse",     "Cow" } new msgtext new const LEVELS[6] = {     100,     200,     400,     800,     1600,     3200 } public plugin_precache() {    precache_model("models/animals/dog.mdl") } public plugin_init() {     register_plugin("Animal Mod", "1.0", "XunTric")           register_cvar("sv_animalmod", "1")           register_event("DeathMsg", "DeathMsg", "a")           register_cvar("XP_per_kill", "20")           register_menucmd(register_menuid("menu_ChooseAnimal"),1023,"DoChooseAnimal");           register_event("ResetHUD", "ResetHud", "b")           msgtext = get_user_msgid("StatusText")     register_clcmd("say /changeanimal", "ChangeAnimal")     register_clcmd("say_team /changeanimal", "ChangeAnimal") } stock ChooseAnimal(id) {     new menu[192]     new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;           format(menu, 191, "Animal Mod: Choose Animal^n^n1. Dog^n2. Cat^n3. Horse^n4. Cow^n^n0. Exit")     show_menu(id, keys, menu, -1, "menu_ChooseAnimal")         return PLUGIN_CONTINUE } public DoChooseAnimal(id, key) {     if(key == 0) {                  if(PlayerClass[id] == CLASS_DOG) {                         client_print(id, print_chat, "[Animal Mod] You are allready a Dog! Choose something else!")               ChooseAnimal(id)                           return PLUGIN_HANDLED          }                  PlayerClass[id] = CLASS_DOG                    client_print(id, print_chat, "[Animal Mod] You are now a Dog!")               }                       if(key == 1) {                    if(PlayerClass[id] == CLASS_CAT) {                               client_print(id, print_chat, "[Animal Mod] You are allready a Cat! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_CAT          client_print(id, print_chat, "[Animal Mod] You are now a Cat!")     }           if(key == 2) {                    if(PlayerClass[id] == CLASS_HORSE) {                               client_print(id, print_chat, "[Animal Mod] You are allready a Horse! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_HORSE          client_print(id, print_chat, "[Animal Mod] You are now a Horse!")     }         if(key == 3) {                    if(PlayerClass[id] == CLASS_COW) {                               client_print(id, print_chat, "[Animal Mod] You are allready a Cow! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_COW          client_print(id, print_chat, "[Animal Mod] You are now a Cow!")     }             ShowHUD(id)           return PLUGIN_HANDLED } public ResetHUD(id) {     if(PlayerClass[id] == CLASS_NOTHING) {                ChooseAnimal(id)          return PLUGIN_HANDLED     }         if(is_user_alive(id) == 1) {          if(PlayerClass[id] == CLASS_DOG) {                   cs_set_user_model (id, "models/animals/dog.mdl")          }     }                     return PLUGIN_HANDLED } public DeathMsg() {     if(get_cvar_num("sv_animalmod") == 0) {          return PLUGIN_HANDLED     }           new attacker = read_data(1)           if(PlayerClass[attacker] == CLASS_NOTHING) {          return PLUGIN_HANDLED     }           if(PlayerLevel[attacker] == 6) {          return PLUGIN_HANDLED     }                   PlayerXP[attacker] += get_cvar_num("XP_per_kill")           if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {                PlayerLevel[attacker] += 1                    client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])                    ShowHUD(attacker)     }               ShowHUD(attacker)           return PLUGIN_CONTINUE } public ShowHUD(id)     {     new HUD[51]     format(HUD, 50, "[%s]Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id])     message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end()     return }

Heres what I did:
Code:
public ResetHUD(id) {     if(PlayerClass[id] == CLASS_NOTHING) {                ChooseAnimal(id)          return PLUGIN_HANDLED     }         if(is_user_alive(id) == 1) {          if(PlayerClass[id] == CLASS_DOG) {                   cs_set_user_model (id, "models/animals/dog.mdl")          }     }                     return PLUGIN_HANDLED }

NiGHTFiRE 04-18-2005 15:15

I got it to work when i did this:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define CLASS_NOTHING 0 #define CLASS_DOG 1 #define CLASS_CAT 2 #define CLASS_HORSE 3 #define CLASS_COW 4 #define MAXCLASSES 5 new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] new const CLASSES[MAXCLASSES][] = {     "None",     "Dog",     "Cat",     "Horse",     "Cow" } new msgtext new const LEVELS[6] = {     100,     200,     400,     800,     1600,     3200 } public plugin_init() { //registers important things     register_plugin("Animal Mod", "1.0", "XunTric")     register_cvar("sv_animalmod", "1")     register_event("DeathMsg", "DeathMsg", "a")     register_cvar("XP_per_kill", "20")     register_menucmd(register_menuid("menu_ChooseAnimal"),1023,"DoChooseAnimal");     register_event("ResetHUD", "ResetHud", "b")     msgtext = get_user_msgid("StatusText")     register_clcmd("say /changeanimal", "ChangeAnimal")     register_clcmd("say_team /changeanimal", "ChangeAnimal") } stock ChooseAnimal(id) {     new menu[192]     new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0;         format(menu, 191, "Animal Mod: Choose Animal^n^n1. Dog^n2. Cat^n3. Horse^n4. Cow^n^n0. Exit")     show_menu(id, keys, menu, -1, "menu_ChooseAnimal")         return PLUGIN_CONTINUE } public DoChooseAnimal(id, key) {     if(key == 0) {                  if(PlayerClass[id] == CLASS_DOG) {                         client_print(id, print_chat, "[Animal Mod] You are allready a Dog! Choose something else!")               ChooseAnimal(id)                         return PLUGIN_HANDLED          }                  PlayerClass[id] = CLASS_DOG                  client_print(id, print_chat, "[Animal Mod] You are now a Dog!")          precache_model("models/animals/dog.mdl");     }                       if(key == 1) {                    if(PlayerClass[id] == CLASS_CAT) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Cat! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_CAT          client_print(id, print_chat, "[Animal Mod] You are now a Cat!")     }         if(key == 2) {                    if(PlayerClass[id] == CLASS_HORSE) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Horse! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_HORSE          client_print(id, print_chat, "[Animal Mod] You are now a Horse!")     }         if(key == 3) {                    if(PlayerClass[id] == CLASS_COW) {                             client_print(id, print_chat, "[Animal Mod] You are allready a Cow! Choose something else!")               ChooseAnimal(id)               return PLUGIN_HANDLED          }                              PlayerClass[id] = CLASS_COW          client_print(id, print_chat, "[Animal Mod] You are now a Cow!")     }           ShowHUD(id)         return PLUGIN_HANDLED } public ResetHUD(id) {     if(PlayerClass[id] == CLASS_NOTHING) {              ChooseAnimal(id)          return PLUGIN_HANDLED     }         return PLUGIN_HANDLED } public DeathMsg() {     if(get_cvar_num("sv_animalmod") == 0) {          return PLUGIN_HANDLED     }         new attacker = read_data(1)         if(PlayerClass[attacker] == CLASS_NOTHING) {          return PLUGIN_HANDLED     }         if(PlayerLevel[attacker] == 6) {          return PLUGIN_HANDLED     }                 PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {                PlayerLevel[attacker] += 1                    client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])                    ShowHUD(attacker)     }           ShowHUD(attacker)         return PLUGIN_CONTINUE } public ShowHUD(id)     {     new HUD[51]     format(HUD, 50, "[%s]Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id])     message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end()     return }
I don't know if it will change model though bc I haven't tested the plugin i just got it to compile.

Xuntric is it ok if i add multilanguage and sql or vault and such things and make it a plugin. I will of course give you credits.

XunTric 04-18-2005 15:18

Copy and paste the code I told ya...
My code compiles.

You cant precache the model inside the menu?
You gotta do it in the plugin_precache()...


And yeh just make a animal plugin if you want.

NiGHTFiRE 04-18-2005 15:21

Code:
public DoChooseAnimal(id, key) {     if(key == 0) {                  if(PlayerClass[id] == CLASS_DOG) {                         client_print(id, print_chat, "[Animal Mod] You are allready a Dog! Choose something else!")               ChooseAnimal(id)                         return PLUGIN_HANDLED          }                  PlayerClass[id] = CLASS_DOG                  client_print(id, print_chat, "[Animal Mod] You are now a Dog!")          precache_model("models/animals/dog.mdl");     }

XunTric 04-18-2005 15:23

You cant precache models inside a menu.
You have to do it in the plugin_precache as you had in the first code.

And that only downloads the model (wont work where you placed it anyway), and does not change peoples models.

Copy and paste the code I said. That one compiles and should work.

n0obie4life 04-19-2005 09:35

remember to credit me :D. i thought of that idea :).

XunTric 04-19-2005 09:44

I only used the animal idea for a example on my tutorial...

Btw I added save XP now, but I cant have more small tags :S

Gotta get admins to help me...

NiGHTFiRE 04-19-2005 10:09

Ok cool, I'll look at your updated tutorial and I won't use the animals idea. I will use some thing else, noobie I'll give you credits too :D

XunTric 04-19-2005 11:00

Meh, he only gave a idea of a animal mod in a post where v3x asked for ideas of new mods...

I was allready making a tutorial, and saw that post and just used the animal mod as a example.

He didnt code anything...


All times are GMT -4. The time now is 09:58.

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