Raised This Month: $ Target: $400
 0% 

Random ID on New Round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Specialist
BANNED
Join Date: Nov 2006
Old 12-07-2006 , 20:17   Random ID on New Round
Reply With Quote #1

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

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"); }
The Specialist is offline
Send a message via AIM to The Specialist
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-07-2006 , 21:07   Re: Random ID on New Round
Reply With Quote #2

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
}

Last edited by Emp`; 12-07-2006 at 21:10.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
The Specialist
BANNED
Join Date: Nov 2006
Old 12-07-2006 , 22:58   Re: Random ID on New Round
Reply With Quote #3

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 ?
The Specialist is offline
Send a message via AIM to The Specialist
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-07-2006 , 23:18   Re: Random ID on New Round
Reply With Quote #4

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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 00:09   Re: Random ID on New Round
Reply With Quote #5

thats what i did have for a random player. but i dont understand how im giving it the wrong id ??
The Specialist is offline
Send a message via AIM to The Specialist
jim_yang
Veteran Member
Join Date: Aug 2006
Old 12-08-2006 , 00:23   Re: Random ID on New Round
Reply With Quote #6

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)
__________________
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
jim_yang
Veteran Member
Join Date: Aug 2006
Old 12-08-2006 , 00:25   Re: Random ID on New Round
Reply With Quote #7

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)];
__________________
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 12-08-2006 , 01:28   Re: Random ID on New Round
Reply With Quote #8

Quote:
Originally Posted by jim_yang View Post
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] ?
The Specialist is offline
Send a message via AIM to The Specialist
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-08-2006 , 02:08   Re: Random ID on New Round
Reply With Quote #9

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
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 02:28   Re: Random ID on New Round
Reply With Quote #10

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 ?
The Specialist is offline
Send a message via AIM to The Specialist
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:50.


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