AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn Chance (bug/help) (https://forums.alliedmods.net/showthread.php?t=170934)

eliptics 10-30-2011 13:25

Respawn Chance (bug/help)
 
i found a bug on this plugin. you can say reviveme and if it didnt succeed you can reconnect and try again and so on.. please someone fix it ...
Thanks!

PHP Code:

#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(idprint_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") == && (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(idprint_chat"Respawning is currently disabled.")
   return 
PLUGIN_HANDLED
  
}
  if (
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
  {
   
client_print(idprint_chat"Spectators can't respawn silly!.")
   return 
PLUGIN_HANDLED
  
}
  if (
RoundEnded == true)
  {
   
client_print(idprint_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") == && (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.00.3006.06.00.50.151)
       
show_hudmessage(0,"%s won and has been respawned!",User)
  }
  else
  {
   if (
== 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.00.3006.06.00.50.151)
        
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


PLUGIN LINK
I dont understand nothing about coding but i think it is like this:
code...

//If a player reconnect show a message like that:
client_print(id,print_chat, "You cannot use reviveme because you reconnected!"

Jenkins 11-03-2011 07:22

Re: Respawn Chance (bug/help)
 
or you just add another plugin that doesnt allow reconnecting/retrying?

sake 11-03-2011 16:38

Re: Respawn Chance (bug/help)
 
Try to create a variable that holds information about if the player has already died this round or if he has ever died (I don't know the plugin and I don't know if the second version works, but it can be a clue).

eliptics 11-03-2011 17:14

Re: Respawn Chance (bug/help)
 
Quote:

Originally Posted by sake (Post 1589392)
Try to create a variable that holds information about if the player has already died this round or if he has ever died (I don't know the plugin and I don't know if the second version works, but it can be a clue).

THX, LOL but i dont understand nothing about coding.. but i think u are right :D
Can you do it?

quark 11-03-2011 18:32

Re: Respawn Chance (bug/help)
 
Quote:

Originally Posted by Jenkins (Post 1589031)
or you just add another plugin that doesnt allow reconnecting/retrying?


eliptics 11-13-2011 15:43

Re: Respawn Chance (bug/help)
 
Someone can help me?

Kreation 11-13-2011 18:48

Re: Respawn Chance (bug/help)
 
Quote:

Originally Posted by eliptics (Post 1596162)
Someone can help me?

If you don't know how to script, then you should be in Suggestions/Requests.

Dark Style 11-14-2011 09:38

Re: Respawn Chance (bug/help)
 
Quote:

Originally Posted by Kreation (Post 1596249)
If you don't know how to script, then you should be in Suggestions/Requests.



All times are GMT -4. The time now is 14:24.

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