Raised This Month: $ Target: $400
 0% 

No Respawn Chance if recconect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kikifrh
Senior Member
Join Date: May 2009
Old 11-30-2009 , 10:31   No Respawn Chance if recconect
Reply With Quote #1

This is the original sma
Code:
/* Random Respawn Chance
 * by Bo0m!
 * www.Chaos-Realms.com
 * Created 5-08-2006
 * Last update: 8-09-2006
 * 
 * With this plugin you have a random chance to respawn by saying:
 * respawn me
 * respawnme
 * revive me
 * reviveme
 * /revive
 * /reviveme
 * 
 * The chance for you to respawn is set by spawnchance_odds
 * Example: If you want a 1 in 50 chance to respawn, set spawnchance_odds to 50
 * The default is a 1 in 10 chance you will respawn.
 * 
 * By default there is a 150 second (2.5 minute) wait between times you can try to respawn
 * This can be changed by spawnchance_wait
 * 
 * A feature has been added that can give admins a bit of a bonus (if they have immunity)
 * Admins can either have no wait time, or always win a respawn regardless of the odds
 * spawnchance_adminbonus 1 gives admins no waiting to try and respawn
 * spawnchance_adminbonus 2 makes admins win a respawn every time
 * By default this feature if off
 * 
 * A message is displayed to notify players that they have a chance to respawn
 * It is displayed every 75 seconds by default
 * This can be changed with spawnchance_msgtime
 * Messages can be enabled/disabled with spawnchance_msg
 * 
 * To enable/disable this plugin use the cvar spawnchance_on
 * 
 * Notes:
 * This is my first attempt at a plugin :)
 * Some parts of this plugin are based on Striker's Advanced Roll The Dice
 * 
 * 
 * **************************************************************************************
 * Changelog
 * 
 * v0.9 - Knocked off the 'amx_' prefix on cvars (They're long enough already)
 *    - Changed amx_spawnchance cvar to spawnchance_on
 *    - Fixed problem where you'd lose your chance if respawned when the round's over
 * 
 * v0.8 - Added special feature for admins by request
 *    - Fixed bug with wait cvar
 * 
 * v0.7 - Fixed bug with message cvar
 *    - Changed default message time cvar
 *    - Removed /respawnme
 * 
 * v0.6 - Added a cvar to choose time between respawn message
 * 
 * v0.5 - Added a message to notify players about the respawn chance
 *    - Added cvar spawnchance_msg to enable/disable message
 *    - Added reviveme and revive me
 * 
 * v0.4 - Minor bug fix
 *    - Changed how the odds reset if less than 2 or greater than 1000
 *    - Changed defaulting if too low/high to changing to least/most 
 * 
 * v0.3 - Made it to reset odds to default if less than 2 or greater than 1000
 * 
 * v0.2 - Fixed bug where spectators could respawn
 *    - Decreased default wait time and increased default winning odds
 *    - Added /revive and /reviveme
 *   - Gave player a knife on respawn due to certain map issues
 * 
 * v0.1 - Initial Release
 *
 * **************************************************************************************
 * And let's not forget:
 *
 * Random Respawn Chance (respawnchance.sma)
 * Copyright (C) 2006  Bo0m!
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * In addition, as a special exception, the author gives permission to
 * link the code of this program with the Half-Life Game Engine ("HL
 * Engine") and Modified Game Libraries ("MODs") developed by Valve,
 * L.L.C ("Valve"). You must obey the GNU General Public License in all
 * respects for all of the code used other than the HL Engine and MODs
 * from Valve. If you modify this file, you may extend this exception
 * to your version of the file, but you are not obligated to do so. If
 * you do not wish to do so, delete this exception statement from your
 * version.
 */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
new Float:LastSpawnAttempt[33]
new bool:RoundEnded = false
public plugin_init()
{ 
 register_plugin("Random Respawn Chance", "0.9", "Bo0m!")
 register_clcmd("say", "spawnchance")
 register_cvar("spawnchance_on","1")
 register_cvar("spawnchance_msg","1")
 register_cvar("spawnchance_msgtime","75") 
 register_cvar("spawnchance_odds","10")
 register_cvar("spawnchance_wait","150")
 register_cvar("spawnchance_adminbonus","0")
 register_logevent("event_RoundStarted", 2, "1=Round_Start")
 register_logevent("event_RoundEnded", 2, "1=Round_End")
}
public plugin_precache()
{
 precache_sound("debris/beamstart9.wav")
}
public client_putinserver(id)
{
 if(is_user_bot(id)) 
  return PLUGIN_HANDLED
 set_task(20.0, "spawnmessage", id)
 LastSpawnAttempt[id] = -5000.0
 return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
 if(is_user_bot(id)) 
  return PLUGIN_HANDLED
 LastSpawnAttempt[id] = -5000.0
 return PLUGIN_CONTINUE
}
public event_RoundStarted()
{
 RoundEnded = false
}
public event_RoundEnded()
{
 RoundEnded = true
}
public spawnagain(id)
{
 spawn(id)
 give_item(id,"weapon_knife")
 return PLUGIN_CONTINUE
}
public spawnmessage(id)
{
 if (!get_cvar_num("spawnchance_on") || !get_cvar_num("spawnchance_msg"))
 return PLUGIN_HANDLED
 if(get_cvar_num("spawnchance_msgtime") < 10)
 {
  server_cmd ("spawnchance_msgtime 10")
  return PLUGIN_CONTINUE
 }
 if(is_user_connected(id)) client_print(id, print_chat, "[Respawn Chance] You have a 1 in %d chance to revive when dead! Say reviveme for your chance!",get_cvar_num("spawnchance_odds"))
 set_task(get_cvar_float("spawnchance_msgtime"), "spawnmessage", id)
 return PLUGIN_HANDLED
}
public spawnchance(id)
{
 new Speech[192]
 read_args(Speech,192)
 remove_quotes(Speech)
 if(get_cvar_num("spawnchance_odds") < 2)
 {
  server_cmd ("spawnchance_odds 2")
  return PLUGIN_CONTINUE
 }
 if(get_cvar_num("spawnchance_odds") > 1000)
 {
  server_cmd ("spawnchance_odds 1000")
  return PLUGIN_CONTINUE
 }
 if(get_cvar_num("spawnchance_wait") < 0)
 {
  server_cmd ("spawnchance_wait 0")
  return PLUGIN_CONTINUE
 }
 if(get_cvar_num("spawnchance_wait") > 5000)
 {
  server_cmd ("spawnchance_wait 5000")
  return PLUGIN_CONTINUE
 }
 if(spawnchance2(id,Speech)) 
 return PLUGIN_HANDLED
 return PLUGIN_CONTINUE
}
public spawnchance2(id,Speech[])
{
 if (get_cvar_num("spawnchance_adminbonus") == 1 && (get_user_flags(id) & ADMIN_IMMUNITY) )
 {
  LastSpawnAttempt[id] = -5000.0
 }
 if ( (equali(Speech, "respawnme")) || (equali(Speech, "reviveme")) || (equali(Speech, "revive me")) || (equali(Speech, "/revive")) || (equali(Speech, "/reviveme")) || (equali(Speech, "respawn me")) )
 {
  if (get_cvar_num("spawnchance_on") == 0)
  {
   client_print(id, print_chat, "Respawning is currently disabled.")
   return PLUGIN_HANDLED
  }
  if (cs_get_user_team(id) == CS_TEAM_SPECTATOR)
  {
   client_print(id, print_chat, "Spectators can't respawn silly!.")
   return PLUGIN_HANDLED
  }
  if (RoundEnded == true)
  {
   client_print(id, print_chat, "The round ended, you don't want to waste your chance!.")
   return PLUGIN_HANDLED
  }
  if (is_user_alive(id) == 1)
  {
   client_print(id,print_chat, "You have to be dead before you can attempt to respawn!")
   return PLUGIN_HANDLED
  }
  else if (get_gametime() < LastSpawnAttempt[id] + get_cvar_float("spawnchance_wait"))
  {
   client_print(id,print_chat, "Sorry you can't try to respawn now. Try again in %d seconds.",floatround(LastSpawnAttempt[id] + get_cvar_num("spawnchance_wait") - get_gametime() + 1))
   return PLUGIN_HANDLED
  }
  new ChanceAmount = random(get_cvar_num("spawnchance_odds"))
  new User[32]
  get_user_name(id,User,32)
 
  if (get_cvar_num("spawnchance_adminbonus") == 2 && (get_user_flags(id) & ADMIN_IMMUNITY) )
  {
   client_cmd(id,"spk debris/beamstart9")
   client_print(id,print_chat, "You win! Prepare to be respawned!")
   spawn(id)
   set_task(0.5,"spawnagain",id)
   set_hudmessage(200,0,0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s won and has been respawned!",User)
  }
  else
  {
   if (1 == ChanceAmount)
   {
    client_cmd(id,"spk debris/beamstart9")
    client_print(id,print_chat, "You win! Prepare to be respawned!")
    spawn(id)
    set_task(0.5,"spawnagain",id)
    set_hudmessage(200,0,0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
        show_hudmessage(0,"%s won and has been respawned!",User)
   }
   else if (ChanceAmount > 1)
   {
    client_print(id,print_chat, "Sorry, you didn't respawn this time!")
   }
   LastSpawnAttempt[id] = get_gametime()
   return PLUGIN_CONTINUE
  }
  return PLUGIN_CONTINUE
 }
 return PLUGIN_CONTINUE
}
I want to block the chance of respawn for the first round if the player recconected.
idk if scripting help is the right place, but it seems it is. I have a sma, and want help to edit. :X
thx in advance
kikifrh is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 11-30-2009 , 12:11   Re: No Respawn Chance if recconect
Reply With Quote #2

Well, this is a scripting help so this forum is to learn scripting... if you want to request something: http://forums.alliedmods.net/forumdisplay.php?f=12
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
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 13:43.


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