Raised This Month: $ Target: $400
 0% 

Spawning Pets via Menu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-13-2014 , 08:40   Spawning Pets via Menu
Reply With Quote #1

Hello everybody,

I wanted to edit GHW's Pets Plugin for a friend by adding a menu where you can choose a pet as a VIP User.
The problem is, when I click on any item in the menu, no pet spawns, but the client_print messages get printed in the chat.
Maybe I am missing something, can anyone help?

Code:
#include <amxmodx> #include <chr_engine> //#include <ColorChat> #define PET_NUM 6 #define VERSION "2.2" static const pet_name[PET_NUM][32] = {     "Rat",     "Bat",     "Frog",     "Cockroach",     "Fish",     "Controller" } static const pet_models[PET_NUM][32] = {     "models/bigrat.mdl",     "models/boid.mdl",     "models/chumtoad.mdl",     "models/roach.mdl",     "models/archer.mdl",     "models/controller.mdl" } static const pet_idle[PET_NUM] = {     1,     0,     0,     1,     0,     3 } static const Float:pet_idle_speed[PET_NUM] = {     1.0,     1.0,     1.0,     1.0,     1.0,     1.0 } static const pet_run[PET_NUM] = {     4,     0,     5,     0,     6,     9 } static const Float:pet_run_speed[PET_NUM] = {     6.0,     3.0,     0.75,     1.0,     0.6,     1.0 } static const pet_die[PET_NUM] = {     7,     0,     12,     0,     9,     18 } static const Float:pet_die_length[PET_NUM] = {     2.4,     0.1,     3.0,     0.1,     3.0,     7.0 } static const Float:pet_minus_z_standing[PET_NUM] = {     36.0,     5.0,     36.0,     36.0,     20.0,     0.0 } static const Float:pet_minus_z_crouching[PET_NUM] = {     16.0,     6.0,     16.0,     16.0,     30.0,     0.0 } static const Float:pet_max_distance[PET_NUM] = {     300.0,     300.0,     300.0,     300.0,     300.0,     800.0 } static const Float:pet_min_distance[PET_NUM] = {     80.0,     80.0,     80.0,     80.0,     80.0,     200.0 } new pet[33] new pettype[33] native is_user_vip(iPlayer) public plugin_init() {     register_plugin("GHW Pet Followers",VERSION,"GHW_Chronic")         register_clcmd( "say /pet", "PetMenu" )         register_event("DeathMsg","DeathMsg","a")     register_forward(FM_Think,"FM_Think_hook") } public plugin_precache() {     for(new i=0;i<PET_NUM;i++)         precache_model(pet_models[i]) } public client_disconnect(id) handle_DeathMsg(id) public DeathMsg() handle_DeathMsg(read_data(2)) public handle_DeathMsg(id) {     if(pet[id] && pev_valid(pet[id]))     {         set_pev(pet[id],pev_animtime,100.0)         set_pev(pet[id],pev_framerate,1.0)         set_pev(pet[id],pev_sequence,pet_die[pettype[id]])         set_pev(pet[id],pev_gaitsequence,pet_die[pettype[id]])         set_task(pet_die_length[pettype[id]],"remove_pet",pet[id])     }         pet[id]=0 } public remove_pet(ent) if(pev_valid(ent)) engfunc(EngFunc_RemoveEntity,ent) public pet_cmd_handle(id,num) {     if(pet[id])     {         client_print(id, print_chat, "You already have a Pet.")         handle_DeathMsg(id)     }         client_print(id, print_chat, "You do not have a pet.")     pet[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))     set_pev(pet[id],pev_classname,"GHW_Pet")     pettype[id] = num     engfunc(EngFunc_SetModel,pet[id],pet_models[pettype[id]])         new Float:origin[3]     pev(id,pev_origin,origin)         if(is_user_crouching(id))         origin[2] -= pet_minus_z_crouching[pettype[id]]     else         origin[2] -= pet_minus_z_standing[pettype[id]]             set_pev(pet[id],pev_origin,origin)     set_pev(pet[id],pev_solid,SOLID_NOT)     set_pev(pet[id],pev_movetype,MOVETYPE_FLY)     set_pev(pet[id],pev_owner,33)     set_pev(pet[id],pev_nextthink,1.0)     set_pev(pet[id],pev_sequence,0)     set_pev(pet[id],pev_gaitsequence,0)     set_pev(pet[id],pev_framerate,1.0)     client_print(id, print_chat, "You should have one now.") } public FM_Think_hook(ent) {     new players[32], pnum, tempid     get_players(players, pnum, "a")         for( new i; i<pnum; i++ )     {         tempid = players[i]                 if(ent==pet[tempid])         {             static Float:origin[3]             static Float:origin2[3]             static Float:velocity[3]                         pev(ent,pev_origin,origin2)             get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)                         if(is_user_crouching(i))                 origin[2] -= pet_minus_z_crouching[pettype[i]]             else                 origin[2] -= pet_minus_z_standing[pettype[i]]                         if(get_distance_f(origin,origin2)>pet_max_distance[pettype[i]])             {                 set_pev(ent,pev_origin,origin)             }             else if(get_distance_f(origin,origin2)>pet_min_distance[pettype[i]])             {                 get_speed_vector(origin2,origin,250.0,velocity)                 set_pev(ent,pev_velocity,velocity)                 if(pev(ent,pev_sequence)!=pet_run[pettype[i]] || pev(ent,pev_framerate)!=pet_run_speed[pettype[i]])                 {                     set_pev(ent,pev_frame,1)                     set_pev(ent,pev_sequence,pet_run[pettype[i]])                     set_pev(ent,pev_gaitsequence,pet_run[pettype[i]])                     set_pev(ent,pev_framerate,pet_run_speed[pettype[i]])                 }             }             else if(get_distance_f(origin,origin2)<pet_min_distance[pettype[i]] - 5.0)             {                 if(pev(ent,pev_sequence)!=pet_idle[pettype[i]] || pev(ent,pev_framerate)!=pet_idle_speed[pettype[i]])                 {                     set_pev(ent,pev_frame,1)                     set_pev(ent,pev_sequence,pet_idle[pettype[i]])                     set_pev(ent,pev_gaitsequence,pet_idle[pettype[i]])                     set_pev(ent,pev_framerate,pet_idle_speed[pettype[i]])                 }                 set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})             }             pev(i,pev_origin,origin)             origin[2] = origin2[2]             entity_set_aim(ent,origin)                         set_pev(ent,pev_nextthink,1.0)         }     } } public PetMenu( id ) {     if(!is_user_vip(id))         return PLUGIN_HANDLED         new menu = menu_create( "Swedish Cake Mafia^n\yChoose your pet", "PetMenuHandler" );         new iButton[ 3 ], szItemInfo[ 55 ];         for ( new i ; i < sizeof pet_name ; i ++ )     {         formatex( iButton, charsmax( iButton ), "%i", i );         formatex( szItemInfo, charsmax( szItemInfo ), "%s", pet_name[ i ] );                 menu_additem( menu, szItemInfo, iButton, 0);     }     menu_display( id, menu, 0 );         return PLUGIN_HANDLED } public PetMenuHandler( id, menu, item ) {     if ( item == MENU_EXIT )         return PLUGIN_HANDLED;         new szCommand[ 6 ] , szName[ 64 ];     new access , callback;         menu_item_getinfo( menu, item, access, szCommand, charsmax( szCommand ), szName, charsmax( szName ), callback );         new i = str_to_num( szCommand );         //ColorChat( id, GREY, "^x04[PlayGroundES]^x03: You chose %s pet.", pet_name[ i ] );         pet_cmd_handle( id, i );         return PLUGIN_HANDLED; }
__________________
Kia is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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