AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random ID on New Round (https://forums.alliedmods.net/showthread.php?t=48227)

The Specialist 12-07-2006 20:17

Random ID on New Round
 
Ok im trying to pick 2 players randomly each round , 1 T and 1 CT , and make them a samari , set there knife model to the samari and so on . but this doesnt seem to work . It precaches the model , but its not setting. Thanks :wink:

Code:
#include <amxmodx> #include <fakemeta_util> #define TE_SMOKE 5 #define TE_LIGHTNING 7 new g_Switch; new g_TSamari[33]; new g_CTSamari[33]; new sprite; new origin[3]; new Lightning; new VictomOrigin[3]; new AttackerOrigin[3]; new Weapon; public plugin_init() {  register_plugin("The Samari","0.1","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_forward(FM_PlayerPreThink,"MakeSamariSmoke");  register_event("Damage" , "SamariDamage" , "b"); } // round start random players public RoundStart(id) {  if(get_pcvar_num(g_Switch))  {   new Terrorist[32],T_num;   get_players(Terrorist,T_num,"ace","TERRORIST");   g_TSamari[id] = Terrorist[random_num(0,T_num-1)];     new CTs[32],CT_num;   get_players(CTs,CT_num,"ace","CT");   g_CTSamari[id] = CTs[random_num(0,CT_num -1)];  }  return; } // make the samari smoke 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(TE_SMOKE);   write_coord(origin[0]);   write_coord(origin[1]);   write_coord(origin[2]);   write_short(sprite);   write_byte(255);   write_byte(0);   message_end();  } } // give the samari a model public SamariModel(id) {  new Weapon = read_data(2)  if(g_CTSamari[id] || g_TSamari[id] && Weapon == CSW_KNIFE)  {   engfunc(EngFunc_SetModel,id,"models/v_samari.mdl");   return 0;  }  return 0; } // damage by the samarai sword public SamariDamage(id) {  new Damage = read_data( 2 );  new AttackerID = get_user_attacker( id, Weapon );  new Samari_Damage = Damage + 55 ;  new AHealth = get_user_health(AttackerID);  new VHealth = get_user_health(id);    if(Weapon == CSW_KNIFE && (AttackerID == g_CTSamari[id] || g_TSamari[id]))  {   fm_fakedamage(id,"weapon_knife",float(Samari_Damage),DMG_SLASH && DMG_BLAST);   return;  }  if( VHealth < Samari_Damage)  {   pev(id,pev_health,AHealth + VHealth );   pev(id,pev_origin,VictomOrigin);   pev(AttackerID,pev_origin,AttackerOrigin);   message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);   write_byte(TE_LIGHTNING);   write_coord(VictomOrigin[0]);   write_coord(VictomOrigin[1]);   write_coord(VictomOrigin[2]);   write_coord(AttackerOrigin[0]) ;   write_coord(AttackerOrigin[1]);   write_coord(AttackerOrigin[2]);   write_byte(50);   write_byte(15);   write_byte(15);   write_short(Lightning);   message_end();  } } // precache file needed public plugin_precache() {  Lightning = precache_model("sprites/laserbeam.spr");  sprite = precache_model("sprites/steam1.spr");  precache_model("models/v_samari.mdl"); }

Emp` 12-07-2006 21:07

Re: Random ID on New Round
 
Code:

// round start random players
public RoundStart(id)
{
 if(get_pcvar_num(g_Switch))
 {
  new Terrorist[32],T_num;
  get_players(Terrorist,T_num,"ace","TERRORIST");
  g_TSamari[id] = Terrorist[random_num(0,T_num-1)];
 
  new CTs[32],CT_num;
  get_players(CTs,CT_num,"ace","CT");
  g_CTSamari[id] = CTs[random_num(0,CT_num -1)];
 }
 return;
}

id is not passed into RoundStart, and also since you don't have the id, here more of what you should do
Code:

g_CTSamari[CTs[random_num(0,CT_num-1)]] = 1 //or you could make it a boolean and set it to true, but 1 will work as well
//then you'll want to do something of the same nature with the Ts

//also, while looking through youre code, you have many if statements that will not work how you want the to
//examples:
//if(a == b || c)
//  is not the same as
//if(a==b || a==c)
//
//also
//if(a || b && c)
//  is not the same as
//if( ( a || b ) && c)

edit: also note that youll want to reset the last players Samari status to 0/1 by doing something of this nature before you assign a new Samari
Code:

for(new i=0; i<33; i++){
  g_CTSamari[i] = 0//or false if youre going to use a boolean
  g_TSamari[i] = 0
}


The Specialist 12-07-2006 22:58

Re: Random ID on New Round
 
good idea. i dont quit understand what to do about the random. So your saying that my if conditions are the reason its not working properly ?

But i dint use a round start , round start uses a logevent which doesnt pass id's . im using New round event which is defierant and does pass id's. According to Vens tutorial on this . So what should i do to make it randomly choose a player on ct and t ?:|

Emp` 12-07-2006 23:18

Re: Random ID on New Round
 
i told you...

Code:

CTs[random_num(0,CT_num-1)]
would give you a random player, your just using the wrong id for g_CTSamari and assigning it to the random player.

The Specialist 12-08-2006 00:09

Re: Random ID on New Round
 
thats what i did have for a random player. but i dont understand how im giving it the wrong id ??

jim_yang 12-08-2006 00:23

Re: Random ID on New Round
 
there's no parameter passed through RoundStart event
so RoundStart(id) this id is some value or maybe 0, i'm not sure.

random(t_num) == random_num(0, t_num-1)

jim_yang 12-08-2006 00:25

Re: Random ID on New Round
 
if you only want a t and a ct , you just need to do this
g_TSamari = Terrorist[random(T_num)];
g_CTSamari = CTs[random(CT_num)];

The Specialist 12-08-2006 01:28

Re: Random ID on New Round
 
Quote:

Originally Posted by jim_yang (Post 412177)
there's no parameter passed through RoundStart event
so RoundStart(id) this id is some value or maybe 0, i'm not sure.

random(t_num) == random_num(0, t_num-1)

once again im NOT using Round start. round start and New Round are 2 completly difernat events. round start is a logevent , new round is an event that has id's the same way as curent weapon id does.

http://forums.alliedmods.net/showthread.php?t=42159

But you think it will work if i dont use [id] ?

Emp` 12-08-2006 02:08

Re: Random ID on New Round
 
um... ya... http://www.amxmodx.org/funcwiki.php?...vent&go=search

still think it passes the id?

anyway, if you are to use jim_yang's method, you will need to change all your g_CTSamurai[id] to g_CTSamurai==id and same goes for T

The Specialist 12-08-2006 02:28

Re: Random ID on New Round
 
So how is it that curweapon events can have id as a paramter ? acording to VEN the only events that DONT have ID's passed are logevents.

anyways, well i got part of it working . my smoke for the samari works , after fuckign with it like jim said. but my models arnt setting any idea why ? can i use engfunc to set a weapon model ?:|


All times are GMT -4. The time now is 06:50.

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