Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Баг в плагине [ZP] Extra Item: Respawn

, Помогите пофиксить
Статус пользователя Slackerok
сообщение 25.5.2013, 14:48
Сообщение #1
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

Всем привет! Парни помогите пофиксить баг в плагине [ZP] Extra Item : Respawn

Человек когда находится в спектаторах, напишет /zspawn и возродится) Подскажите как проверку сделать чтобы плагин блокировал возрождение спектаторов.

Код:
/*
/
/
/ [ZP] Extra Item : Respawn
/ (ability for Humans and Zombies)
/
/ by Fry!
/
/
/ Description :
/
/ With this ability You can respawn Your self every time when You want (only if You are dead).
/ Remember that this will cost to You small fee of ammo packs. Possibility to respawn in Nemesis mode.
/ Added new feature called Late Join. If you join in server and game is almost in middle and you have to wait until round ends.
/ Not anymore cuz now you are able to Join in game whenever you want.
/
/
/
/ Cvars :
/
/ zp_respawn_cost "15" - How much it gonna cost to You
/ zp_respawn_time "2" - How much seconds gonna take untill You respawn
/ zp_late_join_respawn_time "15.0" - When you will respawn if you are late, default after 15 seconds.
/
/
/
/ Command :
/
/ say /zspawn to buy this ability or
/ say_team /zspawn
/
/ If You are Late Joined :
/
/ say /latejoin
/ say_team /latejoin
/
/
/
/ Credits :
/
/ Antibots - For helping
/ G-Dog - I borrowed some code from his coding style.
/ Dores - Helped with Late Join function
/
/
/
/ Changelog :
/
/ 19/10/2008 - v1.0 - First release
/ 20/10/2008 - v1.1 - removed fun module added hamsandwich ( Thanks to Antibots ) module changed some lines.
/ 23/10/2008 - v1.2 - rewrited plugin from crapy to new one ;) and added some cvars
/ 24/10/2008 - v1.2.1 - changed command from /respawn to /zspawn and plugin name.
/ 25/10/2008 - v1.2.5 - fixed respawn not working, fixed some cvars, fixed plugin name typo, optimized code.
/ 25/10/2008 - v1.2.7 - removed one toggle cvar and unnecessary line that zombies can't buy this ability.
/ 19/11/2008 - v1.3 - fixed respawn not working because of toggle cvar (lol) so I removed, fixed forgaten cvar due you could waste ammo packs, now zombies can respawn too.
/ 09/01/2009 - v1.4 - Fixed some previous bugs (could respawn always), added new feature Late Join respawn
/
/
/
*/



#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item : Zspawn"
#define VERSION "1.4"
#define AUTHOR "Fry!"

new g_item_name[] = { "Respawn" }
new g_itemid_respawn, g_respawn_cost, g_respawn_time
new g_late_join_respawn_time

new bool:g_canRespawn[33]

new Float:g_gameTime
new bool:g_justConnected[33]


public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_cvar("zp_extra_zspawn",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)

g_respawn_cost = register_cvar("zp_respawn_cost", "6")
g_respawn_time = register_cvar("zp_respawn_time", "2.0")
g_late_join_respawn_time = register_cvar("zp_late_join_respawn_time", "15.0")

register_clcmd("say /zspawn", "buy_respawn")
register_clcmd("say_team /zspawn", "buy_respawn")
register_clcmd("say /latespawn", "late_join")
register_clcmd("say_team /latespawn", "late_join")

register_event("DeathMsg", "Death", "a")
register_logevent("ev_roundStart", 2, "1=Round_Start")

g_itemid_respawn = zp_register_extra_item(g_item_name, get_pcvar_num(g_respawn_cost), 0)
}

public client_connect(id)
{
g_canRespawn[id] = false
g_justConnected[id] = true
}

public client_disconnect(id)
{
g_canRespawn[id] = false
}

public ev_roundStart()
{
g_gameTime = get_gametime() // To check how much time has passed since round start.
}

public Death()
{
new player = read_data( 2 )

if ( g_canRespawn[player] )
set_task(get_pcvar_float(g_respawn_time), "respawn_player", player)

}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_respawn)
{
if ( !is_user_alive(player) && !zp_get_user_zombie(player) && zp_get_user_zombie(player))
{
g_canRespawn[player] = true
respawn_player(player)
client_print(player, print_chat, "[ZP] You have purchased a respawn ability")
}
}
}

public buy_respawn(id)
{
if ( is_user_alive(id) )
{
g_canRespawn[id] = false
client_print(id, print_chat, "[ZP] Only Dead people can purchase respawn ability", get_pcvar_num(g_respawn_cost))

return PLUGIN_HANDLED
}

if ( g_canRespawn[id] )
{
zp_set_user_ammo_packs( id, zp_get_user_ammo_packs(id) + get_pcvar_num(g_respawn_cost) )
client_print(id, print_chat, "[ZP] You already have a respawn ability")
return PLUGIN_CONTINUE
}

new money = zp_get_user_ammo_packs(id)

if ( money < get_pcvar_num(g_respawn_cost))
{
client_print(id, print_chat, "[ZP] You don't have enough ammo packs to buy this ability", get_pcvar_num(g_respawn_cost))
return PLUGIN_HANDLED
}

zp_set_user_ammo_packs(id, money - get_pcvar_num(g_respawn_cost))

g_canRespawn[id] = true
respawn_player(id)
client_print(id, print_chat, "[ZP] You have purchased a respawn ability")

return PLUGIN_CONTINUE
}

public late_join(id)
{
if ( is_user_alive(id) )
{
client_print(id, print_chat, "[ZP] Only dead and Late Joined players can respawn")
return PLUGIN_HANDLED
}

if ( g_justConnected[id] )
{
set_task( get_pcvar_float(g_late_join_respawn_time), "joinedTeam", id )
g_justConnected[id] = false
client_print(id, print_chat, "[ZP] You will respawn after %d seconds", get_pcvar_num(g_late_join_respawn_time) )
}

return PLUGIN_CONTINUE
}

public joinedTeam(id)
{
new Float:gmtm = get_gametime()

// Check if the player is too late to join.
if ( gmtm - g_gameTime >= get_pcvar_float(g_late_join_respawn_time) && get_user_team( id ) != 3 )
{
ExecuteHamB(Ham_CS_RoundRespawn, id)
client_print(id, print_chat, "[ZP] You have just been respawned due to late join.")
}

return PLUGIN_CONTINUE
}

public respawn_player(id)
{
ExecuteHamB(Ham_CS_RoundRespawn, id);
g_canRespawn[id] = false
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя 3apuk
сообщение 25.5.2013, 16:33
Сообщение #2
Стаж: 14 лет

Сообщений: 106
Благодарностей: 24
Полезность: 181

в public buy_respawn(id)

if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
{
g_canRespawn[id] = false
client_print( id, print_chat, "Ты не можешь возродиться, так как находишься в команде Спектаторов" )
return PLUGIN_HANDLED
}

и подключи инклуд

include <cstrike>

Отредактировал: 3apuk, - 25.5.2013, 16:34
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Nickk
сообщение 25.5.2013, 16:35
Сообщение #3
Стаж: 13 лет

Сообщений: 438
Благодарностей: 120
Полезность: 523

Код:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item : Zspawn"
#define VERSION "1.4"
#define AUTHOR "Fry!"

new g_item_name[] = { "Respawn" }
new g_itemid_respawn, g_respawn_cost, g_respawn_time
new g_late_join_respawn_time

new bool:g_canRespawn[33]

new Float:g_gameTime
new bool:g_justConnected[33]


public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_cvar("zp_extra_zspawn",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)

g_respawn_cost = register_cvar("zp_respawn_cost", "6")
g_respawn_time = register_cvar("zp_respawn_time", "2.0")
g_late_join_respawn_time = register_cvar("zp_late_join_respawn_time", "15.0")

register_clcmd("say /zspawn", "buy_respawn")
register_clcmd("say_team /zspawn", "buy_respawn")
register_clcmd("say /latespawn", "late_join")
register_clcmd("say_team /latespawn", "late_join")

register_event("DeathMsg", "Death", "a")
register_logevent("ev_roundStart", 2, "1=Round_Start")

g_itemid_respawn = zp_register_extra_item(g_item_name, get_pcvar_num(g_respawn_cost), 0)
}

public client_connect(id)
{
g_canRespawn[id] = false
g_justConnected[id] = true
}

public client_disconnect(id)
{
g_canRespawn[id] = false
}

public ev_roundStart()
{
g_gameTime = get_gametime() // To check how much time has passed since round start.
}

public Death()
{
new player = read_data( 2 )

if ( g_canRespawn[player] )
set_task(get_pcvar_float(g_respawn_time), "respawn_player", player)

}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_respawn)
{
if ( !is_user_alive(player) && !zp_get_user_zombie(player) && zp_get_user_zombie(player))
{
g_canRespawn[player] = true
respawn_player(player)
client_print(player, print_chat, "[ZP] You have purchased a respawn ability")
}
}
}

public buy_respawn(id)
{
if(cs_get_user_team(id) == 3)
{
return PLUGIN_HANDLED
}

if ( is_user_alive(id) )
{
g_canRespawn[id] = false
client_print(id, print_chat, "[ZP] Only Dead people can purchase respawn ability", get_pcvar_num(g_respawn_cost))

return PLUGIN_HANDLED
}

if ( g_canRespawn[id] )
{
zp_set_user_ammo_packs( id, zp_get_user_ammo_packs(id) + get_pcvar_num(g_respawn_cost) )
client_print(id, print_chat, "[ZP] You already have a respawn ability")
return PLUGIN_CONTINUE
}

new money = zp_get_user_ammo_packs(id)

if ( money < get_pcvar_num(g_respawn_cost))
{
client_print(id, print_chat, "[ZP] You don't have enough ammo packs to buy this ability", get_pcvar_num(g_respawn_cost))
return PLUGIN_HANDLED
}

zp_set_user_ammo_packs(id, money - get_pcvar_num(g_respawn_cost))

g_canRespawn[id] = true
respawn_player(id)
client_print(id, print_chat, "[ZP] You have purchased a respawn ability")

return PLUGIN_CONTINUE
}

public late_join(id)
{
if ( is_user_alive(id) )
{
client_print(id, print_chat, "[ZP] Only dead and Late Joined players can respawn")
return PLUGIN_HANDLED
}

if ( g_justConnected[id] )
{
set_task( get_pcvar_float(g_late_join_respawn_time), "joinedTeam", id )
g_justConnected[id] = false
client_print(id, print_chat, "[ZP] You will respawn after %d seconds", get_pcvar_num(g_late_join_respawn_time) )
}

return PLUGIN_CONTINUE
}

public joinedTeam(id)
{
new Float:gmtm = get_gametime()

// Check if the player is too late to join.
if ( gmtm - g_gameTime >= get_pcvar_float(g_late_join_respawn_time) && get_user_team( id ) != 3 )
{
ExecuteHamB(Ham_CS_RoundRespawn, id)
client_print(id, print_chat, "[ZP] You have just been respawned due to late join.")
}

return PLUGIN_CONTINUE
}

public respawn_player(id)
{
ExecuteHamB(Ham_CS_RoundRespawn, id);
g_canRespawn[id] = false
}


Отредактировал: Nickk, - 25.5.2013, 16:38
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 25.5.2013, 18:02
Сообщение #4
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

3apuk,
Nickk,

Спасибо! Пойду протестирую)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Тема закрытаНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: