Raised This Month: $ Target: $400
 0% 

Need help for this code


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ds811888
BANNED
Join Date: Mar 2009
Location: Hong Kong
Old 04-08-2009 , 03:02   Re: Need help for this code
Reply With Quote #4

Code:
humanme(id, survivor)
{
 // Pre user humanize forward
 ExecuteForward(g_fwUserHumanized_pre, g_fwDummyResult, id)
 
 // Reset some vars
 g_zombie[id] = false
 g_nemesis[id] = false
 g_firstzombie[id] = false
 g_nodamage[id] = false
 g_canbuy[id] = true
 g_nvision[id] = false
 g_nvisionenabled[id] = false
 
 // Set human attributes based on the mode
 if (survivor)
 {
  // Survivor
  g_survivor[id] = true
  
  // Get survivor health setting
  static survhealth, survbasehealth
  survhealth = get_pcvar_num(cvar_survhp)
  survbasehealth = get_pcvar_num(cvar_survbasehp)
  
  // Set Health [0 = auto]
  if (survhealth == 0)
  {
   if (survbasehealth == 0)
    fm_set_user_health(id, get_pcvar_num(cvar_humanhp)*fnGetAlive())
   else
    fm_set_user_health(id, survbasehealth*fnGetAlive())
  }
  else
   fm_set_user_health(id, survhealth)
  
  // Set Gravity
  set_pev(id, pev_gravity, get_pcvar_float(cvar_survgravity))
  
  // Get survivor's weapon setting
  static survweapon[32]
  get_pcvar_string(cvar_survweapon, survweapon, sizeof survweapon - 1)
  
  // Strip survivor from weapons and give him his own
  fm_strip_user_weapons(id)
  fm_give_item(id, "weapon_knife")
  fm_give_item(id, survweapon)
  
  // Turn off his flashlight
  turn_off_flashlight(id)
  
  // Give the survivor a bright light
  if (get_pcvar_num(cvar_survaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  
  // Survivor bots will also need nightvision to see in the dark
  if (is_user_bot(id)) fm_set_bot_nvg(id, 1);
 }
 else
 {
  // Human taking an antidote
  
  // Set health
  fm_set_user_health(id, get_pcvar_num(cvar_humanhp))
  
  // Set gravity, unless frozen
  if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity)) 
  
  // Strip off from weapons
  fm_strip_user_weapons(id)
  fm_give_item(id, "weapon_knife")
  
  // Show custom buy menu?
  if (get_pcvar_num(cvar_buycustom))
   set_task(0.4, "show_menu_buy1", id+TASK_SPAWN)
  
  // Antidote sound
  engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_antidote[random_num(0, sizeof sound_antidote - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  
  // Get player's name
  static name[32]
  get_user_name(id, name, sizeof name - 1)
  
  // Show Antidote HUD notice
  set_hudmessage(0, 0, 255, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_ANTIDOTE", name)
 } 
 
 // Remove previous tasks
 remove_task(id+TASK_TEAM)
 remove_task(id+TASK_MODEL)
 remove_task(id+TASK_BLOOD)
 
 // Switch to CT
 if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
 {
  fm_set_user_team(id, CS_TEAM_CT)
  fm_user_team_update(id)
 }
 
 #if defined HANDLE_MODELS_ON_SEPARATE_ENT
 
 // Set the right model
 if (g_survivor[id])
  copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_survivor[random_num(0, sizeof model_survivor -1)])
 else
 {
  if (get_pcvar_num(cvar_adminmodelshuman) && get_user_flags(id) & ACCESS_FLAG3)
   copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin[random_num(0, sizeof model_admin -1)])
  else
   copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_human[random_num(0, sizeof model_human -1)])
 }
 
 // Set model on player model entity
 fm_set_playermodel_ent(id)
 
 // Set survivor glow / remove glow, unless frozen
 if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
 else if (!g_frozen[id])
  fm_set_rendering(g_ent_playermodel[id])
 
 #else
 
 // Set the right model, after checking that we don't already have it
 static currentmodel[32], already_has_model, i, iRand
 already_has_model = false;
 
 // Get current model and compare it with current one
 fm_get_user_model(id, currentmodel, sizeof currentmodel - 1);
 
 if (g_survivor[id])
 {
  for (i = 0; i < sizeof model_survivor; i++)
   if (equal(model_survivor[i], currentmodel)) already_has_model = true;
  
  if (!already_has_model)
  {
   iRand = random_num(0, sizeof model_survivor -1)
   copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_survivor[iRand])
   #if defined SET_MODELINDEX_OFFSET
   fm_set_user_model_index(id, g_modelindex_survivor[iRand])
   #endif
  }
 }
 else
 {
  if (get_pcvar_num(cvar_adminmodelshuman) && get_user_flags(id) & ACCESS_FLAG3)
  {
   for (i = 0; i < sizeof model_admin; i++)
    if (equal(model_admin[i], currentmodel)) already_has_model = true;
   
   if (!already_has_model)
   {
    iRand = random_num(0, sizeof model_admin -1)
    copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin[iRand])
    #if defined SET_MODELINDEX_OFFSET
    fm_set_user_model_index(id, g_modelindex_admin[iRand])
    #endif
   }
  }
  else
  {
   for (i = 0; i < sizeof model_human; i++)
    if (equal(model_human[i], currentmodel)) already_has_model = true;
   
   if (!already_has_model)
   {
    iRand = random_num(0, sizeof model_human -1)
    copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_human[iRand])
    #if defined SET_MODELINDEX_OFFSET
    fm_set_user_model_index(id, g_modelindex_human[iRand])
    #endif
   }
  }
 }
 
 // Need to change the model?
 if (!already_has_model)
 {
  // An additional delay is offset at round start
  // since SVC_BAD is more likely to be triggered there
  if (g_newround)
   set_task(5.0*MODELCHANGE_DELAY, "fm_user_model_update", id+TASK_MODEL)
  else
   fm_user_model_update(id+TASK_MODEL)
 }
 
 // Set survivor glow / remove glow, unless frozen
 if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
 else if (!g_frozen[id])
  fm_set_rendering(id)
 
 #endif
 
 // Get FOV setting
 static fov
 fov = get_pcvar_num(cvar_zombiefov)
 
 // Restore FOV?
 if (fov != 90 && fov != 0)
 {
  message_begin(MSG_ONE, g_msgSetFOV, _, id)
  write_byte(90) // angle
  message_end()
 }
 
 // Disable nightvision
 if (is_user_bot(id)) fm_set_bot_nvg(id, 0)
 else if (!get_pcvar_num(cvar_cnvg)) set_user_gnvision(id, 0)
 
 // Post user humanize forward
 ExecuteForward(g_fwUserHumanized_post, g_fwDummyResult, id)
 
 // Last Zombie Check
 set_task(0.1, "fnCheckLastZombie")
}
Code:
fnGetRandomAlive(n)
{
 static iAlive, id
 iAlive = 0
 
 for (id = 1; id <= g_maxplayers; id++)
 {
  if (is_user_alive(id))
   iAlive++
  
  if (iAlive == n)
   return id;
 }
 
 return -1;
}
ds811888 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 02:21.


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