Raised This Month: $ Target: $400
 0% 

Function Crashing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Specialist
BANNED
Join Date: Nov 2006
Old 11-27-2006 , 19:04   Function Crashing
Reply With Quote #1

Ok. I have this almost working correctly. It brings up m menu blocks my use button . And I think It un-blocks it the way i want. But when it cmes to either the explosion or the removing the bomb it crashes. And theres no errors in my logs. Any ideas ? Thank You.

Code:
  #include <amxmodx> #include <fakemeta> #define TE_EXPLOSION 3 new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3; new g_Switch; new i; new Sprite; public plugin_init() {  register_plugin("Cut The Right Wire","0.1","The Speicialist");  g_Switch = register_cvar("ctrw_switch","1");  register_menucmd(register_menuid("menu_show"),1023,"menu_choose");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_Without_Kit");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_With_Kit");  register_forward(FM_PlayerPreThink,"block_buttons"); } // detect defusing public bomb_defuse_no_kit() {  new id = get_loguser_index();    if(get_pcvar_num(g_Switch)==0)  {   return 0;  }else{   new menu[192];   format(menu,191,"Choose The Right Wire Or Die!^n1. Red^n2. Blue^n3. Green^n^n0. Die");   show_menu(id,keys,menu,-1,"menu_show");   ++i;   return PLUGIN_CONTINUE;  }  return PLUGIN_CONTINUE; } // remove use button and show menu public menu_choose(id,key) {  new const Time = get_cvar_num("mp_c4timer");  new wire = random(2);  switch(key)  {   case 0 :   {    if( wire == 0 )    {     --i     set_cvar_num("mp_c4timer",(Time + 10));     return PLUGIN_HANDLED;    }else{     bomb_explosion();     return PLUGIN_HANDLED;    }   }   case 1:   {    if( wire == 1)    {     --i     set_cvar_num("mp_c4timer",(Time + 10 ));     return PLUGIN_HANDLED;    }else{     bomb_explosion();     return PLUGIN_HANDLED;    }   }   case 2 :   {    if( wire == 2 )    {     --i     set_cvar_num("mp_c4timer",(Time + 10 ));     return PLUGIN_HANDLED;    }else{     bomb_explosion();     return PLUGIN_HANDLED;    }   }  }  set_cvar_num("mp_c4timer",Time);  return PLUGIN_HANDLED; } // block the users use button public block_buttons(id) {  if( i == 0 )  {   return FMRES_HANDLED;  }else{   set_pev( id, pev_button, pev(id,pev_button) & ~IN_USE);  }  return PLUGIN_HANDLED; } //bomb explosion public bomb_explosion() {  new Bomb = fm_find_ent_by_model(-1,"grenade","models/c4.mdl");  new Location = pev(Bomb, pev_origin);  message_begin(MSG_BROADCAST,SVC_TEMPENTITY)  write_byte(TE_EXPLOSION)  write_coord(Location)  write_coord(Location)  write_coord(Location)  write_short(Sprite)  write_byte(1)  write_byte(0)  write_byte(0)  message_end()  engfunc(EngFunc_RemoveEntity, Bomb); } // function to get index from log events public get_loguser_index() {  new loguser[80], name[32];  read_logargv(0, loguser, 79);  parse_loguser(loguser, name, 31);  return get_user_index(name); } // finding entity by model public  fm_find_ent_by_model(index, const classname[], const model[]) {  new ent = index, mdl[72];  while ((ent = engfunc(EngFunc_FindEntityByString, index, "classname", classname)))  {   pev(ent, pev_model, mdl, 71);   if (equal(mdl, model))   {    return ent;   }  }  return 0 } //precache sprites for exloasion public plugin_precache() {  Sprite = precache_model("sprites/zerogxplode.spr"); }

Last edited by The Specialist; 11-27-2006 at 20:38.
The Specialist is offline
Send a message via AIM to The Specialist
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-27-2006 , 21:05   Re: Function Crashing
Reply With Quote #2

Check to make sure you found a valid entity in bomb_explosion(). A simple check such as:

Code:
if (!myent) {      // Code... }

or

Code:
if (!pev_valid(myent))      return;
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 11-27-2006 at 21:25.
Zenith77 is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-27-2006 , 21:47   Re: Function Crashing
Reply With Quote #3

Thanks For the help Zenith . Is this the right way to use pev_valid ??
Code:
#include <amxmodx> #include <fakemeta> #define TE_EXPLOSION 3 new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3; new g_Switch; new i; new Sprite; public plugin_init() {  register_plugin("Cut The Right Wire","0.1","The Speicialist");  g_Switch = register_cvar("ctrw_switch","1");  register_menucmd(register_menuid("menu_show"),1023,"menu_choose");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_Without_Kit");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_With_Kit");  register_forward(FM_PlayerPreThink,"block_buttons"); } // detect defusing public bomb_defuse_no_kit() {  new id = get_loguser_index();    if(get_pcvar_num(g_Switch)==0)  {   return 1;  }else{   new menu[192];   format(menu,191,"Choose The Right Wire Or Die!^n1. Red^n2. Blue^n3. Green^n^n0. Die");   show_menu(id,keys,menu,-1,"menu_show");   ++i;   return 0;  }  return 0; } // remove use button and show menu public menu_choose(id,key) {  new const Time = get_cvar_num("mp_c4timer");  new wire = random(2);  switch(key)  {   case 0 :   {    if( wire == 0 )    {     --i     set_cvar_num("mp_c4timer",(Time + 10));     return 1;    }else{     bomb_explosion();     return 1;    }   }   case 1:   {    if( wire == 1)    {     --i     set_cvar_num("mp_c4timer",(Time + 10 ));     return 1;    }else{     bomb_explosion();     return 1    }   }   case 2 :   {    if( wire == 2 )    {     --i     set_cvar_num("mp_c4timer",(Time + 10 ));     return 1;    }else{     bomb_explosion();     return 1;    }   }  }  set_cvar_num("mp_c4timer",Time);  return 1; } // block the users use button public block_buttons(id) {  if( i == 0 )  {   return 1;  }else{   set_pev( id, pev_button, pev(id,pev_button) & ~IN_USE);  }  return 1; } //bomb explosion public bomb_explosion() {  new Bomb = fm_find_ent_by_model(-1,"grenade","models/c4.mdl");  new Location = pev(Bomb, pev_origin);  if( pev_valid(Bomb))  {   message_begin(MSG_BROADCAST,SVC_TEMPENTITY);   write_byte(TE_EXPLOSION);   write_coord(Location);   write_coord(Location);   write_coord(Location);   write_short(Sprite);   write_byte(1);   write_byte(0);   write_byte(0);   message_end();   engfunc(EngFunc_RemoveEntity, Bomb);   return 0;  }  return 1; } // function to get index from log events public get_loguser_index() {  new loguser[80], name[32];  read_logargv(0, loguser, 79);  parse_loguser(loguser, name, 31);  return get_user_index(name); } // finding entity by model public  fm_find_ent_by_model(index, const classname[], const model[]) {  new ent = index, mdl[72];  while ((ent = engfunc(EngFunc_FindEntityByString, index, "classname", classname)))  {   pev(ent, pev_model, mdl, 71);   if (equal(mdl, model))   {    return ent;   }  }  return 0; } //precache sprites for exloasion public plugin_precache() {  Sprite = precache_model("sprites/zerogxplode.spr"); }

If so then it didnt work becasue it still crashed my server . Its only crashing during explosion/bomb removal stll .
The Specialist is offline
Send a message via AIM to The Specialist
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-28-2006 , 00:28   Re: Function Crashing
Reply With Quote #4

Code:
new Float:Location[3] pev(Bomb,pev_origin,Location)   engfunc(EngFunc_WriteCoord,Location[0]) engfunc(EngFunc_WriteCoord,Location[1]) engfunc(EngFunc_WriteCoord,Location[2])
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-28-2006 , 08:00   Re: Function Crashing
Reply With Quote #5

hmmm. That crashed too. Is there something wrong with the way I removed the bomb ? Or my find entity by model function ?
The Specialist is offline
Send a message via AIM to The Specialist
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 11-28-2006 , 08:21   Re: Function Crashing
Reply With Quote #6

Code:
new Float:Location[3] pev(Bomb, pev_origin, Location); if( pev_valid(Bomb)) {   message_begin(MSG_BROADCAST,SVC_TEMPENTITY);   write_byte(TE_EXPLOSION);   write_coord(floatround(Location[0]));   write_coord(floatround(Location[1]));   write_coord(floatround(Location[2]));   write_short(Sprite);   write_byte(1);   write_byte(0);   write_byte(0);   message_end();   engfunc(EngFunc_RemoveEntity, Bomb);   return 0; }
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-28-2006 , 09:35   Re: Function Crashing
Reply With Quote #7

Ok i got it to stop crashing . But now the probem seems to be that my function bomb_explosion is not being executed. Or maybee the first statement is and then its canceled. It doesnt explode or remove the bomb . But it doesnt crash. So why isnt it executing the second statement in my exlosion_function ?
Code:
#include <amxmodx> #include <fakemeta_util> #define TE_EXPLOSION 3 new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3; new g_Switch; new i; new Sprite; new Float:  Location[3]; public plugin_init() {  register_plugin("Cut The Right Wire","0.1","The Speicialist");  g_Switch = register_cvar("ctrw_switch","1");  register_menucmd(register_menuid("menu_show"),1023,"menu_choose");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_Without_Kit");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_With_Kit");  register_forward(FM_PlayerPreThink,"block_buttons"); } // detect defusing public bomb_defuse_no_kit() {  new id = get_loguser_index();    if(get_pcvar_num(g_Switch)==0)  {   return 1;  }else{   new menu[192];   format(menu,191,"Choose The Right Wire Or Die!^n1. Red^n2. Blue^n3. Green^n^n0. Die");   show_menu(id,keys,menu,-1,"menu_show");   ++i;   return 0;  }  return 0; } // remove use button and show menu public menu_choose(id,key) {  new wire = random(2);  switch(key)  {   case 0 :   {    if( wire == 0 )    {     --i;     return 1;    }else{     bomb_explosion();     return 1;    }   }   case 1:   {    if( wire == 1)    {     --i;     return 1;    }else{     bomb_explosion();     return 1    }   }   case 2 :   {    if( wire == 2 )    {     --i;     return 1;    }else{     bomb_explosion();     return 1;    }   }  }  return 1; } // block the users use button public block_buttons(id) {  if( i == 0 )  {   return 1;  }else{   set_pev( id, pev_button, pev(id,pev_button) & ~IN_USE);  }  return 1; } //bomb explosion public bomb_explosion() {  new Bomb = fm_find_ent_by_model(-1,"grenade","models/c4.mdl");  pev(Bomb, pev_origin,Location);  if( !pev_valid(Bomb))  {   return 1;  }else{   message_begin(MSG_BROADCAST,SVC_TEMPENTITY);   write_byte(TE_EXPLOSION);   write_coord(floatround(Location[0]));   write_coord(floatround(Location[1]));   write_coord(floatround(Location[2]));   write_short(Sprite);   write_byte(1);   write_byte(0);   write_byte(0);   message_end();   engfunc(EngFunc_RemoveEntity, Bomb);   i = 0;   return 1;  }  return 1; } // function to get index from log events public get_loguser_index() {  new loguser[80], name[32];  read_logargv(0, loguser, 79);  parse_loguser(loguser, name, 31);  return get_user_index(name); } //precache sprites for exloasion public plugin_precache() {  Sprite = precache_model("sprites/zerogxplode.spr"); }
The Specialist is offline
Send a message via AIM to The Specialist
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-28-2006 , 12:00   Re: Function Crashing
Reply With Quote #8

Some suggestions, put your pev_valid() check before you get the origin, and use EngFunc_WriteCoord as suggested before.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-28-2006 , 14:14   Re: Function Crashing
Reply With Quote #9

Ok. I remved the pev_valid() and now my explosion works. apprenatly my bomb entity wasnt valid. So i wont check it . now how can I make the explosion as big as the c4 explosion and make it do damage ??? And its still not removing the bomb thanks again .
The Specialist is offline
Send a message via AIM to The Specialist
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-28-2006 , 17:09   Re: Function Crashing
Reply With Quote #10

This can easily found out with the following.
  1. Use a logging tool to catch the TE_EXPLOSION message, or it could also be another message and see what size CS puts for it.
  2. Look at other plugins and use their damage code to simulate the bomb. Or, this will take some investigative work, figure out how the bomb knows when to explode. It could be set off by thinking (unlikely because it beeps), or by storing a value in it's pev feild and decrement it.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Reply


Thread Tools
Display Modes

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 06:55.


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