AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Round Start Error (https://forums.alliedmods.net/showthread.php?t=48817)

The Specialist 12-20-2006 22:52

Round Start Error
 
Ok Im trying t fix this plugin to get approved. I changed alot of it . But on round start , everyone dies including me then it does the lightning. Can you tell me whas wrong here ?
Thanks

Code:
#include <amxmodx> #include <fakemeta> new g_Switch; new g_TSamari; new g_CTSamari; new sprite; new origin[3]; new Lightning; new VictomOrigin[3]; new AttackerOrigin[3]; new Weapon; new frags; public plugin_init() {  register_plugin("The Samari","0.3","The Specialist");  g_Switch = register_cvar("smr_switch","1");    register_event("HLTV", "RoundStart", "a", "1=0", "2=0");  register_event("CurWeapon","SamariModel","be","1=1");  register_event("Damage" , "SamariDamage" , "be");    register_forward(FM_PlayerPreThink,"MakeSamariSmoke");  Lightning = engfunc(EngFunc_PrecacheModel,"sprites/lgtning.spr");  sprite = engfunc(EngFunc_PrecacheModel,"sprites/steam1.spr");  engfunc(EngFunc_PrecacheModel,"models/v_samari.mdl");  engfunc(EngFunc_PrecacheModel,"models/player/ninja.mdl"); } public RoundStart() {  if(get_pcvar_num(g_Switch))  g_CTSamari = 0;  g_TSamari = 0;    new Terrorist[32],T_num;  get_players(Terrorist,T_num,"ace","TERRORIST");  g_TSamari = Terrorist[random_num(0,T_num-1)];    new CTs[32],CT_num;  get_players(CTs,CT_num,"ace","CT");  g_CTSamari = CTs[random_num(0,CT_num-1)]; } public MakeSamariSmoke(id) {  if((g_CTSamari == id || g_TSamari == id) && ( pev(id,pev_button) &  IN_USE  ))  pev(id,pev_origin,origin);  message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);  write_byte(5);  engfunc(EngFunc_WriteCoord,origin[0]);  engfunc(EngFunc_WriteCoord,origin[1]);  engfunc(EngFunc_WriteCoord,origin[2]);  write_short(sprite);  write_byte(255);  write_byte(0);  message_end();  return FMRES_IGNORED; } public SamariModel(id) {  Weapon = read_data(2)    if((g_CTSamari == id || g_TSamari  == id) && ( Weapon == CSW_KNIFE))  set_pev( id, pev_viewmodel2,"models/v_samari.mdl");  set_pev(id,pev_model,"models/ninja.mdl");  set_pev(id,pev_maxspeed,330.0);  return ; } public SamariDamage(id) {  new Samari_Damage = read_data( 2 ) + 55;  new AttackerID = get_user_attacker( id, Weapon );  new Float:fAHealth;  new Float:fVHealth ;    if((Weapon == CSW_KNIFE) && (AttackerID == g_CTSamari || AttackerID == g_TSamari ) && (is_user_connected(AttackerID)))  pev(AttackerID,pev_health, fAHealth);  pev(id,pev_health, fVHealth);  set_pev(AttackerID,pev_health, fAHealth + fVHealth );  pev(id,pev_origin,VictomOrigin);  pev(AttackerID,pev_origin,AttackerOrigin);    message_begin( MSG_BROADCAST, SVC_TEMPENTITY)  write_byte(8);  write_short(AttackerID);  write_short(id);  write_short(Lightning);  write_byte(0)  write_byte(0);  write_byte(25);  write_byte(30);  write_byte(10);    write_byte(255);  write_byte(255);  write_byte(255)  write_byte(255);  write_byte(0);  message_end();    if ((is_user_alive(id)) && (fVHealth < Samari_Damage))  pev(AttackerID, pev_frags, frags);  set_pev(AttackerID, pev_frags, ++frags);  dllfunc(DLLFunc_ClientKill, id);  return 1; }

Simon Logic 12-21-2006 08:32

Re: Round Start Error
 
try register_event("Damage" , "SamariDamage" , "be", "2!0", "4!0"), i'm not sure why coordinate x must not equal to 0. Or try just "2!0".

Damage msg can be called when there is no actual damage.

ADDED:

Heh, I wrote in one of my tests a comment:
Quote:

// NOTE: when fall damage is applied coordinates are zero
Memory is unreliable thing.

The Specialist 12-21-2006 17:30

Re: Round Start Error
 
thats not the problem . The damage event worked on version 0.2 . I didnt change that .

P34nut 12-21-2006 17:34

Re: Round Start Error
 
first:
dont precache stuff in plugin_init()

i dont think itll precache it anyway (itll give a warning: Precaching not allowed)

instead of this: set_pev(id,pev_model,"models/ninja.mdl");
use engfunc(EngFunc_SetModel, id, "models/ninja.mdl"); but if id is a player you need to put ninja in the models/player directory and use cs_set_user_model() (for cs) or other native

The Specialist 12-21-2006 17:47

Re: Round Start Error
 
hi Peanut :)

the engfunc precache in the registery , does work , in fact I got that from Jim Yang .

As for the model , I tried that before , But it kills me right at the begining of the round , right as soon as I spawn , so it doesnt give it a chance to set the model , everyone dies . :cry:

P34nut 12-21-2006 18:03

Re: Round Start Error
 
Quote:

Originally Posted by The Specialist (Post 418265)
the engfunc precache in the registery , does work , in fact I got that from Jim Yang .

Dont do it its stupid.. precache need to be done at the very first point (mapload)

The Specialist 12-21-2006 18:05

Re: Round Start Error
 
I like it that way though . I wonder why Jim Yang does it like that ?:cry:
Can you see why it kills everyone on round start ?

P34nut 12-21-2006 18:11

Re: Round Start Error
 
i cant find it so fast.. but there are sooooo many mistakes in that piece of code

examples:
missing { and } (a lot);
frags is a float;
ORIGIN IS A FLOAT (me and VEN already said that to you a few times);
precache in plugin_precache()


Fix this and ill look again

The Specialist 12-21-2006 18:56

Re: Round Start Error
 
the reason I dont make origin a flaot is because it works when i did it as a interger . I ve never seen frags as a flaot .oops your right about frags just noticed that . let me add some brackets and see if the conditions
work .

Heres What I have now , but it doesnt set the player model .
Code:
#include <amxmodx> #include <fakemeta> new g_Switch; new g_TSamari; new g_CTSamari; new sprite; new origin[3]; new Lightning; new VictomOrigin[3]; new AttackerOrigin[3]; new Weapon; new Float:frags; public plugin_init() {  register_plugin("The Samari","0.3","The Specialist");  g_Switch = register_cvar("smr_switch","1");    register_event("HLTV", "RoundStart", "a", "1=0", "2=0");  register_event("CurWeapon","SamariModel","be","1=1");  register_event("Damage" , "SamariDamage" , "be");    register_forward(FM_PlayerPreThink,"MakeSamariSmoke"); } public RoundStart() {  if(get_pcvar_num(g_Switch))  {   g_CTSamari = 0;   g_TSamari = 0;     new Terrorist[32],T_num;   get_players(Terrorist,T_num,"ace","TERRORIST");   g_TSamari = Terrorist[random_num(0,T_num-1)];     new CTs[32],CT_num;   get_players(CTs,CT_num,"ace","CT");   g_CTSamari = CTs[random_num(0,CT_num-1)];   return;  } } public MakeSamariSmoke(id) {  if((g_CTSamari == id || g_TSamari == id) && ( pev(id,pev_button) &  IN_USE  ))  {    pev(id,pev_origin,origin);   message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);   write_byte(5);   engfunc(EngFunc_WriteCoord,origin[0]);   engfunc(EngFunc_WriteCoord,origin[1]);   engfunc(EngFunc_WriteCoord,origin[2]);   write_short(sprite);   write_byte(255);   write_byte(0);   message_end();   return;  } } public SamariModel(id) {  Weapon = read_data(2)    if((g_CTSamari == id || g_TSamari  == id) && ( Weapon == CSW_KNIFE))  {   set_pev( id, pev_viewmodel2,"models/v_samari.mdl");   engfunc(EngFunc_SetModel,id,"models/player/ninja.mdl");   set_pev(id,pev_maxspeed,330.0);   return ;  } } public SamariDamage(id) {  new Samari_Damage = read_data( 2 ) + 55;  new AttackerID = get_user_attacker( id, Weapon );  new Float:fAHealth;  new Float:fVHealth ;    if((Weapon == CSW_KNIFE) && (AttackerID == g_CTSamari || AttackerID == g_TSamari ) && (is_user_connected(AttackerID)))  {   pev(AttackerID,pev_health, fAHealth);   pev(id,pev_health, fVHealth);   set_pev(AttackerID,pev_health, fAHealth + fVHealth );   pev(id,pev_origin,VictomOrigin);   pev(AttackerID,pev_origin,AttackerOrigin);     message_begin( MSG_BROADCAST, SVC_TEMPENTITY)   write_byte(8);   write_short(AttackerID);   write_short(id);   write_short(Lightning);   write_byte(0)   write_byte(0);   write_byte(25);   write_byte(30);   write_byte(10);     write_byte(255);   write_byte(255);   write_byte(255)   write_byte(255);   write_byte(0);   message_end();     if ((is_user_alive(id)) && (fVHealth < Samari_Damage))   {    pev(AttackerID, pev_frags, frags);    set_pev(AttackerID, pev_frags, ++frags);    dllfunc(DLLFunc_ClientKill, id);    return 1;   }  }  return 1; } public plugin_precache() {  precache_model("models/player/ninja.mdl");  precache_model("models/v_samari.mdl");  Lightning = precache_model("sprites/lgtning.spr");  sprite = precache_model("sprites/steam1.spr"); }

jim_yang 12-21-2006 23:31

Re: Round Start Error
 
If I had told you that before, I was definitely having drugs that time.


All times are GMT -4. The time now is 22:30.

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