Raised This Month: $ Target: $400
 0% 

Manager code help =)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.ThePro
Member
Join Date: Aug 2011
Location: Brazil
Old 05-08-2012 , 00:08   Manager code help =)
Reply With Quote #1

Can tell me if there are errors in this plugin?
If possible, I would like to optimize it.


Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define P "JB: Team Manager"
#define V "1.0"
#define A ".ThePro"

new vgui_enabled[33]

new g_maxplayers

new CsTeams:lastTeam[33]

public plugin_init()
{
register_plugin(P, V, A)

register_message(get_user_msgid("ShowMenu"), "message_menu")

register_menu("Jail Main Menu", MENU_KEY_1|MENU_KEY_2|MENU_KEY_3, "menu_Handler")

register_clcmd("jointeam", "clcmd_JoinTeam")
register_clcmd("chooseteam", "clcmd_ChosseTeam")

g_maxplayers = get_maxplayers()
}

public client_putinserver(id)
{
new vgui_active[2]
get_user_info(id, "_vgui_menus", vgui_active, charsmax(vgui_active))

if(str_to_num(vgui_active) == 1)
{
vgui_enabled[id] = 1
set_user_info(id, "_vgui_menus", "0")
}

set_task(1.0, "monitore_team_change", id, _, _, "b")
}
public client_disconnect(id)
{
vgui_enabled[id] = 0

if(cs_get_user_team(id) == CS_TEAM_CT && has_vacancy_ct())
{
client_print(0, print_chat, "[Jail Break] Ah vagas no time dos Guardas..")
}

remove_task(id)
}
teamChanged(id, CsTeams:team, CsTeams:last_team)
{ 
if(last_team == CS_TEAM_CT && team != CS_TEAM_CT && has_vacancy_ct())
{
client_print(0, print_chat, "[Jail Break] Ah vagas no time dos Guardas.")
}

if(id == 0) {} // Apenas para nao dar a mensagem que variavel nao foi usada
}


public message_menu(iMsgid, iDest, id)
{
new szMsgId[10]
num_to_str(iMsgid, szMsgId, charsmax(szMsgId))

new szText[50]
get_msg_arg_string(4, szText, charsmax(szText))


if(equal(szText, "#Team_Select") || equal(szText, "#Team_Select_Spect") || equal(szText, "#IG_Team_Select") || equal(szText, "#IG_Team_Select_Spect"))
{
set_task(0.1, "event_teamMenu_delay", id, szMsgId, charsmax(szMsgId))
return 1
}
else if(equal(szText, "#Terrorist_Select") || equal(szText, "#CT_Select"))
{
set_task(0.1, "event_classMenu_delay", id, szMsgId, charsmax(szMsgId))
return 1
}

return 0
}

public event_teamMenu_delay(params[], id)
{ 
new iMsgBlock = get_msg_block(params[0])
set_msg_block(params[0], BLOCK_SET)
engclient_cmd(id, "jointeam", "1")
cs_set_user_team(id, CS_TEAM_T)
set_msg_block(params[0], iMsgBlock)

set_user_info(id, "_vgui_menus", vgui_enabled[id]? "1" : "0") 
jail_menu(id)
}
public event_classMenu_delay(params[0], id)
{
new iMsgBlock = get_msg_block(params[0])
set_msg_block(params[0], BLOCK_SET)
engclient_cmd(id, "joinclass", "1")
set_msg_block(params[0], iMsgBlock)

set_user_info(id, "_vgui_menus", vgui_enabled[id]? "1" : "0") 
}

public jail_menu(id)
{
new szMenuBody[500], len, keys

len = formatex(szMenuBody, charsmax(szMenuBody), "Menu do servidor^n")

new CsTeams:team = cs_get_user_team(id)

if(team != CS_TEAM_T)
{
len += formatex(szMenuBody[len], charsmax(szMenuBody) - len, "^n\r1. \wEntrar para TR")
keys |= MENU_KEY_1
}
else len += formatex(szMenuBody[len], charsmax(szMenuBody) - len, "^n\d1. Entrar para TR")


if(team != CS_TEAM_CT && has_vacancy_ct())
{
len += formatex(szMenuBody[len], charsmax(szMenuBody) - len, "^n\r2. \wEntrar para CT")
keys |= MENU_KEY_2
}
else len += formatex(szMenuBody[len], charsmax(szMenuBody) - len, "^n\d2. Entrar para CT")


if(team == CS_TEAM_CT || team == CS_TEAM_T)
{
len += formatex(szMenuBody[len], charsmax(szMenuBody) - len, "^n\r3. \wContato")
keys |= MENU_KEY_3
}

show_menu(id, keys, szMenuBody, -1, "Jail Main Menu")
}
public menu_Handler(id, key)
{
switch(key)
{
case 0, 1:
{
if(key == 1 && !has_vacancy_ct())
{
client_print(id, print_chat, "[Jail Break] Nao ah vagas no time dos Guardas.")
jail_menu(id)
return
}

if(is_user_alive(id))
{
new deaths = cs_get_user_deaths(id)
user_kill(id)

new param[15]
num_to_str(deaths, param, charsmax(param))
set_task(0.1, "setOldDeaths", id, param, charsmax(param))
}

cs_set_user_team(id, key + 1)
}
case 2:
{
client_print(id, print_center, "Informacao nao definida, editar SMA")
}

}

}
public setOldDeaths(param[], id)
{ 
cs_set_user_deaths(id, str_to_num(param))
}

public clcmd_JoinTeam(id)
{
return 1
}
public clcmd_ChosseTeam(id)
{
jail_menu(id)

return 1
}



bool:has_vacancy_ct()
{ 
new total_ct, total_tr

new i
for(i = 1; i <= g_maxplayers; i++)
{
if(!is_user_connected(i))
continue

if(cs_get_user_team(i) == CS_TEAM_CT)
total_ct++

else if(cs_get_user_team(i) == CS_TEAM_T)
total_tr++
}

new ct_free = 1, a
total_tr -= 1
for(i = 1; i <= total_tr; i++)
{
if(++a == 4)
{
ct_free++
a = 1
}
}

if(ct_free - total_ct > 0)
return true

return false
}

public monitore_team_change(id)
{
new CsTeams:team = cs_get_user_team(id)
if(lastTeam[id] !=team)
{
teamChanged(id, team, lastTeam[id])
lastTeam[id] = team
}
}
Thank you very much for all.
__________________
Of Developer to apprentice.

.ThePro is offline
Send a message via MSN to .ThePro
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 01:46   Re: Manager code help =)
Reply With Quote #2

You tell us if there are errors. (aka Does it work?)
__________________
fysiks is offline
.ThePro
Member
Join Date: Aug 2011
Location: Brazil
Old 05-08-2012 , 02:40   Re: Manager code help =)
Reply With Quote #3

Eventually there are no errors. The role of plugin it is, pass CT only if have 3TR x 1 CT. And if not, can not mingle. But it seems that this is not happening.. I'd like a optimization the plugin and know that everything is okay.. HELP? :}
__________________
Of Developer to apprentice.


Last edited by .ThePro; 05-08-2012 at 02:42.
.ThePro is offline
Send a message via MSN to .ThePro
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 02:41   Re: Manager code help =)
Reply With Quote #4

Quote:
Originally Posted by .ThePro View Post
Eventually there are no errors. The role of plugin it is, pass CT only if have 3TR x 1 CT. And if not, can not mingle. I'd like a plug-in optimization and know that everything is okay.. HELP? :}
I'm not sure how much of that post is in english. Are you saying it works perfectly and has no errors?
__________________
fysiks is offline
.ThePro
Member
Join Date: Aug 2011
Location: Brazil
Old 05-08-2012 , 12:03   Re: Manager code help =)
Reply With Quote #5

God, this translator is useless.

You can optimize the plugin for me?
__________________
Of Developer to apprentice.

.ThePro is offline
Send a message via MSN to .ThePro
.ThePro
Member
Join Date: Aug 2011
Location: Brazil
Old 05-23-2012 , 22:50   Re: Manager code help =)
Reply With Quote #6

UP? Anyone? ):
__________________
Of Developer to apprentice.

.ThePro is offline
Send a message via MSN to .ThePro
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-24-2012 , 05:07   Re: Manager code help =)
Reply With Quote #7

Go and get your request translated.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply



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 00:31.


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