Junior Member
|
11-29-2006
, 18:01
[Engine] entity_get_int(), NS v3.2b1 and AMXX 1.76b
|
#1
|
Stumbled across a potential problem with using entity_get_int(playerid,EV_INT_team) to find a players team in Natural Selection v3.2b1 while rewriting the nscommands plugin to make it compatible with the latest version of NS. Instead of returning the values 1, 2 and 5 if a player is on marines, aliens or is spectating it is returning a value of 0 no matter what team the player is on. Testing the same code on a server running NS v3.1.3 and AMXX 1.75a resulted in entity_get_int(playerid,EV_INT_team) working perfectly and returning the correct value.
This is the nscommands code that I've rewritten, the command "amx_random" will print debug messages in global chat containing the values returned by entity_get_int(playerid,EV_INT_team) as a demo of above.
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <ns>
#define PLUGIN "mrcoffee's NS commands"
#define VERSION "1.0"
#define AUTHOR "mrcoffee"
#define ACCESS_REQUIRED ADMIN_BAN
new team
new name_target[32]
new name[32]
new auth_target[35]
new auth[35]
new userid_target
new userid
new command_info[32]
new player_id
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_alien","force_alien",ACCESS_REQUIRED,"<name or #userid>")
register_concmd("amx_marine","force_marine",ACCESS_REQUIRED,"<name or #userid>")
register_concmd("amx_uncomm","force_uncomm",ACCESS_REQUIRED," - force commander out of chair")
register_concmd("amx_random","force_random",ACCESS_REQUIRED,"<name or #userid> - omit to do all in rr")
register_concmd("amx_readyroom","force_readyroom",ACCESS_REQUIRED,"<name or #userid> - omit to do everybody")
}
public force_readyroom(id)
{
if (!access(id,ACCESS_REQUIRED))
{
return PLUGIN_HANDLED
}
get_user_name(id,name,32)
get_user_authid(id,auth,35)
if (read_argc() > 1)
{
read_argv(1,command_info,32)
player_id = cmd_target(id,command_info,1)
if (!player_id)
{
client_print(id,print_chat,"[AMXX] That player is not on the server")
return PLUGIN_HANDLED
}
get_user_name(player_id,name_target,32)
get_user_authid(player_id,auth_target,35)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: ready room %s",name,name_target)
case 1: client_print(0,print_chat,"ADMIN: ready room %s",name_target)
}
log_amx("Cmd: ^"%s<%d><%s><>^" ready room ^"%s<%d><%s><>^"",name,get_user_userid(id),auth,name_target,get_user_userid(player_id),auth_target)
engclient_cmd(player_id,"readyroom")
engclient_cmd(player_id,"readyroom")
return PLUGIN_HANDLED_MAIN
}
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: ready room all",name)
case 1: client_print(0,print_chat,"ADMIN: ready room all %s")
}
log_amx("Cmd: ^"%s<%d><%s><>^" ready room all",name,get_user_userid(id),auth)
readyroom_loop()
return PLUGIN_HANDLED_MAIN
}
public readyroom_loop()
{
new numforced = 0
for (new playerid; playerid <= get_maxplayers(); playerid++)
{
if (numforced > 4)
{
set_task(0.1,"readyroom_loop")
break
}
if (!is_valid_ent(playerid))
{
continue
}
team = entity_get_int(playerid,EV_INT_team)
if (team == 1 || team == 2)
{
engclient_cmd(playerid,"readyroom")
engclient_cmd(playerid,"readyroom")
numforced++
}
}
}
public force_random(id)
{
new numforced2 = 0
if (!access(id,ACCESS_REQUIRED))
{
return PLUGIN_HANDLED
}
for (new playerid; playerid <= get_maxplayers(); playerid++)
{
if (numforced2 > 6)
{
set_task(0.1,"force_random")
break
}
if (!is_valid_ent(playerid))
{
continue
}
team = entity_get_int(player_id,EV_INT_team)
if (team != 1 && team != 2 && team != 5)
{
new name[32]
get_user_name(playerid,name,32)
client_print(0,print_chat,"%s on team %d and has playerid %d",name,team,playerid)
engclient_cmd(playerid,"autoassign")
numforced2++
}
}
get_user_name(id,name,32)
log_amx("Cmd: ^"%s<%d><%s><>^" random all",name,get_user_userid(id),auth)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: random all",name)
case 1: client_print(0,print_chat,"ADMIN: random all %s")
}
return PLUGIN_HANDLED_MAIN
}
public force_uncomm(id)
{
if (!access(id,ACCESS_REQUIRED))
{
return PLUGIN_HANDLED
}
new is_comm = 0
for (new playerid; playerid <= get_maxplayers(); playerid++)
{
if (!is_valid_ent(playerid))
{
continue
}
if (ns_get_class(playerid) == CLASS_COMMANDER)
{
get_user_authid(playerid,auth_target,35)
get_user_name(playerid,name_target,32)
userid_target = get_user_userid(playerid)
engclient_cmd(playerid,"stopcommandermode")
is_comm++
break
}
}
if (is_comm == 0)
{
client_print(id,print_chat,"[AMXX] There is no commander to eject")
return PLUGIN_HANDLED
}
if (is_comm > 0)
{
get_user_name(id,name,32)
get_user_authid(id,auth,35)
userid = get_user_userid(id)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: uncomm %s",name,name_target)
case 1: client_print(0,print_chat,"ADMIN: uncomm %s",name_target)
}
log_amx("Cmd: ^"%s<d><%s><>^" uncomm ^"%s<d><%s><>^"",name,userid,auth,name_target,userid_target,auth_target)
}
return PLUGIN_HANDLED_MAIN
}
public force_marine(id)
{
if (!access(id,ACCESS_REQUIRED))
{
return PLUGIN_HANDLED
}
if (read_argc() > 1)
{
read_argv(1,command_info,32)
player_id = cmd_target(id,command_info,1)
if (!player_id)
{
client_print(id,print_chat,"[AMXX] That player is not on the server")
return PLUGIN_HANDLED
}
team = entity_get_int(player_id,EV_INT_team)
if (team == 1)
{
client_print(id,print_chat,"[AMXX] That player is already on marines")
return PLUGIN_HANDLED
}
get_user_name(id,name,32)
get_user_name(player_id,name_target,32)
get_user_authid(id,auth,32)
get_user_authid(player_id,auth_target,35)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: marine %s",name,name_target)
case 1: client_print(0,print_chat,"ADMIN: marine %s",name_target)
}
log_amx("Cmd: ^"%s<%d><%s><>^" alien ^"%s<%d><%s><>^"",name,get_user_userid(id),auth,name_target,get_user_userid(player_id),auth_target)
engclient_cmd(player_id,"readyroom")
engclient_cmd(player_id,"readyroom")
engclient_cmd(player_id,"jointeamone")
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
public force_alien(id)
{
if (!access(id,ACCESS_REQUIRED))
{
return PLUGIN_HANDLED
}
if (read_argc() > 1)
{
read_argv(1,command_info,32)
player_id = cmd_target(id,command_info,1)
if (!player_id)
{
client_print(id,print_chat,"[AMXX] That player is not on the server")
return PLUGIN_HANDLED
}
team = entity_get_int(player_id,EV_INT_team)
if (team == 2)
{
client_print(id,print_chat,"[AMXX] That player is already on aliens")
return PLUGIN_HANDLED
}
get_user_name(id,name,32)
get_user_name(player_id,name_target,32)
get_user_authid(id,auth,32)
get_user_authid(player_id,auth_target,35)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: alien %s",name,name_target)
case 1: client_print(0,print_chat,"ADMIN: alien %s",name_target)
}
log_amx("Cmd: ^"%s<%d><%s><>^" alien ^"%s<%d><%s><>^"",name,get_user_userid(id),auth,name_target,get_user_userid(player_id),auth_target)
engclient_cmd(player_id,"readyroom")
engclient_cmd(player_id,"readyroom")
engclient_cmd(player_id,"jointeamtwo")
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
|
|